diff options
| author | Aiden Cline <[email protected]> | 2026-04-24 11:10:47 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-04-24 11:10:47 -0400 |
| commit | 86715fecc469e7bf12e526d386e4927afc95fa3e (patch) | |
| tree | 579c2b2a6b104f849da92f0154ffc769e1cc59f6 | |
| parent | 3062d3e0705a3959ff1108c8aa699358c8ea05a7 (diff) | |
| download | opencode-86715fecc469e7bf12e526d386e4927afc95fa3e.tar.gz opencode-86715fecc469e7bf12e526d386e4927afc95fa3e.zip | |
fix: ensure assistant messages always have reasoning on them for deepseek (#24180)
| -rw-r--r-- | packages/opencode/src/provider/transform.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index 7fcfcd250..50529c4dd 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -175,6 +175,24 @@ function normalizeMessages( return result } + // Deepseek requires all assistant messages to have reasoning on them + if (model.api.id.includes("deepseek")) { + msgs = msgs.map((msg) => { + if (msg.role !== "assistant") return msg + if (Array.isArray(msg.content)) { + if (msg.content.some((part) => part.type === "reasoning")) return msg + return { ...msg, content: [...msg.content, { type: "reasoning", text: "" }] } + } + return { + ...msg, + content: [ + ...(msg.content ? [{ type: "text" as const, text: msg.content }] : []), + { type: "reasoning" as const, text: "" }, + ], + } + }) + } + if (typeof model.capabilities.interleaved === "object" && model.capabilities.interleaved.field) { const field = model.capabilities.interleaved.field return msgs.map((msg) => { |
