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

View File

@@ -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 {
high: {
thinking: {

View File

@@ -3128,53 +3128,50 @@ describe("ProviderTransform.variants", () => {
})
describe("@ai-sdk/anthropic", () => {
test("sonnet 4.6 returns adaptive thinking options", () => {
const model = createMockModel({
id: "anthropic/claude-sonnet-4-6",
providerID: "anthropic",
api: {
id: "claude-sonnet-4-6",
url: "https://api.anthropic.com",
npm: "@ai-sdk/anthropic",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high", "max"])
expect(result.high).toEqual({
thinking: {
type: "adaptive",
},
effort: "high",
})
})
test("opus 4.7 returns adaptive thinking options with xhigh", () => {
const model = createMockModel({
id: "anthropic/claude-opus-4-7",
providerID: "anthropic",
api: {
id: "claude-opus-4-7",
url: "https://api.anthropic.com",
npm: "@ai-sdk/anthropic",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
expect(result.xhigh).toEqual({
thinking: {
type: "adaptive",
display: "summarized",
},
effort: "xhigh",
})
expect(result.max).toEqual({
thinking: {
type: "adaptive",
display: "summarized",
},
effort: "max",
})
})
for (const testCase of [
{
name: "opus 4.5",
apiIds: ["claude-opus-4-5-20251101", "claude-opus-4.5-20251101"],
efforts: ["low", "medium", "high"],
expectedHigh: { effort: "high" },
},
{
name: "sonnet 4.6",
apiIds: ["claude-sonnet-4-6", "claude-sonnet-4.6"],
efforts: ["low", "medium", "high", "max"],
expectedHigh: { thinking: { type: "adaptive" }, effort: "high" },
},
{
name: "opus 4.6",
apiIds: ["claude-opus-4-6", "claude-opus-4.6"],
efforts: ["low", "medium", "high", "max"],
expectedHigh: { thinking: { type: "adaptive" }, effort: "high" },
},
{
name: "opus 4.7",
apiIds: ["claude-opus-4-7", "claude-opus-4.7"],
efforts: ["low", "medium", "high", "xhigh", "max"],
expectedHigh: { thinking: { type: "adaptive", display: "summarized" }, effort: "high" },
},
]) {
for (const apiId of testCase.apiIds) {
test(`${testCase.name} ${apiId} returns supported reasoning efforts`, () => {
const result = ProviderTransform.variants(
createMockModel({
id: `anthropic/${apiId}`,
providerID: "anthropic",
api: {
id: apiId,
url: "https://api.anthropic.com",
npm: "@ai-sdk/anthropic",
},
}),
)
expect(Object.keys(result)).toEqual(testCase.efforts)
expect(result.high).toEqual(testCase.expectedHigh)
})
}
}
test("github copilot opus 4.7 returns only medium reasoning effort", () => {
const model = createMockModel({