Skip to content

Commit 0e072a5

Browse files
authored
fix: bump openrouter sdk version to resolve deepseek reasoning issue (bug was in sdk pkg) (anomalyco#24435)
1 parent b0aaaa3 commit 0e072a5

4 files changed

Lines changed: 83 additions & 4 deletions

File tree

bun.lock

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"@opencode-ai/plugin": "workspace:*",
116116
"@opencode-ai/script": "workspace:*",
117117
"@opencode-ai/sdk": "workspace:*",
118-
"@openrouter/ai-sdk-provider": "2.5.1",
118+
"@openrouter/ai-sdk-provider": "2.8.1",
119119
"@opentelemetry/api": "1.9.0",
120120
"@opentelemetry/context-async-hooks": "2.6.1",
121121
"@opentelemetry/exporter-trace-otlp-http": "0.214.0",

packages/opencode/src/provider/transform.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,11 @@ function normalizeMessages(
193193
})
194194
}
195195

196-
if (typeof model.capabilities.interleaved === "object" && model.capabilities.interleaved.field) {
196+
if (
197+
typeof model.capabilities.interleaved === "object" &&
198+
model.capabilities.interleaved.field &&
199+
model.api.npm !== "@openrouter/ai-sdk-provider"
200+
) {
197201
const field = model.capabilities.interleaved.field
198202
return msgs.map((msg) => {
199203
if (msg.role === "assistant" && Array.isArray(msg.content)) {

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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,79 @@ describe("session.message-v2.toModelMessage", () => {
873873
])
874874
})
875875

876+
test("preserves OpenRouter reasoning details through provider transform", async () => {
877+
const assistantID = "m-assistant"
878+
const openrouterModel: Provider.Model = {
879+
...model,
880+
id: ModelID.make("deepseek/deepseek-v4-pro"),
881+
providerID: ProviderID.make("openrouter"),
882+
api: {
883+
id: "deepseek/deepseek-v4-pro",
884+
url: "https://openrouter.ai/api/v1",
885+
npm: "@openrouter/ai-sdk-provider",
886+
},
887+
capabilities: {
888+
...model.capabilities,
889+
reasoning: true,
890+
interleaved: { field: "reasoning_details" },
891+
},
892+
}
893+
const reasoningDetails = [
894+
{
895+
type: "reasoning.text",
896+
text: "thinking",
897+
format: "unknown",
898+
index: 0,
899+
},
900+
]
901+
const input: MessageV2.WithParts[] = [
902+
{
903+
info: assistantInfo(assistantID, "m-parent", undefined, {
904+
providerID: openrouterModel.providerID,
905+
modelID: openrouterModel.id,
906+
}),
907+
parts: [
908+
{
909+
...basePart(assistantID, "a1"),
910+
type: "reasoning",
911+
text: "thinking",
912+
time: { start: 0 },
913+
metadata: {
914+
openrouter: {
915+
reasoning_details: reasoningDetails,
916+
},
917+
},
918+
},
919+
{
920+
...basePart(assistantID, "a2"),
921+
type: "text",
922+
text: "answer",
923+
},
924+
] as MessageV2.Part[],
925+
},
926+
]
927+
928+
expect(
929+
ProviderTransform.message(await MessageV2.toModelMessages(input, openrouterModel), openrouterModel, {}),
930+
).toStrictEqual([
931+
{
932+
role: "assistant",
933+
content: [
934+
{
935+
type: "reasoning",
936+
text: "thinking",
937+
providerOptions: {
938+
openrouter: {
939+
reasoning_details: reasoningDetails,
940+
},
941+
},
942+
},
943+
{ type: "text", text: "answer" },
944+
],
945+
},
946+
])
947+
})
948+
876949
test("splits assistant messages on step-start boundaries", async () => {
877950
const assistantID = "m-assistant"
878951

0 commit comments

Comments
 (0)