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
commit c4bc902958
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View file

@ -606,7 +606,7 @@ function anthropicOpus47OrLater(apiId: string) {
}
function anthropicAdaptiveEfforts(apiId: string): string[] | null {
if (anthropicOpus47OrLater(apiId)) {
if (anthropicOpus47OrLater(apiId) || apiId.includes("fable-5")) {
return ["low", "medium", "high", "xhigh", "max"]
}
if (
@ -619,6 +619,10 @@ function anthropicAdaptiveEfforts(apiId: string): string[] | null {
return null
}
function anthropicOmitsThinking(apiId: string) {
return anthropicOpus47OrLater(apiId) || apiId.includes("fable-5")
}
function googleThinkingLevelEfforts(apiId: string) {
const id = apiId.toLowerCase()
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" } },
}
}
const adaptiveOpus = anthropicOpus47OrLater(model.api.id)
const adaptiveThinkingOmitted = anthropicOmitsThinking(model.api.id)
const adaptiveEfforts = anthropicAdaptiveEfforts(model.api.id)
if (
id.includes("deepseek-chat") ||
@ -734,10 +738,10 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
{
thinking: {
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
// survive (4.6/Sonnet 4.6 already default to "summarized").
...(adaptiveOpus ? { display: "summarized" } : {}),
...(adaptiveThinkingOmitted ? { display: "summarized" } : {}),
},
effort,
},
@ -884,7 +888,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
{
thinking: {
type: "adaptive",
...(adaptiveOpus ? { display: "summarized" } : {}),
...(adaptiveThinkingOmitted ? { display: "summarized" } : {}),
},
effort,
},
@ -921,7 +925,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
reasoningConfig: {
type: "adaptive",
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) => [
effort,
{
thinking: { type: "adaptive", ...(adaptiveOpus ? { display: "summarized" } : {}) },
thinking: { type: "adaptive", ...(adaptiveThinkingOmitted ? { display: "summarized" } : {}) },
output_config: { effort },
},
]),

View file

@ -3486,6 +3486,12 @@ describe("ProviderTransform.variants", () => {
efforts: ["low", "medium", "high", "xhigh", "max"],
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) {
test(`${testCase.name} ${apiId} returns supported reasoning efforts`, () => {