fix(provider): align Anthropic Opus 4.5 efforts (#26275)

This commit is contained in:
Kit Langton
2026-05-08 00:06:07 -04:00
committed by GitHub
parent 319498e2fd
commit e0396b809a
2 changed files with 48 additions and 47 deletions
@@ -811,6 +811,10 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
) )
} }
if (["opus-4-5", "opus-4.5"].some((v) => model.api.id.includes(v))) {
return Object.fromEntries(WIDELY_SUPPORTED_EFFORTS.map((effort) => [effort, { effort }]))
}
return { return {
high: { high: {
thinking: { thinking: {
@@ -3128,53 +3128,50 @@ describe("ProviderTransform.variants", () => {
}) })
describe("@ai-sdk/anthropic", () => { describe("@ai-sdk/anthropic", () => {
test("sonnet 4.6 returns adaptive thinking options", () => { for (const testCase of [
const model = createMockModel({ {
id: "anthropic/claude-sonnet-4-6", name: "opus 4.5",
providerID: "anthropic", apiIds: ["claude-opus-4-5-20251101", "claude-opus-4.5-20251101"],
api: { efforts: ["low", "medium", "high"],
id: "claude-sonnet-4-6", expectedHigh: { effort: "high" },
url: "https://api.anthropic.com", },
npm: "@ai-sdk/anthropic", {
}, name: "sonnet 4.6",
}) apiIds: ["claude-sonnet-4-6", "claude-sonnet-4.6"],
const result = ProviderTransform.variants(model) efforts: ["low", "medium", "high", "max"],
expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"]) expectedHigh: { thinking: { type: "adaptive" }, effort: "high" },
expect(result.high).toEqual({ },
thinking: { {
type: "adaptive", name: "opus 4.6",
}, apiIds: ["claude-opus-4-6", "claude-opus-4.6"],
effort: "high", efforts: ["low", "medium", "high", "max"],
}) expectedHigh: { thinking: { type: "adaptive" }, effort: "high" },
}) },
{
test("opus 4.7 returns adaptive thinking options with xhigh", () => { name: "opus 4.7",
const model = createMockModel({ apiIds: ["claude-opus-4-7", "claude-opus-4.7"],
id: "anthropic/claude-opus-4-7", efforts: ["low", "medium", "high", "xhigh", "max"],
providerID: "anthropic", expectedHigh: { thinking: { type: "adaptive", display: "summarized" }, effort: "high" },
api: { },
id: "claude-opus-4-7", ]) {
url: "https://api.anthropic.com", for (const apiId of testCase.apiIds) {
npm: "@ai-sdk/anthropic", test(`${testCase.name} ${apiId} returns supported reasoning efforts`, () => {
}, const result = ProviderTransform.variants(
}) createMockModel({
const result = ProviderTransform.variants(model) id: `anthropic/${apiId}`,
expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"]) providerID: "anthropic",
expect(result.xhigh).toEqual({ api: {
thinking: { id: apiId,
type: "adaptive", url: "https://api.anthropic.com",
display: "summarized", npm: "@ai-sdk/anthropic",
}, },
effort: "xhigh", }),
}) )
expect(result.max).toEqual({ expect(Object.keys(result)).toEqual(testCase.efforts)
thinking: { expect(result.high).toEqual(testCase.expectedHigh)
type: "adaptive", })
display: "summarized", }
}, }
effort: "max",
})
})
test("github copilot opus 4.7 returns only medium reasoning effort", () => { test("github copilot opus 4.7 returns only medium reasoning effort", () => {
const model = createMockModel({ const model = createMockModel({