ai: Thinking Shows Twice When a reasoning.text Detail Repeats Streamed reasoning_content
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start with packages/ai/src/protocols/openai-chat.ts, especially detailText and reasoningTextObserved, then review the OpenAI chat provider tests in packages/ai/test/provider/openai-chat.test.ts. Reproduce the stream where reasoning_content is followed by matching reasoning.text details. Done means the Thought block contains the text once and the regression test passes.
Written by the indexing model from the issue text.
Description
Description
Claude's thinking shows twice in the Thought block when the model is reached through an OpenAI-compatible gateway that streams reasoning_content and then sends the signed thinking block as one reasoning.text entry in reasoning_details. I see it in OpenChamber. The doubled text is also in the stored session, so it does not depend on the interface.
The next request sends the doubled text back as reasoning_content. The signed entry itself is sent back correctly.
The cause is in packages/ai/src/protocols/openai-chat.ts. detailText returns the text of every reasoning.text entry, and OpenCode appends that text as another reasoning delta after the streamed chunks. reasoningTextObserved already stops this for Kimi's summary entries but has no effect on reasoning.text.
The code is the same in v2.2.7, v2.3.2 and dev (ae88eb6a7).
In my local database, 730 of 918 reasoning blocks from Claude Sonnet and 188 of 219 from Claude Haiku are exactly doubled. The GPT model I use (321 blocks) shows no doubling.
I have a two-line fix with a regression test, and it passes the related existing provider tests. I can open a PR if a maintainer wants one.
Plugins
Two local plugins (memory and environment setup). Neither mentions reasoning or thinking.
OpenCode version
2.2.7 (I also read the source of 2.3.2 and dev)
Steps to reproduce
-
Use a Claude Sonnet or Haiku model through a gateway that streams the chunks below on
/v1/chat/completions. OpenCodex does this. OpenRouter sends both fields in one frame and is not affected.{"delta":{"reasoning_content":"Think "}} {"delta":{"reasoning_content":"hard."}} {"delta":{"reasoning_details":[{"type":"reasoning.text","text":"Think hard.","signature":"...","format":"anthropic-claude-v1","index":0}]}} {"delta":{"content":"Done"},"finish_reason":"stop"} -
Ask a question that makes the model think.
-
Open the Thought block. It reads "Think hard.Think hard." and should read "Think hard."
The same stream as a test in packages/ai/test/provider/openai-chat.test.ts fails with Received: "Think hard.Think hard.".
Screenshot
No response
Operating System
macOS 27.2
Terminal
OpenChamber (web UI)
- Dominant language
- TypeScript
- Stars
- 227k
- Forks
- 30.7k
- Avg merge
- 5h 14m
- Merged PRs (30d)
- 486
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from anomalyco/opencode
-
area/providers type/feature version/v2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/opencode#64845 · 1 comment ·
Maintainers usually reply within 1 day
-
area/desktop platform/windows type/feature version/v2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
anomalyco/opencode#64566 · 1 comment ·
Maintainers usually reply within 1 day
-
Opening mini-tabsOpenarea/desktop platform/windows status/repro-plausible type/bug version/v2
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
anomalyco/opencode#64522 · 1 comment ·
Maintainers usually reply within 1 day
-
cli: plugin list shows - for ID of TUI-only plugins configured in cli.jsonPossibly taken @yash-alla claimed this 2 days ago. Openarea/cli platform/windows type/feature version/v2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anomalyco/opencode#64175 · 1 comment ·
Maintainers usually reply within 1 day
-
area/desktop platform/windows type/feature version/v2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anomalyco/opencode#64077 · 3 comments ·
Maintainers usually reply within 1 day
All issues in anomalyco/opencode
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
🛠️ dette technique
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
betagouv/mon-entreprise#4752 · 1 comment ·
Maintainers usually reply within 5 days
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
franciscoBSalgueiro/en-croissant#1111 ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
inmanta/web-console#7947 ·
Maintainers usually reply within 1 day