anomalyco / anomalyco/opencode
[Bug] Empty tool_calls arrays split continuous reasoning into separate parts
@nexxeln is already working on this.
Since Sep 8, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
OpenCode's pinned @ai-sdk/openai-compatible@2.0.41 closes active reasoning whenever a streamed delta contains tool_calls, even when the array is empty. Consecutive reasoning deltas with tool_calls: [] therefore produce separate persisted reasoning parts instead of one continuous part.
This is the SDK bug tracked in vercel/ai#20203, fixed by vercel/ai#20253 and published in compatible 3.0.44. OpenCode's pinned version still needs the fix. A narrow backport would avoid a major SDK migration.
Related: #40865 describes fragmented Thought blocks, but also content-field behavior outside this report's scope. This report only concerns consecutive reasoning_content deltas with empty tool-call arrays, not merging across real text or tool boundaries.
Plugins
None required; reproduced with local SSE fixtures through the SDK and real session processor.
OpenCode version
dev at ecbc6ccac85b3e8087b6445e584318419b9e2b34; ai@6.0.168, @ai-sdk/openai-compatible@2.0.41, Bun 1.3.14.
Steps to reproduce
- Configure an OpenAI-compatible test endpoint to return this chat-completion SSE response:
data: {"id":"repro","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"reasoning_content":"r1","tool_calls":[]},"finish_reason":null}]}
data: {"id":"repro","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"reasoning_content":"r2","tool_calls":[]},"finish_reason":null}]}
data: {"id":"repro","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"done"},"finish_reason":null}]}
data: {"id":"repro","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
- Send a prompt and inspect the assistant's persisted reasoning parts.
Expected: one completed reasoning part, r1r2, followed by text done.
Actual: two completed reasoning parts, r1 and r2; text done remains intact. Omitting tool_calls produces the expected single part.
Screenshot and/or share link
Not applicable; reproduced with headless SDK/session tests, not a live provider account.
Operating System
Linux.
Terminal
Not applicable to the headless reproduction.
Contributor 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.
Assessment
This issue has not been assessed yet.