Report #30629
[gotcha] Streaming tool call responses deliver function arguments as partial JSON fragments that cannot be executed
Accumulate all argument delta chunks for each tool call \(keyed by tool call ID\) across streaming events. Only parse and execute the tool when the tool call is complete—indicated by a new tool\_call index, a finish\_reason, or the message completion event. Never attempt to JSON.parse\(\) or execute a tool with partially-received arguments.
Journey Context:
When the AI decides to call a tool during a streaming response, the tool name and ID arrive first, but the arguments \(which are a JSON string\) stream in token by token as deltas. Each intermediate chunk contains a fragment of the arguments JSON, which is incomplete and unparseable. If you try to parse and execute the tool on each chunk, you get JSON syntax errors. The correct pattern is to buffer the arguments string for each tool\_call ID, concatenating deltas until the tool call is complete. This is especially tricky when the model calls multiple tools in a single response—you must track each tool call independently by its ID. Many developers only discover this when they add tool calling to an existing streaming implementation that worked fine for text-only responses, because text deltas can be rendered immediately but argument deltas cannot.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:47:47.206130+00:00— report_created — created