ai: Thinking Shows Twice When a reasoning.text Detail Repeats Streamed reasoning_content
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从 packages/ai/src/protocols/openai-chat.ts 开始,重点查看 detailText 和 reasoningTextObserved,然后检查 packages/ai/test/provider/openai-chat.test.ts 中的 OpenAI chat provider 测试。重现 reasoning_content 后跟随匹配的 reasoning.text 详情的流。完成标准是 Thought 块中只包含一次该文本,并且回归测试通过。
由索引模型根据 Issue 内容生成。
描述
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)
- 主要语言
- TypeScript
- 星标
- 227k
- 派生
- 30.7k
- 平均合并
- 5 小时 14 分钟
- 30 天内合并 PR
- 486
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
area/providers type/feature version/v2
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#64845 · 1 条评论 ·
维护者通常 1 天内回复
-
area/desktop platform/windows type/feature version/v2
难度 2/5 1-3 小时 新手友好度 78/100
anomalyco/opencode#64566 · 1 条评论 ·
维护者通常 1 天内回复
-
area/desktop platform/windows status/repro-plausible type/bug version/v2
难度 2/5 1-3 小时 新手友好度 64/100
anomalyco/opencode#64522 · 1 条评论 ·
维护者通常 1 天内回复
-
cli: plugin list shows - for ID of TUI-only plugins configured in cli.json可能已有人在做 @yash-alla 于 2 天前认领。 未关闭area/cli platform/windows type/feature version/v2
难度 2/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#64175 · 1 条评论 ·
维护者通常 1 天内回复
-
area/desktop platform/windows type/feature version/v2
难度 2/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#64077 · 3 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 87/100
维护者通常 1 天内回复
-
🛠️ dette technique
难度 2/5 1-3 小时 新手友好度 61/100
betagouv/mon-entreprise#4752 · 1 条评论 ·
维护者通常 5 天内回复
-
type: bug
难度 2/5 1-3 小时 新手友好度 67/100
franciscoBSalgueiro/en-croissant#1111 ·
维护者通常 2 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 83/100
inmanta/web-console#7947 ·
维护者通常 1 天内回复