kmail.at
contact

elsewhere

EnglishEN
← learning

langchain · difficulty ◆◆◆

normalize_v1_streamed_tool_calls: The Reliable Stream Fix

Downstream consumers get well-formed ToolCall objects, every time.

A streamed tool call should be one well-formed ToolCall, not a pile of fragments. This fix guarantees it.

fully AI-generatedThis text is fully AI-generated and was published without human editorial review.

2026-06-18 · 7 min read

$ pip install -U langchain-openai langchain-core
openai 1.3.1 / core 1.4.7
Release
#35983
PR
Consistent ToolCall list
Guarantee

What it does

When you use LangChain’s OpenAI integration with tool calling in streaming mode, the model can emit tool call chunks in a non-deterministic order or with inconsistent formatting. The normalize_v1_streamed_tool_calls fix standardizes how these streamed events are normalized, ensuring tool arguments are correctly reconstructed even when the model emits partial or reordered chunks. Concretely, it patches the streaming path so AIMessageChunk.tool_calls is always a consistent list of ToolCall objects with the correct name, args, and id fields.

Why it matters

Streaming tool calls are critical in real-time agentic pipelines, such as a customer-service bot that streams a tool use while the user is still watching. If streamed tool calls are malformed or duplicated, downstream components that consume tool_calls directly (like a ReAct agent or a tool-executing loop) can crash or silently skip tool execution. This fix eliminates the most common source of streaming tool-call bugs in LangChain’s OpenAI integration.

Example

$ Accumulate streamed tool calls
Received tool_call chunk: ToolCall(name='get_weather', args='{"city": "Tokyo"}', id='...')

Total tool calls received: 1

Multiple partial chunks accumulate into one non-duplicated top-level ToolCall after the fix.

Common flags

AIMessageChunk.tool_calls
Normalized list of ToolCall objects on streaming chunks
PydanticStructurableMixin
Enables Pydantic models as tool schemas, benefiting from normalization

History

Origin

Released in langchain-openai 1.3.1 and langchain-core 1.4.7 (2026-06-13), PR #35983, covered in the June 18 tutorial.

Same-day context

langchain==1.3.9 bundled anthropic 1.4.6 and an allowed_prefixes fix for file search; core 1.4.7 carried the Pydantic v1 tools fix.

Under the hood

Downstream safety

Because tool_calls on chunks is now normalized, consumers like ReAct agents and tool-executing loops read a consistent structure. The fix removes both the crash and the silent-skip failure modes in one stroke.

Fun facts

Pros & cons

pros

  • + No duplicate top-level tool calls
  • + Well-formed name/args/id
  • + Protects real-time agents

cons

  • − Requires both packages updated
  • − Streaming accumulation logic still needed

Takeaways

  1. 1Upgrade langchain-openai and langchain-core together.
  2. 2Inspect AIMessageChunk.tool_calls while streaming to see normalized ToolCall objects.
  3. 3Your tool-executing loops stay reliable in real-time streaming agents.

Related commands

archive entry — written and published by a scheduled job, never editorially reviewed. Kept for reference: out of the site’s search index, and no ads run here. the reviewed library →

← all learning