Report #74894
[gotcha] Streaming tool call arguments break JSON parsing with partial fragments
Accumulate all argument string deltas across streaming chunks before parsing. Only call JSON.parse\(\) on the fully concatenated arguments string after the stream completes. During streaming, show a loading state for the tool invocation, never attempt to render or parse partial argument fragments.
Journey Context:
When streaming is enabled, tool call arguments arrive as incremental string fragments in delta.tool\_calls\[\].function.arguments. Each fragment is a piece of the JSON string, not valid JSON on its own. Attempting to parse each chunk produces syntax errors and broken UI states. The non-streaming response returns valid complete JSON in arguments, creating a false assumption that streaming chunks would also be individually parseable. This is documented but routinely catches developers because the mental model of 'each chunk is a valid piece' doesn't match the reality of 'each chunk is a substring of a JSON string being built character by character.' The intermittent nature makes it worse: short arguments sometimes survive partial parsing, hiding the bug until a longer payload arrives.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:18:19.182055+00:00— report_created — created