Skip to content

[langchan-core] Breaking change: Tool with argument tool_call_id forces invoke to use different call pattern #34169

@cristianocca

Description

@cristianocca

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-cli
  • 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-perplexity
  • langchain-prompty
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Example Code (Python)

# Tool definition 
@tool(name, description=description)
def handoff_tool(
    task_description: Annotated[
        str,
        "some argument",
    ],
    state: Annotated[Any, InjectedState],
    tool_call_id: Annotated[str, InjectedToolArg],
) -> SomeModel:
    ....


# Tool call
tool.invoke(
    {"task_description": "Test task", "state": some_state, "tool_call_id": "test-id"}
)

# With langchain 1.0.5 -- works

# With langchain >= 1.0.6 -- raises exception

raises from https://github.com/langchain-ai/langchain/pull/33999/files


msg = (
    "When tool includes an InjectedToolCallId "
    "argument, tool must always be invoked with a full "
    "model ToolCall of the form: {'args': {...}, "
    "'name': '...', 'type': 'tool_call', "
    "'tool_call_id': '...'}"
)
raise ValueError(msg)

Error Message and Stack Trace (if applicable)

E                       ValueError: When tool includes an InjectedToolCallId argument, tool must always be invoked with a full model ToolCall of the form: {'args': {...}, 'name': '...', 'type': 'tool_call', 'tool_call_id': '...'}

Description

When upgrading from langchain 1.0.5 to 1.1.0 there is a breaking change in how tools are invoked.

Breaking change was added in https://github.com/langchain-ai/langchain/pull/33999/files

Addressing the error is not possible as well (without significant refactor), as using "type": "tool_call" forces the tool to always return strings which is not backwards compatible. We have implemented a custom tool node that allows returning arbitrary objects from tools and coerces it to string using custom logic (i.e., serializing json, invoking custom model methods, etc).

As this was a breaking change, it would be great to keep it in a major version.

System Info

System Information
------------------
> OS:  Darwin
> OS Version:  Darwin Kernel Version 24.6.0: Wed Oct 15 21:12:06 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_ARM64_T6000
> Python Version:  3.12.11 (main, Jun  3 2025, 15:41:47) [Clang 17.0.0 (clang-1700.0.13.3)]

Package Information
-------------------
> langchain_core: 1.0.5
> langchain: 1.0.5
> langchain_community: 0.4.1
> langsmith: 0.4.49
> langchain_aws: 1.0.0
> langchain_classic: 1.0.0
> langchain_text_splitters: 1.0.0
> langgraph_checkpoint_aws: 1.0.1
> langgraph_sdk: 0.2.10

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.13.2
> boto3: 1.42.0
> dataclasses-json: 0.6.7
> httpx: 0.28.1
> httpx-sse: 0.4.3
> jsonpatch: 1.33
> langgraph: 1.0.4
> langgraph-checkpoint: 3.0.1
> numpy: 2.3.2
> opentelemetry-api: 1.38.0
> opentelemetry-exporter-otlp-proto-http: 1.38.0
> opentelemetry-sdk: 1.38.0
> orjson: 3.11.4
> packaging: 25.0
> pydantic: 2.12.5
> pydantic-settings: 2.12.0
> pytest: 9.0.1
> PyYAML: 6.0.3
> pyyaml: 6.0.3
> requests: 2.32.5
> requests-toolbelt: 1.0.0
> SQLAlchemy: 2.0.44
> sqlalchemy: 2.0.44
> tenacity: 9.1.2
> typing-extensions: 4.15.0
> typing_extensions: 4.15.0
> zstandard: 0.25.0

Metadata

Metadata

Assignees

Labels

bugRelated to a bug, vulnerability, unexpected error with an existing featurecoreRelated to the package `langchain-core`langchainRelated to the package `langchain`

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions