diff --git a/packages/asil-runners/src/__tests__/wiring.test.ts b/packages/asil-runners/src/__tests__/wiring.test.ts index a766ac7..b567203 100644 --- a/packages/asil-runners/src/__tests__/wiring.test.ts +++ b/packages/asil-runners/src/__tests__/wiring.test.ts @@ -283,6 +283,10 @@ describe('wiring', () => { { role: 'system', content: 'sys' }, { role: 'user', content: 'user' }, ]); + // Default max_tokens must be high enough for whole-file rewrites — + // 4096 truncated large files mid-output and the patch was rejected. + // A live gpt-4o grind surfaced this. (Matches the Anthropic caller.) + expect(body.max_tokens).toBe(8192); }); it('omits Authorization header when apiKey is unset (many local servers ignore auth)', async () => { diff --git a/packages/asil-runners/src/wiring.ts b/packages/asil-runners/src/wiring.ts index cab5cab..f90b786 100644 --- a/packages/asil-runners/src/wiring.ts +++ b/packages/asil-runners/src/wiring.ts @@ -191,7 +191,10 @@ export interface OpenAICompatibleOptions { apiKey?: string; /** Path appended to baseUrl. Default `/chat/completions`. */ endpoint?: string; - /** Max output tokens per call. Default 4096. */ + /** Max output tokens per call. Default 8192 — matches the Anthropic + * caller. The executor rewrites WHOLE files, so a low cap truncates + * large-file rewrites mid-output (the closing `<<>>` + * sentinel gets cut), and the patch is rejected. 4096 was too low. */ maxTokens?: number; /** Injectable fetch for tests. Defaults to global fetch. */ fetchImpl?: typeof fetch; @@ -233,7 +236,7 @@ function postOpenAICompatible( headers, body: JSON.stringify({ ...body, - max_tokens: opts.maxTokens ?? 4096, + max_tokens: opts.maxTokens ?? 8192, }), }).then(async (response) => { if (!response.ok) {