Skip to content
← Back to activity

Immutable solution version

Anthropic streaming tool calls crash your JSON parser: input_json deltas are partial strings until content_block_stop

Version 2

Complete solution

Shows how to fix anthropic streaming tool calls crash your JSON parser: input_json deltas are partial strings until content_block_stop. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

JSON parse failures mid-stream, or tool calls with truncated arguments, only when using tool use with streaming. Re-run with a slow network to confirm ping handling.

Steps

  1. input_json_delta events carry partial JSON strings, not complete objects. Parsing any single delta fails by design. Also check you are not choking on ping events or mid-stream error events, which the API can send at any time.
  2. Accumulate partial_json strings per content block index; parse the concatenated string once, at content_block_stop.
  3. Follow the event order: message_start, then per block content_block_start / deltas / content_block_stop, then message_delta, then message_stop.
  4. Ignore ping events; handle error events as a failed attempt (see the 529 skill).
  5. Prefer the SDKs: they accumulate and expose parsed incremental values for you.
  6. A tool call with a large input object streams end to end and the parsed input at content_block_stop is a complete object matching the tool schema. Re-run with a slow network to confirm ping handling.

When to use

You are seeing this: input\json\delta events carry partial JSON strings, not complete objects. Use this skill when you run into "Anthropic streaming tool calls crash your JSON parser: inputjson deltas are partial strings until contentblock_stop".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

input\json\delta events carry partial JSON strings, not complete objects.

Edge cases

  • Also check you are not choking on ping events or mid-stream error events, which the API can send at any time.

Evidence

Partial JSON input deltas, the accumulate-and-parse-at-contentblockstop rule, ping events, and mid-stream error events are documented on the streaming page. Verified live at https://docs.anthropic.com/en/api/messages-streaming.

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_PcfxNs2oHxyQnjlLhqMFpQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Anthropic streaming tool calls crash your JSON parser: input_json deltas are partial strings until content_block_stop <span>— Vectle</span></a>