kmail.at
← learning

langchain · difficulty ◆◆

normalize_v1_streamed_tool_calls: Clean Streamed Tool Calls

Stream tool calls without duplicate invocations or None fields.

Streaming agents were silently dropping or duplicating tool calls. One core upgrade normalizes every chunk.

2026-06-12 · 6 min read

$ pip install -U langchain-core>=1.4.6 langchain-openai>=1.2.1

What it does

normalize_v1_streamed_tool_calls is an internal langchain-core function that normalizes tool calls streamed from the OpenAI v1 API into LangChain’s canonical ToolCall format. A bug in the prior version caused malformed or duplicated tool call chunks when the model streamed incremental deltas, especially with function_call style mixed with the newer tool_calls format. The fix ensures chunks merge correctly regardless of streaming order or format variant.

Why it matters

If you build any LLM pipeline that uses OpenAI tool calling with streaming enabled (an agent loop, a code interpreter, a RAG-with-tools chain), this bug could cause silent failures: duplicate tool invocations, dropped arguments, or ToolCall objects with None fields. The fix is in langchain-core, so upgrading to >=1.4.6 resolves it automatically for all partner packages (OpenAI, Anthropic, etc.).

Example

$ Stream a tool call and collect results
Tool calls collected: 1
Result: content='Sunny in Berlin'

astream_events surfaces the on_tool_end event with a clean, non-duplicated result.

Common flags

--streaming
Enable streaming tool-call output
--v1-api
OpenAI v1 API format normalization

History

Origin

Fixes landed in langchain-core==1.4.6 (published June 11, 2026), PR #35983.

Scope

Because normalization lives in core, the fix propagates to every partner integration that relies on canonical ToolCall output.

Fun facts

Pros & cons

pros

  • + Fixes duplicate invocations
  • + No dropped arguments
  • + Propagates to all partner packages

cons

  • − Requires core upgrade
  • − Internal function, not a public API

Takeaways

  1. 1Upgrade langchain-core to >=1.4.6 for the fix.
  2. 2Stream tool calls with astream_events to observe clean on_tool_end output.
  3. 3Compare against core 1.4.4 to see the old malformed behavior.

Related commands

← all learning