feat: Add support for claude opus 4.7 xhigh adaptive reasoning effort (#22833)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
This commit is contained in:
Graham Campbell
2026-04-16 16:57:36 +01:00
committed by GitHub
parent cc7acd90ab
commit 378c05f202
2 changed files with 107 additions and 6 deletions

View File

@@ -2246,6 +2246,46 @@ describe("ProviderTransform.variants", () => {
})
})
test("anthropic opus 4.7 models return adaptive thinking options with xhigh", () => {
const model = createMockModel({
id: "anthropic/claude-opus-4-7",
providerID: "gateway",
api: {
id: "anthropic/claude-opus-4-7",
url: "https://gateway.ai",
npm: "@ai-sdk/gateway",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
expect(result.xhigh).toEqual({
thinking: {
type: "adaptive",
},
effort: "xhigh",
})
expect(result.max).toEqual({
thinking: {
type: "adaptive",
},
effort: "max",
})
})
test("anthropic opus 4.7 dot-format models return adaptive thinking options with xhigh", () => {
const model = createMockModel({
id: "anthropic/claude-opus-4-7",
providerID: "gateway",
api: {
id: "anthropic/claude-opus-4.7",
url: "https://gateway.ai",
npm: "@ai-sdk/gateway",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
})
test("anthropic models return anthropic thinking options", () => {
const model = createMockModel({
id: "anthropic/claude-sonnet-4",
@@ -2654,6 +2694,32 @@ describe("ProviderTransform.variants", () => {
})
})
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",
},
effort: "xhigh",
})
expect(result.max).toEqual({
thinking: {
type: "adaptive",
},
effort: "max",
})
})
test("returns high and max with thinking config", () => {
const model = createMockModel({
id: "anthropic/claude-4",
@@ -2702,6 +2768,32 @@ describe("ProviderTransform.variants", () => {
})
})
test("anthropic opus 4.7 returns adaptive reasoning options with xhigh", () => {
const model = createMockModel({
id: "bedrock/anthropic-claude-opus-4-7",
providerID: "bedrock",
api: {
id: "anthropic.claude-opus-4-7",
url: "https://bedrock.amazonaws.com",
npm: "@ai-sdk/amazon-bedrock",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
expect(result.xhigh).toEqual({
reasoningConfig: {
type: "adaptive",
maxReasoningEffort: "xhigh",
},
})
expect(result.max).toEqual({
reasoningConfig: {
type: "adaptive",
maxReasoningEffort: "max",
},
})
})
test("returns WIDELY_SUPPORTED_EFFORTS with reasoningConfig", () => {
const model = createMockModel({
id: "bedrock/llama-4",