From 6110df648504fbb26277d6e4dd0a6a363165bc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milicevic?= Date: Wed, 17 Jun 2026 22:53:55 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20raise=20OpenAI-compatible=20adapter=20de?= =?UTF-8?q?fault=20max=5Ftokens=204096=20=E2=86=92=208192?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Surfaced by a live grind: routing the executor at gpt-4o via the OpenAI-compatible adapter, a whole-file rewrite of a ~700-line file was truncated at the 4096-token default mid-output, so the closing `<<>>` sentinel was cut and the executor (correctly) rejected the incomplete block as "no FILE blocks". The Anthropic caller already used 8192; the executor rewrites entire files, so the OpenAI-compatible path needs the same headroom. After the fix, the same grind produced a complete patch that passed typecheck + tests + 3-persona self-review + adversarial gate end-to-end (stopping only at the push, which had no remote by design). Regression test asserts the 8192 default. --- packages/asil-runners/src/__tests__/wiring.test.ts | 4 ++++ packages/asil-runners/src/wiring.ts | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) 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) {