Skip to content

Commit c090a62

Browse files
committed
fix(opencode): follow latest adaptive reasoning variants
1 parent 43e999a commit c090a62

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

packages/opencode/src/provider/transform.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ function normalizeMessages(
5151
_options: Record<string, unknown>,
5252
): ModelMessage[] {
5353
const modelID = `${model.id} ${model.api.id}`.toLowerCase()
54-
const preserveAdaptiveAnthropicReasoning = ["sonnet-4-6", "sonnet-4.6", "opus-4-6", "opus-4.6"].some(
55-
(variant) => modelID.includes(variant),
56-
)
54+
const preserveAdaptiveAnthropicReasoning = !!anthropicAdaptiveEfforts(modelID)
5755

5856
// Many providers (Anthropic, Bedrock, and proxies like openai-compatible
5957
// forwarding to Bedrock) reject messages with empty text content blocks.
@@ -409,10 +407,12 @@ const WIDELY_SUPPORTED_EFFORTS = ["low", "medium", "high"]
409407
const OPENAI_EFFORTS = ["none", "minimal", ...WIDELY_SUPPORTED_EFFORTS, "xhigh"]
410408

411409
function anthropicAdaptiveEfforts(apiId: string): string[] | null {
412-
if (["opus-4-7", "opus-4.7"].some((v) => apiId.includes(v))) {
410+
const normalized = apiId.toLowerCase()
411+
412+
if (["opus-4-7", "opus-4.7"].some((v) => normalized.includes(v))) {
413413
return ["low", "medium", "high", "xhigh", "max"]
414414
}
415-
if (["opus-4-6", "opus-4.6", "sonnet-4-6", "sonnet-4.6"].some((v) => apiId.includes(v))) {
415+
if (["opus-4-6", "opus-4.6", "sonnet-4-6", "sonnet-4.6"].some((v) => normalized.includes(v))) {
416416
return ["low", "medium", "high", "max"]
417417
}
418418
return null

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,10 +1215,10 @@ describe("ProviderTransform.message - anthropic empty content filtering", () =>
12151215
test("preserves whitespace text separators in assistant reasoning messages", () => {
12161216
const adaptiveAnthropicModel = {
12171217
...anthropicModel,
1218-
id: "anthropic/claude-sonnet-4-6",
1218+
id: "anthropic/claude-opus-4-7",
12191219
api: {
12201220
...anthropicModel.api,
1221-
id: "claude-sonnet-4-6-20260301",
1221+
id: "claude-opus-4-7-20260401",
12221222
},
12231223
capabilities: {
12241224
...anthropicModel.capabilities,

packages/opencode/test/session/message-v2.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,10 @@ describe("session.message-v2.toModelMessage", () => {
723723
const assistantID = "m-assistant-reasoning"
724724
const adaptiveModel: Provider.Model = {
725725
...model,
726-
id: ModelID.make("anthropic/claude-sonnet-4-6"),
726+
id: ModelID.make("anthropic/claude-opus-4-7"),
727727
providerID: ProviderID.make("anthropic"),
728728
api: {
729-
id: "claude-sonnet-4-6-20260301",
729+
id: "claude-opus-4-7-20260401",
730730
url: "https://api.anthropic.com",
731731
npm: "@ai-sdk/anthropic",
732732
},

0 commit comments

Comments
 (0)