mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-21 15:01:03 +00:00
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:
committed by
Josh Lehman
parent
dc86b6d72a
commit
1eae2fdd32
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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>;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user