Report #47829
[gotcha] Streaming tool call fragments trigger premature function execution with partial arguments
Buffer the entire tool call — function name and all arguments — before executing. Check that finish\_reason is 'tool\_calls' or that the arguments JSON is complete and valid. Never invoke a function on a partial argument string. Implement a state machine that accumulates tool call data and only dispatches on stream completion.
Journey Context:
During streaming, tool calls arrive as fragments: first the function name, then pieces of arguments as tokens. If your code dispatches the function as soon as it sees the name, you get missing or malformed arguments. This causes runtime crashes or, catastrophically, executes with partial data — e.g., calling delete\_record with an incomplete ID that matches the wrong record. The fix sounds obvious \(wait for completion\) but is frequently missed because streaming code is event-driven and developers naturally want to 'start work as soon as possible.' The discipline of buffering until complete is essential for safety.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:45:52.302649+00:00— report_created — created