diff --git a/docs/tools/thinking.md b/docs/tools/thinking.md index d23f446b71a..950a3614144 100644 --- a/docs/tools/thinking.md +++ b/docs/tools/thinking.md @@ -13,7 +13,7 @@ title: "Thinking levels" - low → “think hard” - medium → “think harder” - high → “ultrathink” (max budget) - - xhigh → “ultrathink+” (GPT-5.2 + Codex models and Anthropic Claude Opus 4.7 effort) + - xhigh → “ultrathink+” (GPT-5.2+ and Codex models, plus Anthropic Claude Opus 4.7 effort) - adaptive → provider-managed adaptive thinking (supported for Claude 4.6 on Anthropic/Bedrock and Anthropic Claude Opus 4.7) - max → provider max reasoning (currently Anthropic Claude Opus 4.7) - `x-high`, `x_high`, `extra-high`, `extra high`, and `extra_high` map to `xhigh`. diff --git a/src/agents/openai-reasoning-effort.test.ts b/src/agents/openai-reasoning-effort.test.ts new file mode 100644 index 00000000000..09e9af74e5a --- /dev/null +++ b/src/agents/openai-reasoning-effort.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, it } from "vitest"; +import { + resolveOpenAIReasoningEffortForModel, + resolveOpenAISupportedReasoningEfforts, +} from "./openai-reasoning-effort.js"; + +describe("OpenAI reasoning effort support", () => { + it.each([ + { provider: "openai", id: "gpt-5.5" }, + { provider: "openai-codex", id: "gpt-5.5" }, + ])("preserves xhigh for $provider/$id", (model) => { + expect(resolveOpenAISupportedReasoningEfforts(model)).toContain("xhigh"); + expect(resolveOpenAIReasoningEffortForModel({ model, effort: "xhigh" })).toBe("xhigh"); + }); + + it("does not downgrade xhigh when Pi compat metadata declares it explicitly", () => { + const model = { + provider: "openai-codex", + id: "gpt-5.5", + compat: { + supportedReasoningEfforts: ["low", "medium", "high", "xhigh"], + }, + }; + + expect(resolveOpenAIReasoningEffortForModel({ model, effort: "xhigh" })).toBe("xhigh"); + }); +}); diff --git a/src/agents/pi-embedded-runner/openai-stream-wrappers.test.ts b/src/agents/pi-embedded-runner/openai-stream-wrappers.test.ts index a29001c5d11..663727a8922 100644 --- a/src/agents/pi-embedded-runner/openai-stream-wrappers.test.ts +++ b/src/agents/pi-embedded-runner/openai-stream-wrappers.test.ts @@ -158,4 +158,25 @@ describe("createOpenAIThinkingLevelWrapper", () => { expect(payloads[0]?.reasoning).toEqual({ effort: level }); } }); + + it.each([ + { + api: "openai-responses", + provider: "openai", + id: "gpt-5.5", + }, + { + api: "openai-codex-responses", + provider: "openai-codex", + id: "gpt-5.5", + }, + ] as const)("preserves xhigh for $provider/$id", (model) => { + const { baseStreamFn, payloads } = createPayloadCapture({ + initialReasoning: { effort: "high" }, + }); + const wrapped = createOpenAIThinkingLevelWrapper(baseStreamFn, "xhigh"); + void wrapped(model as Model, { messages: [] }, {}); + + expect(payloads[0]?.reasoning).toEqual({ effort: "xhigh" }); + }); });