You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenAI-compatible reasoning streamed under reasoning field is dropped #35283
When an OpenAI-compatible provider streams its chain-of-thought under a reasoning delta field (instead of reasoning_content), opencode drops it entirely — no reasoning surfaces even though the provider is sending it.
The OpenAI Chat delta schema in packages/llm/src/protocols/openai-chat.ts only declares reasoning_content. Each SSE chunk is decoded with Protocol.jsonEvent → Schema.fromJsonString, which strips any key not on the struct, so reasoning is gone before step() ever runs.
I ran into this with Scaleway. It also affects self-hosted vLLM / SGLang deployments and OpenRouter's reasoning field.
Steps to reproduce
Configure an openai-compatible provider that emits reasoning under reasoning (e.g. Scaleway with a reasoning model).
Send a prompt that triggers reasoning.
The answer streams fine, but no reasoning is shown — even though the raw SSE chunks contain delta.reasoning.
Confirmed still reproducible on current main (4161695). Two touch points in packages/llm/src/protocols/openai-chat.ts:
OpenAIChatDelta (line ~146) declares only reasoning_content — the Schema decode strips any unknown key, so a provider emitting delta.reasoning loses it before step() runs.
step() (line ~419) reads only delta.reasoning_content.
Fix shape: add reasoning: optionalNull(Schema.String) to the delta struct and coalesce in step() (delta.reasoning ?? delta.reasoning_content). ~10 LOC plus an SSE fixture test covering both field names. This also covers vLLM/SGLang and OpenRouter's reasoning field, not just Scaleway.
Note: PR #35284 for this issue was closed by automated cleanup without merge — happy to pick this up with a fresh minimal PR if that direction is acceptable.
Same issue here in version 1.18.31, using gpt-oss-20b 32k context. Two same requests to a new fresh session give me different aswers: one with reasoning part separated, the other answer with reasoning part inside the text part.
Request and response 1: Reasoning part separated $ curl -X POST "http://agent:4096/session/ses_f5a563edcffev5kx58QILpCsw5/message" -H "Content-Type: application/json" -d '{ "model": { "providerID": "private", "modelID": "gpt-oss-20b-32k" }, "parts": [ { "type": "text", "text": "Who are you?" } ] }' | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1707 0 1546 100 161 1649 171 --:--:-- --:--:-- --:--:-- 1821 { "info": { "parentID": "msg_0a5bf1f77001hXEk1S03UJgpsb", "role": "assistant", "mode": "build", "agent": "build", "path": { "cwd": "/root/projects/default", "root": "/" }, "cost": 0, "tokens": { "total": 7550, "input": 34, "output": 63, "reasoning": 0, "cache": { "write": 0, "read": 7453 } }, "modelID": "gpt-oss-20b-32k", "providerID": "private", "time": { "created": 1789487161217, "completed": 1789487162132 }, "finish": "stop", "id": "msg_0a5bf1f810014WNLSg276GgEWx", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5" }, "parts": [ { "type": "step-start", "id": "prt_0a5bf210c0016NpW9VBxtowXqW", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf1f810014WNLSg276GgEWx" }, { "type": "reasoning", "text": "The user keep asking the same question. We should answer with minimal description. We can just say \"I am OpenCode, an AI.\" Let's keep.", "time": { "start": 1789487161614, "end": 1789487161948 }, "id": "prt_0a5bf210e001Ans0ACmyaYTLp8", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf1f810014WNLSg276GgEWx" }, { "type": "text", "text": "I’m **OpenCode**, an AI language model created by OpenAI that helps with coding tasks and questions.", "time": { "start": 1789487161950, "end": 1789487162125 }, "id": "prt_0a5bf225e0018Ao8HlmUI0QRJy", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf1f810014WNLSg276GgEWx" }, { "reason": "stop", "type": "step-finish", "tokens": { "total": 7550, "input": 34, "output": 63, "reasoning": 0, "cache": { "write": 0, "read": 7453 } }, "cost": 0, "id": "prt_0a5bf2311001yNMeVSXVn4CVwE", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf1f810014WNLSg276GgEWx" } ] }
Request and response 2: Reasoning part inside text part $ curl -X POST "http://agent-private1.lan:4096/session/ses_f5a563edcffev5kx58QILpCsw5/message" -H "Content-Type: application/json" -d '{ "model": { "providerID": "private", "modelID": "gpt-oss-20b-32k" }, "parts": [ { "type": "text", "text": "Who are you?" } ] }' | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1442 0 1281 100 161 1693 212 --:--:-- --:--:-- --:--:-- 1907 { "info": { "parentID": "msg_0a5bf323f001d91hkQMIVhVOlW", "role": "assistant", "mode": "build", "agent": "build", "path": { "cwd": "/root/projects/default", "root": "/" }, "cost": 0, "tokens": { "total": 7570, "input": 35, "output": 47, "reasoning": 0, "cache": { "write": 0, "read": 7488 } }, "modelID": "gpt-oss-20b-32k", "providerID": "private", "time": { "created": 1789487166022, "completed": 1789487166762 }, "finish": "stop", "id": "msg_0a5bf3246001zPVwfKIQfCLGQ3", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5" }, "parts": [ { "type": "step-start", "id": "prt_0a5bf33bc001BNy1lM13j4udK4", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf3246001zPVwfKIQfCLGQ3" }, { "type": "text", "text": "User keeps asking same question. Maybe they want description. Provide answer.I’m **OpenCode**, an AI language model built by OpenAI that assists with coding and technical questions.", "time": { "start": 1789487166397, "end": 1789487166757 }, "id": "prt_0a5bf33bd001AgEQ8L1J6qSx2l", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf3246001zPVwfKIQfCLGQ3" }, { "reason": "stop", "type": "step-finish", "tokens": { "total": 7570, "input": 35, "output": 47, "reasoning": 0, "cache": { "write": 0, "read": 7488 } }, "cost": 0, "id": "prt_0a5bf35270012Z2DgX45O4J23T", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf3246001zPVwfKIQfCLGQ3" } ] }
OpenCode v2 reads streamed reasoning from OpenAI-compatible providers in any of reasoning_content, reasoning or reasoning_text, and a provider can configure a custom field. Reasoning sent under reasoning (as vLLM does) shows up.
Activity
jaycampbell029-cmd commentedon Jul 10, 2026
Same here. I have no idea why in July 4th I could see reasoning and now I cannot.
vanbukin commentedon Aug 21, 2026
Any plans to fix this?
kvnloo commentedon Aug 24, 2026
Confirmed still reproducible on current main (4161695). Two touch points in packages/llm/src/protocols/openai-chat.ts:
OpenAIChatDelta(line ~146) declares onlyreasoning_content— the Schema decode strips any unknown key, so a provider emittingdelta.reasoningloses it beforestep()runs.step()(line ~419) reads onlydelta.reasoning_content.Fix shape: add
reasoning: optionalNull(Schema.String)to the delta struct and coalesce in step() (delta.reasoning ?? delta.reasoning_content). ~10 LOC plus an SSE fixture test covering both field names. This also covers vLLM/SGLang and OpenRouter'sreasoningfield, not just Scaleway.Note: PR #35284 for this issue was closed by automated cleanup without merge — happy to pick this up with a fresh minimal PR if that direction is acceptable.
barrenaedu commentedon Sep 15, 2026
Same issue here in version 1.18.31, using gpt-oss-20b 32k context. Two same requests to a new fresh session give me different aswers: one with reasoning part separated, the other answer with reasoning part inside the text part.
Request and response 1: Reasoning part separated
$ curl -X POST "http://agent:4096/session/ses_f5a563edcffev5kx58QILpCsw5/message" -H "Content-Type: application/json" -d '{ "model": { "providerID": "private", "modelID": "gpt-oss-20b-32k" }, "parts": [ { "type": "text", "text": "Who are you?" } ] }' | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1707 0 1546 100 161 1649 171 --:--:-- --:--:-- --:--:-- 1821 { "info": { "parentID": "msg_0a5bf1f77001hXEk1S03UJgpsb", "role": "assistant", "mode": "build", "agent": "build", "path": { "cwd": "/root/projects/default", "root": "/" }, "cost": 0, "tokens": { "total": 7550, "input": 34, "output": 63, "reasoning": 0, "cache": { "write": 0, "read": 7453 } }, "modelID": "gpt-oss-20b-32k", "providerID": "private", "time": { "created": 1789487161217, "completed": 1789487162132 }, "finish": "stop", "id": "msg_0a5bf1f810014WNLSg276GgEWx", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5" }, "parts": [ { "type": "step-start", "id": "prt_0a5bf210c0016NpW9VBxtowXqW", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf1f810014WNLSg276GgEWx" }, { "type": "reasoning", "text": "The user keep asking the same question. We should answer with minimal description. We can just say \"I am OpenCode, an AI.\" Let's keep.", "time": { "start": 1789487161614, "end": 1789487161948 }, "id": "prt_0a5bf210e001Ans0ACmyaYTLp8", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf1f810014WNLSg276GgEWx" }, { "type": "text", "text": "I’m **OpenCode**, an AI language model created by OpenAI that helps with coding tasks and questions.", "time": { "start": 1789487161950, "end": 1789487162125 }, "id": "prt_0a5bf225e0018Ao8HlmUI0QRJy", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf1f810014WNLSg276GgEWx" }, { "reason": "stop", "type": "step-finish", "tokens": { "total": 7550, "input": 34, "output": 63, "reasoning": 0, "cache": { "write": 0, "read": 7453 } }, "cost": 0, "id": "prt_0a5bf2311001yNMeVSXVn4CVwE", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf1f810014WNLSg276GgEWx" } ] }Request and response 2: Reasoning part inside text part
$ curl -X POST "http://agent-private1.lan:4096/session/ses_f5a563edcffev5kx58QILpCsw5/message" -H "Content-Type: application/json" -d '{ "model": { "providerID": "private", "modelID": "gpt-oss-20b-32k" }, "parts": [ { "type": "text", "text": "Who are you?" } ] }' | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1442 0 1281 100 161 1693 212 --:--:-- --:--:-- --:--:-- 1907 { "info": { "parentID": "msg_0a5bf323f001d91hkQMIVhVOlW", "role": "assistant", "mode": "build", "agent": "build", "path": { "cwd": "/root/projects/default", "root": "/" }, "cost": 0, "tokens": { "total": 7570, "input": 35, "output": 47, "reasoning": 0, "cache": { "write": 0, "read": 7488 } }, "modelID": "gpt-oss-20b-32k", "providerID": "private", "time": { "created": 1789487166022, "completed": 1789487166762 }, "finish": "stop", "id": "msg_0a5bf3246001zPVwfKIQfCLGQ3", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5" }, "parts": [ { "type": "step-start", "id": "prt_0a5bf33bc001BNy1lM13j4udK4", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf3246001zPVwfKIQfCLGQ3" }, { "type": "text", "text": "User keeps asking same question. Maybe they want description. Provide answer.I’m **OpenCode**, an AI language model built by OpenAI that assists with coding and technical questions.", "time": { "start": 1789487166397, "end": 1789487166757 }, "id": "prt_0a5bf33bd001AgEQ8L1J6qSx2l", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf3246001zPVwfKIQfCLGQ3" }, { "reason": "stop", "type": "step-finish", "tokens": { "total": 7570, "input": 35, "output": 47, "reasoning": 0, "cache": { "write": 0, "read": 7488 } }, "cost": 0, "id": "prt_0a5bf35270012Z2DgX45O4J23T", "sessionID": "ses_f5a563edcffev5kx58QILpCsw5", "messageID": "msg_0a5bf3246001zPVwfKIQfCLGQ3" } ] }ayebrian commentedon Sep 16, 2026
The issue is confirmed in 1.18.31 using Qwen 3.8 27B with vLLM 0.22.1 and vLLM 0.29.0
neriousy commentedon Oct 1, 2026
OpenCode v2 reads streamed reasoning from OpenAI-compatible providers in any of
reasoning_content,reasoningorreasoning_text, and a provider can configure a custom field. Reasoning sent underreasoning(as vLLM does) shows up.Fixed in #37558; the custom field came in #38227.
Closing as completed. If something doesn't work on v2, please open a new issue.