fix(thinking): send explicit thinking:{type:adaptive} alongside output_config.effort
This commit is contained in:
parent
a077ee85bd
commit
ba508f2506
3 changed files with 15 additions and 2 deletions
|
|
@ -173,6 +173,12 @@ function applyFormat(fmt, body, cfg, caps) {
|
||||||
}
|
}
|
||||||
case "claude-adaptive": {
|
case "claude-adaptive": {
|
||||||
if (none && canDisable) { body.thinking = { type: "disabled" }; break; }
|
if (none && canDisable) { body.thinking = { type: "disabled" }; break; }
|
||||||
|
// output_config.effort alone does NOT turn thinking on: Anthropic requires
|
||||||
|
// an explicit thinking:{type:"adaptive"} on Opus 4.6/4.7/4.8 and Sonnet 4.6
|
||||||
|
// ("thinking is off unless you explicitly set it"), and Anthropic-compatible
|
||||||
|
// shims (e.g. GitHub Copilot /v1/messages) default thinking off even for
|
||||||
|
// Sonnet 5. Send both fields — the documented adaptive-thinking shape.
|
||||||
|
body.thinking = { type: "adaptive" };
|
||||||
const level = toLevel(eff);
|
const level = toLevel(eff);
|
||||||
body.output_config = { effort: level === "xhigh" ? "high" : level };
|
body.output_config = { effort: level === "xhigh" ? "high" : level };
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,9 @@ exports[`GOLDEN request: OpenAI → Claude > reasoning_effort → adaptive outpu
|
||||||
"type": "text",
|
"type": "text",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"thinking": {
|
||||||
|
"type": "adaptive",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,14 @@ describe("extractThinking", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("applyThinking per provider format", () => {
|
describe("applyThinking per provider format", () => {
|
||||||
it("claude 4.6+ → adaptive output_config (no budget_tokens)", () => {
|
it("claude 4.6+ → adaptive thinking + output_config (no budget_tokens)", () => {
|
||||||
const out = apply("claude", "claude-opus-4.7", { reasoning_effort: "high" }, "claude");
|
const out = apply("claude", "claude-opus-4.7", { reasoning_effort: "high" }, "claude");
|
||||||
expect(out.output_config).toEqual({ effort: "high" });
|
expect(out.output_config).toEqual({ effort: "high" });
|
||||||
expect(out.thinking).toBeUndefined();
|
// Anthropic: on Opus 4.6/4.7/4.8 and Sonnet 4.6 thinking stays OFF unless
|
||||||
|
// thinking:{type:"adaptive"} is sent explicitly; output_config alone is not
|
||||||
|
// enough (and Anthropic-compatible shims like Copilot default off even on
|
||||||
|
// Sonnet 5). Both fields together are the documented adaptive shape.
|
||||||
|
expect(out.thinking).toEqual({ type: "adaptive" });
|
||||||
});
|
});
|
||||||
it("claude haiku → enabled+budget", () => {
|
it("claude haiku → enabled+budget", () => {
|
||||||
const out = apply("claude", "claude-haiku-4.5", { reasoning_effort: "high" }, "claude");
|
const out = apply("claude", "claude-haiku-4.5", { reasoning_effort: "high" }, "claude");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue