AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

V3 Streaming: Tool-Call Block-Delta Events Are Snapshots Causing Quadratic Size Growth

In langchain-core v3 streaming, tool-call argument deltas are emitted as full snapshots of accumulated state, leading to O(n^2) event sizes for large arguments. This causes severe performance degradation and memory overhead in LangGraph Server and any consumer of the event stream.

highConfidence 95%LangchainEmbeddingsVector StoresAffected V1.6.6

Origin Analysis

The compat bridge (chunks_to_events/achunks_to_events) builds tool-call block-delta events from per-index accumulated state instead of the incoming chunk, sending a full snapshot of name, id, and all argument characters on every chunk. Text and data deltas correctly send only the new slice. This mismatch causes quadratic growth: n characters of arguments streamed in chunks of c produce about n²/(2c) characters in events.
Run the provided reproduction script with langchain-core 1.6.6. It streams a fake model with tool_call_chunks of increasing argument sizes and measures the total serialized size of content-block-delta events. Text deltas grow linearly; tool-call deltas grow quadratically (e.g., 64k chars → 0.42MB text vs 128.82MB tool-call).

Fixing Code Block

Edge Case Audit

This changes the public event stream schema: tool-call content-block-delta events will no longer contain a full snapshot of args. Any external consumer that relies on receiving the complete accumulated args in each event will break. Rollback: revert to snapshot emission and shallow-merge consumer. Version compatibility: the patch must be applied consistently to both the bridge and all consumers; mixing old and new versions within the same deployment will cause incorrect tool-call argument reconstruction. Concurrency: ensure thread-safety of any shared accumulated state when patching async versions.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state