langchain - ✅(Solved) Fix langchain-core 1.2.14 stream_mode == "messages" tool args parse failed [2 pull requests, 3 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#35395Fetched 2026-04-08 00:26:22
View on GitHub
Comments
3
Participants
4
Timeline
13
Reactions
0
Author
Timeline (top)
commented ×3labeled ×3mentioned ×2subscribed ×2

when I use langchain-core == 1.2.13 it's ok, return: [{'name': 'get_weather', 'args': '', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': '', 'args': '{"city": "', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_8786ef62dbe741afae2953', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}] Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| The city experiences all| four seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the real-time weather for| you. Would you like that|?|

but when I use langchain-core == 1.2.14 return:

[{'name': 'get_weather', 'args': '', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': '', 'args': '{"city": "', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_69347ed8e4234f42a9eba6', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}] Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| It experiences all four| seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the latest weather for| Boston right now. Would| you like that?

by the way, I use model is qwen series ( qwen-plus qwen3-max .etc )

Error Message

Error Message and Stack Trace (if applicable)

Root Cause

when I use langchain-core == 1.2.13 it's ok, return: [{'name': 'get_weather', 'args': '', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': '', 'args': '{"city": "', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_8786ef62dbe741afae2953', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}] Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| The city experiences all| four seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the real-time weather for| you. Would you like that|?|

but when I use langchain-core == 1.2.14 return:

[{'name': 'get_weather', 'args': '', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': '', 'args': '{"city": "', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_69347ed8e4234f42a9eba6', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}] Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| It experiences all four| seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the latest weather for| Boston right now. Would| you like that?

by the way, I use model is qwen series ( qwen-plus qwen3-max .etc )

Fix Action

Fix / Workaround

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Other Dependencies

httpx: 0.28.1 jsonpatch: 1.33 langgraph: 1.0.9 openai: 2.21.0 orjson: 3.11.7 packaging: 26.0 pydantic: 2.12.5 pyyaml: 6.0.3 requests: 2.32.5 requests-toolbelt: 1.0.0 tenacity: 9.1.4 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.14.1 xxhash: 3.6.0 zstandard: 0.25.0

PR fix notes

PR #35414: fix(core): treat empty tool chunk ids as missing in merge

Description (problem / solution / changelog)

Fixes #35395

Tool call chunk aggregation treated id="" as a conflicting identifier, which prevented chunks with the same index from merging and could break streamed tool-argument reconstruction. This change treats empty ids as missing ids during list merge so chunks continue to merge correctly.

How did you verify your code works?

  • uv run --project libs/core --group test pytest libs/core/tests/unit_tests/test_messages.py::test_message_chunks
  • uv run --project libs/core --group test pytest libs/core/tests/unit_tests/test_messages.py

Breaking changes

  • None

Depends on

  • None

Changed files

  • libs/core/langchain_core/utils/_merge.py (modified, +3/-3)
  • libs/core/tests/unit_tests/test_messages.py (modified, +28/-0)

PR #138: fix: initial fix of isolated tools

Description (problem / solution / changelog)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit

  • New Features

    • Native function-calling workflow for bound tools; tool-call responses are preserved.
    • Task/todo tracking surfaced as a "Current plan" in the system prompt and propagated through execution.
    • Sandboxed Python execution tool and stricter per-turn isolation rules for autonomous subtasks and knowledge tooling.
  • Bug Fixes

    • Retry-aware handling for certain tool failures and improved recovery from malformed tool payloads.
    • Better preservation of tool-call metadata to improve fallbacks.
  • Tests

    • Added/updated tests for error recovery, retry classification, and knowledge-tool prompt behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Changed files

  • src/cuga/backend/cuga_graph/nodes/cuga_lite/cuga_lite_graph.py (modified, +263/-35)
  • src/cuga/backend/cuga_graph/nodes/cuga_lite/prompt_utils.py (modified, +21/-0)
  • src/cuga/backend/cuga_graph/nodes/cuga_lite/prompts/mcp_prompt.jinja2 (modified, +121/-151)
  • src/cuga/backend/cuga_graph/nodes/cuga_lite/prompts/mcp_prompt_todos.jinja2 (modified, +176/-349)
  • src/cuga/backend/cuga_graph/nodes/cuga_supervisor/cuga_supervisor_graph.py (modified, +107/-31)
  • src/cuga/backend/cuga_graph/nodes/cuga_supervisor/cuga_supervisor_state.py (modified, +5/-0)
  • src/cuga/backend/cuga_graph/nodes/cuga_supervisor/prompts/supervisor_lite_prompt.jinja2 (modified, +174/-116)
  • src/cuga/backend/llm/errors.py (modified, +147/-4)
  • tests/integration/test_knowledge_integration.py (modified, +13/-9)
  • tests/unit/test_tool_use_failed_recovery.py (modified, +60/-0)

Code Example

from typing import Any
import asyncio
import os
from langchain.agents import create_agent
from langchain.messages import AIMessage, AIMessageChunk, AnyMessage, ToolMessage
from langchain_openai import ChatOpenAI

from dotenv import find_dotenv, load_dotenv

from langchain.tools import tool


load_dotenv(find_dotenv())

@tool( description="useful for when you want to get the weather in a given city")
def get_weather(city: str) -> str:
    """Get weather for a given city."""
    return f"It's always sunny in {city}!"


def _render_message_chunk(token: AIMessageChunk) -> None:
    if token.text:
        print(token.text, end="|")

    if token.tool_call_chunks:
        print(token.tool_call_chunks)


def _render_completed_message(message: AnyMessage) -> None:
    if isinstance(message, AIMessage) and message.tool_calls:
        print(f"\nTool calls: {message.tool_calls}")

    if isinstance(message, ToolMessage):
        print(f"\nTool response: {message.content_blocks}")

llm = ChatOpenAI(
    model=os.getenv("DEFAULT_MODEL", ""),
    api_key=os.getenv("OPENAI_API_KEY", ""),
    base_url=os.getenv("OPENAI_API_BASE", ""),
)


async def main():
    agent = create_agent(
        llm,  
        system_prompt="You are a helpful assistant that can get the weather in a given city.",
        tools=[get_weather]
    )

    input_message = {
        "role": "user",
        "content": "What is the weather in Boston?",
    }

    async for stream_mode, data in agent.astream(
        {"messages": [input_message]},
        stream_mode=["messages", "updates"],
    ):
        if stream_mode == "messages":
            token, metadata = data
            if isinstance(token, AIMessageChunk):
                _render_message_chunk(token)

        if stream_mode == "updates":
            for source, update in data.items():
                if source in ("model", "tools"):
                    _render_completed_message(update["messages"][-1])


if __name__ == "__main__":
    asyncio.run(main())

---

when I use langchain-core == 1.2.13 it's ok, return:
[{'name': 'get_weather', 'args': '', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}]
[{'name': '', 'args': '{"city": "', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}]
[{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_8786ef62dbe741afae2953', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}]
Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| The city experiences all| four seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the real-time weather for| you. Would you like that|?|

but when I use langchain-core == 1.2.14 return:

[{'name': 'get_weather', 'args': '', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}]
[{'name': '', 'args': '{"city": "', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}]
[{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_69347ed8e4234f42a9eba6', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}]
Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| It experiences all four| seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the latest weather for| Boston right now. Would| you like that?
RAW_BUFFERClick to expand / collapse

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

No response

Reproduction Steps / Example Code (Python)

from typing import Any
import asyncio
import os
from langchain.agents import create_agent
from langchain.messages import AIMessage, AIMessageChunk, AnyMessage, ToolMessage
from langchain_openai import ChatOpenAI

from dotenv import find_dotenv, load_dotenv

from langchain.tools import tool


load_dotenv(find_dotenv())

@tool( description="useful for when you want to get the weather in a given city")
def get_weather(city: str) -> str:
    """Get weather for a given city."""
    return f"It's always sunny in {city}!"


def _render_message_chunk(token: AIMessageChunk) -> None:
    if token.text:
        print(token.text, end="|")

    if token.tool_call_chunks:
        print(token.tool_call_chunks)


def _render_completed_message(message: AnyMessage) -> None:
    if isinstance(message, AIMessage) and message.tool_calls:
        print(f"\nTool calls: {message.tool_calls}")

    if isinstance(message, ToolMessage):
        print(f"\nTool response: {message.content_blocks}")

llm = ChatOpenAI(
    model=os.getenv("DEFAULT_MODEL", ""),
    api_key=os.getenv("OPENAI_API_KEY", ""),
    base_url=os.getenv("OPENAI_API_BASE", ""),
)


async def main():
    agent = create_agent(
        llm,  
        system_prompt="You are a helpful assistant that can get the weather in a given city.",
        tools=[get_weather]
    )

    input_message = {
        "role": "user",
        "content": "What is the weather in Boston?",
    }

    async for stream_mode, data in agent.astream(
        {"messages": [input_message]},
        stream_mode=["messages", "updates"],
    ):
        if stream_mode == "messages":
            token, metadata = data
            if isinstance(token, AIMessageChunk):
                _render_message_chunk(token)

        if stream_mode == "updates":
            for source, update in data.items():
                if source in ("model", "tools"):
                    _render_completed_message(update["messages"][-1])


if __name__ == "__main__":
    asyncio.run(main())

Error Message and Stack Trace (if applicable)

when I use langchain-core == 1.2.13 it's ok, return:
[{'name': 'get_weather', 'args': '', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}]
[{'name': '', 'args': '{"city": "', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}]
[{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_8786ef62dbe741afae2953', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}]
Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| The city experiences all| four seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the real-time weather for| you. Would you like that|?|

but when I use langchain-core == 1.2.14 return:

[{'name': 'get_weather', 'args': '', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}]
[{'name': '', 'args': '{"city": "', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}]
[{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_69347ed8e4234f42a9eba6', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}]
Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| It experiences all four| seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the latest weather for| Boston right now. Would| you like that?

Description

when I use langchain-core == 1.2.13 it's ok, return: [{'name': 'get_weather', 'args': '', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': '', 'args': '{"city": "', 'id': 'call_8786ef62dbe741afae2953', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_8786ef62dbe741afae2953', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}] Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| The city experiences all| four seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the real-time weather for| you. Would you like that|?|

but when I use langchain-core == 1.2.14 return:

[{'name': 'get_weather', 'args': '', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': '', 'args': '{"city": "', 'id': 'call_69347ed8e4234f42a9eba6', 'index': 0, 'type': 'tool_call_chunk'}] [{'name': None, 'args': 'Boston"}', 'id': '', 'index': 0, 'type': 'tool_call_chunk'}]

Tool calls: [{'name': 'get_weather', 'args': {'city': 'Boston'}, 'id': 'call_69347ed8e4234f42a9eba6', 'type': 'tool_call'}]

Tool response: [{'type': 'text', 'text': "It's always sunny in Boston!"}] Actually|, Boston|'s| weather varies| throughout the year—it|'s not always sunny!| It experiences all four| seasons, with cold|, snowy winters and| warm, humid summers|. If you'd like| current conditions (temperature|, cloud cover, precipitation|, etc.), I can| fetch the latest weather for| Boston right now. Would| you like that?

by the way, I use model is qwen series ( qwen-plus qwen3-max .etc )

System Info

python -m langchain_core.sys_info

System Information

OS: Darwin OS Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000 Python Version: 3.11.13 (main, Sep 18 2025, 19:53:58) [Clang 20.1.4 ]

Package Information

langchain_core: 1.2.13 langchain: 1.2.10 langsmith: 0.7.6 langchain_openai: 1.1.10 langgraph_sdk: 0.3.8

Optional packages not installed

langserve

Other Dependencies

httpx: 0.28.1 jsonpatch: 1.33 langgraph: 1.0.9 openai: 2.21.0 orjson: 3.11.7 packaging: 26.0 pydantic: 2.12.5 pyyaml: 6.0.3 requests: 2.32.5 requests-toolbelt: 1.0.0 tenacity: 9.1.4 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.14.1 xxhash: 3.6.0 zstandard: 0.25.0

extent analysis

Problem Summary

The issue is that the langchain-core version 1.2.14 is causing a regression in the get_weather tool, resulting in incorrect output.

Root Cause Analysis

The root cause of the issue is likely due to a change in the langchain-core library that is affecting the get_weather tool.

Fix Plan

To fix this issue, we need to downgrade the langchain-core version to 1.2.13 or upgrade the langchain-core version to a version that does not have this regression.

Step-by-Step Solution Plan

Downgrade langchain-core to 1.2.13

  1. Run the following command to downgrade langchain-core to 1.2.13:

pip install langchain-core==1.2.13

2. Verify that the issue is resolved by running the code again.

### Upgrade `langchain-core` to a version that does not have this regression

1. Run the following command to upgrade `langchain-core` to the latest version:
   ```bash
pip install --upgrade langchain-core
  1. Verify that the issue is resolved by running the code again.

Code Changes

No code changes are required to fix this issue. The issue is caused by a regression in the langchain-core library.

Temporary Workaround

If downgrading or upgrading langchain-core is not feasible, a temporary workaround is to use a different version of the get_weather tool that is not affected by this regression.

Verification

To verify that the fix worked, run the code again and verify that the output is correct.

Extra Tips

  • Always check the changelog of the library you are using to see if there are any known issues or regressions.
  • Use a version control system to keep track of changes to your code and dependencies.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - ✅(Solved) Fix langchain-core 1.2.14 stream_mode == "messages" tool args parse failed [2 pull requests, 3 comments, 4 participants]