Skip to content

[Bug] Empty tool_calls arrays split continuous reasoning into separate parts #47875

Closed

Description

@yixiao5428

Description

OpenCode's pinned @ai-sdk/[email protected] 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; [email protected], @ai-sdk/[email protected], Bun 1.3.14.

Steps to reproduce

  1. 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]
  1. 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.

Activity

  1. neriousy commented on Oct 19, 2026

    @neriousy
    Member

    This is fixed in v2: OpenAI-compatible streaming uses the native parser, which keeps reasoning in one response-wide channel and does not split it on empty tool_calls arrays. Upgrade with npm i -g @opencode/cli@latest. If you still see this on v2, please open a new issue with the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions