fix(opencode): support Claude Fable reasoning (#31546)

This commit is contained in:
Aiden Cline
2026-06-09 12:38:53 -05:00
committed by GitHub
parent d68397b42f
commit c4bc902958
2 changed files with 17 additions and 7 deletions
+11 -7
View File
@@ -606,7 +606,7 @@ function anthropicOpus47OrLater(apiId: string) {
} }
function anthropicAdaptiveEfforts(apiId: string): string[] | null { function anthropicAdaptiveEfforts(apiId: string): string[] | null {
if (anthropicOpus47OrLater(apiId)) { if (anthropicOpus47OrLater(apiId) || apiId.includes("fable-5")) {
return ["low", "medium", "high", "xhigh", "max"] return ["low", "medium", "high", "xhigh", "max"]
} }
if ( if (
@@ -619,6 +619,10 @@ function anthropicAdaptiveEfforts(apiId: string): string[] | null {
return null return null
} }
function anthropicOmitsThinking(apiId: string) {
return anthropicOpus47OrLater(apiId) || apiId.includes("fable-5")
}
function googleThinkingLevelEfforts(apiId: string) { function googleThinkingLevelEfforts(apiId: string) {
const id = apiId.toLowerCase() const id = apiId.toLowerCase()
if (!id.includes("gemini-3")) return ["low", "high"] if (!id.includes("gemini-3")) return ["low", "high"]
@@ -671,7 +675,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
thinking: { thinking: { type: "adaptive" } }, thinking: { thinking: { type: "adaptive" } },
} }
} }
const adaptiveOpus = anthropicOpus47OrLater(model.api.id) const adaptiveThinkingOmitted = anthropicOmitsThinking(model.api.id)
const adaptiveEfforts = anthropicAdaptiveEfforts(model.api.id) const adaptiveEfforts = anthropicAdaptiveEfforts(model.api.id)
if ( if (
id.includes("deepseek-chat") || id.includes("deepseek-chat") ||
@@ -734,10 +738,10 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
{ {
thinking: { thinking: {
type: "adaptive", type: "adaptive",
// Opus 4.7+ flips the API default for `display` to "omitted", which // Newer adaptive-only models default `display` to "omitted", which
// returns empty thinking blocks. Force "summarized" so summaries // returns empty thinking blocks. Force "summarized" so summaries
// survive (4.6/Sonnet 4.6 already default to "summarized"). // survive (4.6/Sonnet 4.6 already default to "summarized").
...(adaptiveOpus ? { display: "summarized" } : {}), ...(adaptiveThinkingOmitted ? { display: "summarized" } : {}),
}, },
effort, effort,
}, },
@@ -884,7 +888,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
{ {
thinking: { thinking: {
type: "adaptive", type: "adaptive",
...(adaptiveOpus ? { display: "summarized" } : {}), ...(adaptiveThinkingOmitted ? { display: "summarized" } : {}),
}, },
effort, effort,
}, },
@@ -921,7 +925,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
reasoningConfig: { reasoningConfig: {
type: "adaptive", type: "adaptive",
maxReasoningEffort: effort, maxReasoningEffort: effort,
...(adaptiveOpus ? { display: "summarized" } : {}), ...(adaptiveThinkingOmitted ? { display: "summarized" } : {}),
}, },
}, },
]), ]),
@@ -1011,7 +1015,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
adaptiveEfforts.map((effort) => [ adaptiveEfforts.map((effort) => [
effort, effort,
{ {
thinking: { type: "adaptive", ...(adaptiveOpus ? { display: "summarized" } : {}) }, thinking: { type: "adaptive", ...(adaptiveThinkingOmitted ? { display: "summarized" } : {}) },
output_config: { effort }, output_config: { effort },
}, },
]), ]),
@@ -3486,6 +3486,12 @@ describe("ProviderTransform.variants", () => {
efforts: ["low", "medium", "high", "xhigh", "max"], efforts: ["low", "medium", "high", "xhigh", "max"],
expectedHigh: { thinking: { type: "adaptive", display: "summarized" }, effort: "high" }, expectedHigh: { thinking: { type: "adaptive", display: "summarized" }, effort: "high" },
}, },
{
name: "fable 5",
apiIds: ["claude-fable-5"],
efforts: ["low", "medium", "high", "xhigh", "max"],
expectedHigh: { thinking: { type: "adaptive", display: "summarized" }, effort: "high" },
},
]) { ]) {
for (const apiId of testCase.apiIds) { for (const apiId of testCase.apiIds) {
test(`${testCase.name} ${apiId} returns supported reasoning efforts`, () => { test(`${testCase.name} ${apiId} returns supported reasoning efforts`, () => {