Revert tool-choice forcing — the Codex regression was strict:null

The GPT-account (Codex) path supports tool calls and worked before; my
forced tool_choice broke it and was the wrong fix. The real regression was
strict:null in the rebuild's tool definitions, which made the endpoint drop
the tool list so the model had nothing to call — a "Done" run that hired no
one. Forcing then turned that silent failure into a red one.

Restore the original "auto" loop (no forced tool_choice, no finish tool) and
keep only the one-line strict:null omission. Codex now receives valid tools
on the working "auto" choice, as in the version that worked.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 4.8 committed 2026-06-10 23:17:42 -04:00
1 parent 74422da4f8
commit 97242ae684
13 files changed
+57 -160

No files matched your search

@@ -210,22 +210,13 @@ describe("credential resolver", () => {
});
});
describe("tool definitions and forced tool choice", () => {
describe("responses tool definitions", () => {
const tools = [{ name: "hire_agent", description: "Add a report.", parameters: { type: "object", properties: {} } }];
test("Responses tool defs omit strict when null, keep it when boolean", () => {
test("omit strict when null (so the Codex endpoint keeps the tools), keep it when boolean", () => {
const codex = responsesToolDefs(tools, null)[0] as Record<string, unknown>;
expect("strict" in codex).toBe(false); // null would make the endpoint drop the tools
expect("strict" in codex).toBe(false); // strict:null is malformed and makes the endpoint drop the tools
expect(responsesToolDefs(tools)[0]).toMatchObject({ type: "function", name: "hire_agent", strict: false });
expect(responsesToolDefs(tools, true)[0]).toMatchObject({ strict: true });
});
test("Bedrock and Gemini encode a forced tool choice", () => {
expect(bedrockToolConfig(tools, "required").toolChoice).toEqual({ any: {} });
expect(bedrockToolConfig(tools).toolChoice).toEqual({ auto: {} });
const vertex = vertexRequestBody({ model: "m", instructions: null, messages: [], tools, toolChoice: "required" });
expect(vertex.toolConfig).toEqual({ functionCallingConfig: { mode: "ANY" } });
const anti = antigravityRequestBody({ model: "m", projectId: "p", instructions: null, messages: [], tools, requestId: "r" });
expect((anti.request as Record<string, unknown>).toolConfig).toEqual({ functionCallingConfig: { mode: "AUTO" } });
});
});