fix(context-window): prioritize config over model for context window resolution

resolveContextWindowInfo now uses config > model > default priority so
explicit --context-window flag overrides model defaults. Also adds
--context-window CLI option to the run command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jiayuan Zhang 2026-02-15 21:37:02 +08:00
parent 74c0ca0ddc
commit 40a2e8ae55
3 changed files with 32 additions and 13 deletions

View file

@ -28,6 +28,7 @@ type RunOptions = {
runLog?: boolean;
toolsAllow?: string[];
toolsDeny?: string[];
contextWindow?: number;
help?: boolean;
};
@ -49,6 +50,7 @@ ${cyan("Options:")}
${yellow("--session")} ID Session ID for persistence
${yellow("--debug")} Enable debug logging
${yellow("--run-log")} Enable structured run logging (run-log.jsonl)
${yellow("--context-window")} N Override context window token count
${yellow("--help")}, -h Show this help
${cyan("Tools Configuration:")}
@ -141,6 +143,11 @@ function parseArgs(argv: string[]): { opts: RunOptions; prompt: string } {
opts.toolsDeny = value?.split(",").map((s) => s.trim()) ?? [];
continue;
}
if (arg === "--context-window") {
const value = args.shift();
opts.contextWindow = value ? parseInt(value, 10) : undefined;
continue;
}
if (arg === "--") {
promptParts.push(...args);
break;
@ -213,6 +220,7 @@ export async function runCommand(args: string[]): Promise<void> {
debug: opts.debug,
enableRunLog,
tools: toolsConfig,
contextWindowTokens: opts.contextWindow,
});
const sessionDir = join(DATA_DIR, "sessions", agent.sessionId);