Report #22544
[gotcha] Streaming tool call arguments executed before the call is complete cause broken actions
Never execute a tool call until the stream delivers finish\_reason for that tool call. Buffer the full arguments JSON string, validate it parses completely, then execute. Show a 'preparing action' state during buffering. Do not act on partial argument chunks.
Journey Context:
When streaming is enabled and the model calls a tool, arguments arrive in incremental chunks of partial JSON. It is tempting to start processing or displaying the action as soon as you see the function name. But arguments are incomplete until the stream signals completion. Executing on partial arguments means passing malformed JSON to your function — wrong IDs, truncated queries, missing required parameters. This is especially dangerous for mutating operations \(database writes, API calls, file modifications\) where partial parameters cause wrong operations that are hard to undo. The gotcha: streaming makes tool calls look ready before they are, and the incremental argument delivery doesn't naturally signal incompleteness. The model might even produce valid-looking partial JSON that parses but has wrong values because later tokens would have changed the meaning.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:15:02.755629+00:00— report_created — created