fix(claude): normalize adaptive auto effort (#3792)

Claude adaptive requests without an explicit effort are normalized to
output_config.effort: "high" instead of forwarding the unsupported
literal value "auto" which Anthropic rejects with HTTP 400.
This commit is contained in:
Sutarto Jordan Chrisfivo
2026-09-05 21:37:32 +07:00
committed by decolua
parent 1442cc73ce
commit 77e6a227fe
2 changed files with 11 additions and 1 deletions

View File

@@ -246,7 +246,7 @@ function applyFormat(fmt, body, cfg, caps, supportedLevels) {
if (canDisable) body.thinking = { type: "adaptive" };
else delete body.thinking;
const level = toLevel(eff);
body.output_config = { effort: level === "xhigh" ? "high" : level };
body.output_config = { effort: level === "xhigh" || level === "auto" ? "high" : level };
break;
}
case "claude-budget": {

View File

@@ -82,6 +82,16 @@ describe("applyThinking per provider format", () => {
// Sonnet 5). Both fields together are the documented adaptive shape.
expect(out.thinking).toEqual({ type: "adaptive" });
});
it("claude adaptive thinking maps auto effort to a supported level", () => {
const out = apply("claude", "claude-opus-4.7", { thinking: { type: "adaptive" } }, "claude");
expect(out.output_config).toEqual({ effort: "high" });
expect(out.thinking).toEqual({ type: "adaptive" });
});
it("permanently adaptive Claude maps auto effort without adding a thinking switch", () => {
const out = apply("claude", "claude-fable-5-1", { thinking: { type: "adaptive" } }, "claude");
expect(out.output_config).toEqual({ effort: "high" });
expect(out.thinking).toBeUndefined();
});
it("Fable 5.1 → effort without a redundant thinking switch", () => {
const out = apply("claude", "claude-fable-5-1", { reasoning_effort: "high" }, "claude");
expect(out.output_config).toEqual({ effort: "high" });