Skip to content

Commit e0b3ee6

Browse files
committed
fix: extend isDeepSeekR1 guard to cover Bedrock-hosted R1 via family field
The previous guard checked providerID === 'deepseek' and api.id containing 'reasoner', which only matched the direct DeepSeek API. Bedrock-hosted R1 has providerID 'amazon-bedrock' and api.id 'deepseek.r1-v1:0' — neither condition fired, so tools were still being sent to Bedrock R1. Broaden the guard to use the provider-agnostic family field ('deepseek-thinking') which is set for all DeepSeek reasoning variants regardless of hosting provider. Fall back to api.id substring matching ('deepseek.r1') as an additional safety net for cases where family may be absent.
1 parent 7dc3633 commit e0b3ee6

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

  • packages/opencode/src/session

packages/opencode/src/session/llm.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,19 @@ const live: Layer.Layer<
193193
},
194194
)
195195

196-
// DeepSeek R1 (deepseek-reasoner) does not honour the `tools` parameter on the
197-
// standard api.deepseek.com endpoint despite models.dev reporting tool_call: true.
198-
// When tools are sent, R1 ignores the definitions and writes the invocation as
199-
// markdown text inside its response — exactly the wrong behaviour. Disable tools
200-
// for it so the model falls back to conversational output instead.
196+
// DeepSeek R1 does not honour the `tools` parameter regardless of which provider
197+
// hosts it — neither the direct api.deepseek.com endpoint (model id: deepseek-reasoner,
198+
// providerID: deepseek) nor the AWS Bedrock endpoint (model id: deepseek.r1-v1:0,
199+
// providerID: amazon-bedrock) support function calling, even though models.dev
200+
// incorrectly reports tool_call: true for both. When tools are sent, R1 ignores
201+
// the definitions and writes the invocation as markdown text instead.
202+
// Detect R1 via the provider-agnostic `family` field ("deepseek-thinking") which
203+
// is set for all DeepSeek reasoning variants, or fall back to matching the known
204+
// model IDs directly for cases where family is absent.
201205
const isDeepSeekR1 =
202-
input.model.providerID === "deepseek" &&
203-
input.model.api.id.toLowerCase().includes("reasoner")
206+
input.model.family === "deepseek-thinking" ||
207+
(input.model.providerID === "deepseek" && input.model.api.id.toLowerCase().includes("reasoner")) ||
208+
input.model.api.id.toLowerCase().includes("deepseek.r1")
204209
const canTool = input.model.capabilities.toolcall && !isDeepSeekR1
205210
const tools = canTool ? resolveTools(input) : {}
206211

0 commit comments

Comments
 (0)