kmail.at
← learning

langchain · difficulty ◆◆◆

Streaming Tool Calls in Agents: The 1.3.1 Normalization

ReAct agents that stream tool calls in real time, without parsing fragility.

A ReAct agent streams its thoughts and tool calls live. This fix keeps those chunks from falling apart mid-stream.

2026-06-17 · 7 min read

$ pip install --upgrade langchain-openai

What it does

When using OpenAI’s v1 API with streaming responses, tool calls arrive as partial JSON chunks that must be assembled and decoded before the full tool call can be executed. This fix normalizes how those streamed tool-call chunks are reconstructed, ensuring consistent parsing regardless of model or chunk-splitting behavior. If you were streaming a chat completion with tools or function_call and noticed malformed or duplicated tool calls, this standardizes the chunk-assembly logic in the langchain-openai stream parser.

Why it matters

Streaming tool calls are common in agentic pipelines, such as a ReAct agent that streams back-and-forth with the model in real time. A brittle parser produces duplicate tool invocations, null or partially decoded function names, and JSON decode errors mid-stream. This fix lands in langchain-openai’s core streaming path, used by anyone running OpenAI-powered agents with function/tool calling in streaming mode.

Example

$ Stream an agent’s tool call chunks
Tool call chunk: [{'name': 'get_weather', 'args': '{"city": "Tokyo"}', 'index': 0, 'id': 'call_abc123'}]

Each chunk is a clean, complete ToolCallChunk with no duplicates or partial strings.

Common flags

AgentExecutor.stream()
Stream agent events including tool call chunks
api_version="v1"
OpenAI v1 API streaming normalization

History

Origin

Released in langchain-openai==1.3.1 (June 13, 2026), PR #35983, covered in the June 17 tutorial.

Same-release fixes

1.3.1 also tightened structured output model fallbacks, renamed package version trace metadata, and added a validate-tool-call-chunks test guard.

Fun facts

Pros & cons

pros

  • + No duplicate tool invocations
  • + Complete parsed chunks
  • + Works across agent loops

cons

  • − Agent-level streaming is verbose
  • − Requires openai 1.3.1

Takeaways

  1. 1Upgrade langchain-openai to 1.3.1 for the v1 stream parser fix.
  2. 2Stream agents with AgentExecutor.stream() and watch clean tool_call_chunks.
  3. 3Compare against 1.3.0 to confirm the normalization is working.

Related commands

← all learning