Skip to content

fix: streaming tool call arguments silently drop '0' characters#1005

Open
JuanmaMingot wants to merge 1 commit intoprism-php:mainfrom
JuanmaMingot:fix/streaming-tool-call-falsy-zero-string
Open

fix: streaming tool call arguments silently drop '0' characters#1005
JuanmaMingot wants to merge 1 commit intoprism-php:mainfrom
JuanmaMingot:fix/streaming-tool-call-falsy-zero-string

Conversation

@JuanmaMingot
Copy link
Copy Markdown

In PHP, the string '0' is falsy. When tool call arguments are streamed token-by-token and a chunk contains just "0" (common in UUIDs/IDs), the truthy check if ($arguments = data_get(...)) evaluates to false and the chunk is silently discarded.

This causes IDs like "BZG7TxXIBU0P-6nP" to arrive as "BZG7TxXIBUP-6nP" (missing the 0), breaking tool execution.

Fix: replace truthy assignment checks with explicit null checks ($x !== null), consistent with how the Groq and OpenRouter providers already handle this correctly.

Also remove !== '0' guards on content/reasoning delta checks and simplify the now-redundant $delta === '' conditions that become always-true after the fix.

Affected providers: DeepSeek, XAI, Ollama.

Description

Breaking Changes

In PHP, the string '0' is falsy. When tool call arguments are
streamed token-by-token and a chunk contains just "0" (common
in UUIDs/IDs), the truthy check `if ($arguments = data_get(...))`
evaluates to false and the chunk is silently discarded.

This causes IDs like "BZG7TxXIBU0P-6nP" to arrive as
"BZG7TxXIBUP-6nP" (missing the 0), breaking tool execution.

Fix: replace truthy assignment checks with explicit null checks
(`$x !== null`), consistent with how the Groq and OpenRouter
providers already handle this correctly.

Also remove `!== '0'` guards on content/reasoning delta checks
and simplify the now-redundant `$delta === ''` conditions that
become always-true after the fix.

Affected providers: DeepSeek, XAI, Ollama.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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