Visitar URL original
fix(opencode): support Claude Fable reasoning (#31546) · isaacfinnegan/whispercode@fe567cc · GitHub
Skip to content

Commit fe567cc

Browse files
authored
fix(opencode): support Claude Fable reasoning (anomalyco#31546)
1 parent 1cebc1e commit fe567cc

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

‎packages/opencode/src/provider/transform.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ function anthropicOpus47OrLater(apiId: string) {
606606
}
607607

608608
function anthropicAdaptiveEfforts(apiId: string): string[] | null {
609-
if (anthropicOpus47OrLater(apiId)) {
609+
if (anthropicOpus47OrLater(apiId) || apiId.includes("fable-5")) {
610610
return ["low", "medium", "high", "xhigh", "max"]
611611
}
612612
if (
@@ -619,6 +619,10 @@ function anthropicAdaptiveEfforts(apiId: string): string[] | null {
619619
return null
620620
}
621621

622+
function anthropicOmitsThinking(apiId: string) {
623+
return anthropicOpus47OrLater(apiId) || apiId.includes("fable-5")
624+
}
625+
622626
function googleThinkingLevelEfforts(apiId: string) {
623627
const id = apiId.toLowerCase()
624628
if (!id.includes("gemini-3")) return ["low", "high"]
@@ -671,7 +675,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
671675
thinking: { thinking: { type: "adaptive" } },
672676
}
673677
}
674-
const adaptiveOpus = anthropicOpus47OrLater(model.api.id)
678+
const adaptiveThinkingOmitted = anthropicOmitsThinking(model.api.id)
675679
const adaptiveEfforts = anthropicAdaptiveEfforts(model.api.id)
676680
if (
677681
id.includes("deepseek-chat") ||
@@ -734,10 +738,10 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
734738
{
735739
thinking: {
736740
type: "adaptive",
737-
// Opus 4.7+ flips the API default for `display` to "omitted", which
741+
// Newer adaptive-only models default `display` to "omitted", which
738742
// returns empty thinking blocks. Force "summarized" so summaries
739743
// survive (4.6/Sonnet 4.6 already default to "summarized").
740-
...(adaptiveOpus ? { display: "summarized" } : {}),
744+
...(adaptiveThinkingOmitted ? { display: "summarized" } : {}),
741745
},
742746
effort,
743747
},
@@ -884,7 +888,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
884888
{
885889
thinking: {
886890
type: "adaptive",
887-
...(adaptiveOpus ? { display: "summarized" } : {}),
891+
...(adaptiveThinkingOmitted ? { display: "summarized" } : {}),
888892
},
889893
effort,
890894
},
@@ -921,7 +925,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
921925
reasoningConfig: {
922926
type: "adaptive",
923927
maxReasoningEffort: effort,
924-
...(adaptiveOpus ? { display: "summarized" } : {}),
928+
...(adaptiveThinkingOmitted ? { display: "summarized" } : {}),
925929
},
926930
},
927931
]),
@@ -1011,7 +1015,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
10111015
adaptiveEfforts.map((effort) => [
10121016
effort,
10131017
{
1014-
thinking: { type: "adaptive", ...(adaptiveOpus ? { display: "summarized" } : {}) },
1018+
thinking: { type: "adaptive", ...(adaptiveThinkingOmitted ? { display: "summarized" } : {}) },
10151019
output_config: { effort },
10161020
},
10171021
]),

‎packages/opencode/test/provider/transform.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,6 +3486,12 @@ describe("ProviderTransform.variants", () => {
34863486
efforts: ["low", "medium", "high", "xhigh", "max"],
34873487
expectedHigh: { thinking: { type: "adaptive", display: "summarized" }, effort: "high" },
34883488
},
3489+
{
3490+
name: "fable 5",
3491+
apiIds: ["claude-fable-5"],
3492+
efforts: ["low", "medium", "high", "xhigh", "max"],
3493+
expectedHigh: { thinking: { type: "adaptive", display: "summarized" }, effort: "high" },
3494+
},
34893495
]) {
34903496
for (const apiId of testCase.apiIds) {
34913497
test(`${testCase.name} ${apiId} returns supported reasoning efforts`, () => {

0 commit comments

Comments
 (0)