Skip to content

fix(codebuddy-cn): strip empty tool_calls arrays to preserve reasoning#2230

Open
zmf963 wants to merge 1 commit into
decolua:masterfrom
HotSec:fix/codebuddy-cn-empty-tool-calls
Open

fix(codebuddy-cn): strip empty tool_calls arrays to preserve reasoning#2230
zmf963 wants to merge 1 commit into
decolua:masterfrom
HotSec:fix/codebuddy-cn-empty-tool-calls

Conversation

@zmf963

@zmf963 zmf963 commented Jun 30, 2026

Copy link
Copy Markdown

CodeBuddy CN API includes "tool_calls": [] (empty array) in every SSE streaming delta. @ai-sdk/openai-compatible checks delta.tool_calls != null — an empty array passes this check ([] != null is true in JS), triggering premature reasoning-end on every chunk that contains reasoning_content.

This causes tools like OpenCode to show zero or 1ms reasoning durations instead of the actual thinking time.

Fix: in passthrough mode, delete empty tool_calls arrays from delta before hasValuableContent filtering. This is a zero-side-effect change — real tool_calls always have at least one element.

CodeBuddy CN API includes `"tool_calls": []` (empty array) in every SSE
streaming delta. @ai-sdk/openai-compatible checks `delta.tool_calls != null`
— an empty array passes this check ([] != null is true in JS), triggering
premature `reasoning-end` on every chunk that contains reasoning_content.

This causes tools like OpenCode to show zero or 1ms reasoning durations
instead of the actual thinking time.

Fix: in passthrough mode, delete empty tool_calls arrays from delta before
hasValuableContent filtering. This is a zero-side-effect change — real
tool_calls always have at least one element.

Closes decolua#2176
@zmf963 zmf963 force-pushed the fix/codebuddy-cn-empty-tool-calls branch from d56f953 to 406d590 Compare June 30, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant