High severity intermediate · Fix: 5-10 min

LangGraphAstreamDeltaParseError

langgraph.exceptions.LangGraphAstreamDeltaParseError

What this error means
LangGraph's streaming delta update parser failed to parse the incremental update due to unexpected format or corrupted stream data.

Stack trace

traceback
langgraph.exceptions.LangGraphAstreamDeltaParseError: Failed to parse astream delta update: unexpected token at position 45
  File "/usr/local/lib/python3.10/site-packages/langgraph/astream/parser.py", line 112, in parse_delta_update
    raise LangGraphAstreamDeltaParseError(f"Failed to parse astream delta update: {err}")
  File "/usr/local/lib/python3.10/site-packages/langgraph/astream/parser.py", line 98, in parse_delta_update
    delta = json.loads(delta_str)  # <-- error triggered here
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 46 (char 45)
QUICK FIX
Add buffering to accumulate full JSON delta updates before parsing to avoid partial JSON parse errors.

Why it happens

LangGraph expects streaming delta updates in a strict JSON format for incremental graph updates. If the stream contains malformed JSON, partial fragments, or unexpected tokens, the parser raises this error. This often happens when network interruptions corrupt the stream or the upstream source sends invalid data.

Detection

Monitor logs for LangGraphAstreamDeltaParseError exceptions and capture the raw delta update strings to identify malformed or incomplete JSON fragments before they cause downstream failures.

Causes & fixes

1

The streaming delta update contains malformed JSON due to truncated or corrupted data.

✓ Fix

Implement retry logic on the stream source to ensure complete JSON fragments are received before parsing.

2

Upstream source sends delta updates with unexpected fields or format changes not compatible with the parser.

✓ Fix

Update the LangGraph parser schema to match the new delta update format or coordinate with the upstream source to maintain format consistency.

3

Network interruptions cause partial delta update messages to be delivered to the parser.

✓ Fix

Buffer incoming stream data and only parse complete JSON objects, using delimiters or length prefixes to detect message boundaries.

Code: broken vs fixed

Broken - triggers the error
python
from langgraph.astream import AstreamParser

parser = AstreamParser()
delta_str = '{"node": 1, "edges": [2, 3'  # incomplete JSON
parsed = parser.parse_delta_update(delta_str)  # triggers LangGraphAstreamDeltaParseError here
Fixed - works correctly
python
import os
from langgraph.astream import AstreamParser

parser = AstreamParser()
# Buffering example: accumulate until full JSON received
buffer = ''
raw_stream_data = '{"node": 1, "edges": [2, 3]}'  # complete JSON
buffer += raw_stream_data
parsed = parser.parse_delta_update(buffer)  # fixed: full JSON parsed successfully
print(parsed)
# Changed to ensure full JSON string before parsing
Added buffering to ensure the parser receives complete JSON strings, preventing parse errors from partial or malformed input.

Workaround

Wrap the parse_delta_update call in try/except LangGraphAstreamDeltaParseError, then attempt to extract valid JSON fragments using regex or manual string fixes before retrying parse.

Prevention

Design the streaming protocol to send complete, self-delimited JSON messages or use length-prefixed framing to guarantee parsable delta updates, avoiding partial or corrupted data.

Python 3.9+ · langgraph >=0.1.0 · tested on 0.4.2
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.