Report #24339
[gotcha] Streaming tool call arguments parsed as complete JSON objects fail
Concatenate all delta.tool\_calls\[\].function.arguments fragments across chunks before parsing. Never call JSON.parse on a single chunk's arguments field — it is a substring, not a complete object.
Journey Context:
When streaming chat completions with tool calls, each SSE chunk contains a delta with a fragment of the function.arguments string. A common mistake is treating each chunk's arguments as a standalone JSON object. It is not — it is a substring that must be accumulated across all chunks. Parsing any single chunk independently throws a JSON syntax error. This is fundamentally different from streaming text content where each delta.content can be rendered immediately. The gotcha is that the first chunk often contains '\{' or a partial key, which looks parseable but is not. Developers discover this only at runtime when tool calls are actually invoked, not during basic streaming tests with simple text responses.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:15:32.850464+00:00— report_created — created