graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(codex): drop top-level max_output_tokens from Responses requests
Rach Pradhan24ffc3815c6a
diff --git a/src/agent_request_body.zig b/src/agent_request_body.zigindex 0d4a2ec2..d061e201 100644--- a/src/agent_request_body.zig+++ b/src/agent_request_body.zig@@ -209,11 +209,13 @@ pub fn buildBody(self: *Agent, tools: ?[]const u8, force_tool: bool, stream: bootry s.endArray();try s.objectField("store");try s.write(false);- // Bound every Responses request explicitly. The normal agent keeps- // the existing 16k ceiling; compaction gets a focused 4k handoff- // and title generation can override this to 64 tokens.- try s.objectField("max_output_tokens");- try s.write(responsesOutputLimit(self));+ // Do NOT send a top-level `max_output_tokens` on the Codex Responses+ // request. The chatgpt.com/backend-api/codex/responses backend rejects+ // it ("Unsupported parameter: max_output_tokens") on gpt-5.6-* models,+ // which hard-fails every turn (incl. the title task). openai/codex+ // itself never puts it at the request top level — there it is only a+ // tool argument (exec_command/wait output truncation). Output length is+ // bounded by the model's own cap and our prompts instead.try s.objectField("stream");try s.write(true);},diff --git a/src/agent_ws_test.zig b/src/agent_ws_test.zigindex dc4df2ac..f51a97c2 100644--- a/src/agent_ws_test.zig+++ b/src/agent_ws_test.zig@@ -91,7 +91,7 @@ test "buildBody (.responses): delta while WS live; full input after closeCodexWstry std.testing.expect(std.mem.indexOf(u8, delta_body, "\"previous_response_id\":\"resp_live\"") != null);try std.testing.expect(std.mem.indexOf(u8, delta_body, "third — not yet sent") != null);try std.testing.expect(std.mem.indexOf(u8, delta_body, "\"first\"") == null); // NOT resent — already on the server- try std.testing.expect(std.mem.indexOf(u8, delta_body, "\"max_output_tokens\":16000") != null);+ try std.testing.expect(std.mem.indexOf(u8, delta_body, "max_output_tokens") == null); // #codex: backend rejects a top-level max_output_tokens (gpt-5.6) — never emit it// Simulate closeCodexWs's effect (covered by its own unit test above)// without invoking it directly: it would call ws.WsClient.deinit on@@ -112,11 +112,11 @@ test "buildBody (.responses): delta while WS live; full input after closeCodexWsagent.compaction_request = true;const compact_body = try agent.buildBody(null, false, false, false);defer std.testing.allocator.free(compact_body);- try std.testing.expect(std.mem.indexOf(u8, compact_body, "\"max_output_tokens\":4096") != null);+ try std.testing.expect(std.mem.indexOf(u8, compact_body, "max_output_tokens") == null); // #codex: no top-level max_output_tokens even in compactionagent.compaction_request = false;agent.responses_output_limit = 64;const title_body = try agent.buildBody(null, false, false, false);defer std.testing.allocator.free(title_body);- try std.testing.expect(std.mem.indexOf(u8, title_body, "\"max_output_tokens\":64") != null);+ try std.testing.expect(std.mem.indexOf(u8, title_body, "max_output_tokens") == null); // #codex: no top-level max_output_tokens even for the bounded title task}