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
Reasoning from OpenAI-compatible providers that inline <think> tags leaks into text content #43770
For OpenAI-compatible providers whose models emit reasoning inline in content wrapped in <think>...</think> tags, opencode stores the raw tagged text verbatim as a text part. The UI then renders the model's chain-of-thought as regular assistant output instead of a collapsible thinking block.
opencode saves this whole string as one text part. The affected message reports reasoning: 0 tokens at message level, while the session total still shows accumulated reasoning tokens — so token accounting is also distorted (reasoning counted as output).
Expected behavior
Inline <think> blocks should be extracted into separate reasoning parts so they render as thinking, not as body text.
Suggested fix
Wrap affected provider/model instances with the AI SDK's extraction middleware, e.g.:
Apply extractReasoningMiddleware automatically for providers/models known to inline think tags (similar to how DeepSeek R1 is handled).
Expose a per-model config flag (e.g. reasoning.extract: "think-tags") in the model/provider schema so users can enable it for any OpenAI-compatible endpoint.
A safe fallback could also apply startWithReasoning: true semantics for models that omit the opening tag.
Impact
Users cannot review the agent's reasoning process (it appears as unreadable body text mixed with output).
Reasoning/output token attribution is wrong on affected messages.
If your issue is specifically about providers that intermittently send reasoning inline in content rather than in a separate reasoning_content field, it may be distinct enough to keep open — please clarify in a comment whether the stream sometimes omits reasoning_content entirely in favor of content with embedded tags, as that detail would distinguish this from the above.
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Re-filed for OpenCode 2.0 here: #54599. Reproduces on 2.0.25 (macOS and Windows) with opencode/big-pickle via OpenCode Zen — inline </think> reasoning is stored as a text part instead of a reasoning part. 104 of 152 text parts for this model in my session DB contain a literal </think>. Claude models on the same setup are unaffected.
Activity
github-actions commentedon Aug 21, 2026
This issue might be a duplicate of existing issues. Please check:
</think>delimiter as assistant text in OpenAI-compatible streams — overlapping symptom (think-tag content leaking as visible text) with a related root cause<think>…</think>rendering as body text instead of a collapsible reasoning blockIf your issue is specifically about providers that intermittently send reasoning inline in
contentrather than in a separatereasoning_contentfield, it may be distinct enough to keep open — please clarify in a comment whether the stream sometimes omitsreasoning_contententirely in favor ofcontentwith embedded tags, as that detail would distinguish this from the above.00kino547 commentedon Oct 11, 2026
its also happening for me but with opencode zen (big pickle)
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊
ashaker20 commentedon Oct 11, 2026
Re-filed for OpenCode 2.0 here: #54599. Reproduces on 2.0.25 (macOS and Windows) with
opencode/big-picklevia OpenCode Zen — inline</think>reasoning is stored as atextpart instead of areasoningpart. 104 of 152 text parts for this model in my session DB contain a literal</think>. Claude models on the same setup are unaffected.