feat: pass modelId to context engine assemble()

Context engine plugins can now receive the current model identifier
in assemble() params, enabling model-aware context formatting.

For example, a plugin could:
- Use XML formatting for Claude models
- Use terse/compressed context for small local models (7B)
- Adjust token budgets based on model context window size

The model param is optional and backward-compatible — existing
plugins that don't use it are unaffected.
This commit is contained in:
Block Thyme LLC
2026-03-15 23:37:46 +08:00
committed by Josh Lehman
parent dc86b6d72a
commit 1eae2fdd32
3 changed files with 5 additions and 0 deletions

View File

@@ -2167,6 +2167,7 @@ export async function runEmbeddedAttempt(
sessionKey: params.sessionKey,
messages: activeSession.messages,
tokenBudget: params.contextTokenBudget,
model: params.modelId,
});
if (assembled.messages !== activeSession.messages) {
activeSession.agent.replaceMessages(assembled.messages);

View File

@@ -40,6 +40,7 @@ export class LegacyContextEngine implements ContextEngine {
sessionKey?: string;
messages: AgentMessage[];
tokenBudget?: number;
model?: string;
}): Promise<AssembleResult> {
// Pass-through: the existing sanitize -> validate -> limit -> repair pipeline
// in attempt.ts handles context assembly for the legacy engine.

View File

@@ -131,6 +131,9 @@ export interface ContextEngine {
sessionKey?: string;
messages: AgentMessage[];
tokenBudget?: number;
/** Current model identifier (e.g. "claude-opus-4", "gpt-4o", "qwen2.5-7b").
* Allows context engine plugins to adapt formatting per model. */
model?: string;
}): Promise<AssembleResult>;
/**