[GH-ISSUE #1010] [langchain]: Incorrect ToolRuntime type parameter usage in documentation #131

Closed
opened 2026-02-17 17:19:14 -05:00 by yindo · 1 comment
Owner

Originally created by @ganeshprasadrao on GitHub (Oct 20, 2025).
Original GitHub issue: https://github.com/langchain-ai/docs/issues/1010

Type of issue

issue / bug

Language

Python

Description

Description:
While following the LangChain v1 docs for python, I encountered a type error when using the ToolRuntime generic class as shown in the examples. The docs currently suggest or imply that ToolRuntime takes a single type argument (e.g., ToolRuntime[Context]), but in reality, it requires two type parameters.


Steps to Reproduce:

from dataclasses import dataclass
from langchain.tools import tool, ToolRuntime

@dataclass
class Context:
    user_id: str

@tool
def get_user_location(runtime: ToolRuntime[Context]) -> str:
    return "Florida" if runtime.context.user_id == "1" else "SF"

Observed Behavior:

TypeError: Too few arguments for <class 'langchain.tools.tool_node.ToolRuntime'>; actual 1, expected at least 2

Expected Behavior:
The documentation should show the correct generic signature:

from typing import Any
@tool
def get_user_location(runtime: ToolRuntime[Context, Any]) -> str:
    ...

or note that users can safely omit generics:

@tool
def get_user_location(runtime: ToolRuntime) -> str:
    ...

Suggested Fix:
Update the affected documentation (likely under Tools / ToolRuntime or related agent examples) to correctly specify that ToolRuntime requires two generic arguments:

ToolRuntime[ContextType, StateType]

and optionally mention that the second can be Any if not used.

from typing import Any

ToolRuntime[ContextType, Any]

Environment:

  • Python 3.12
  • LangChain v1
  • macOS (Apple Silicon)

Additional Context:
This error can confuse users because the example runs fine until runtime type-checking occurs, leading to misleading TypeError messages. Clarifying the signature in the docs will prevent false bug reports and confusion among developers using custom runtime contexts.

Originally created by @ganeshprasadrao on GitHub (Oct 20, 2025). Original GitHub issue: https://github.com/langchain-ai/docs/issues/1010 ### Type of issue issue / bug ### Language Python ### Description **Description:** While following the LangChain v1 docs for python, I encountered a type error when using the `ToolRuntime` generic class as shown in the examples. The docs currently suggest or imply that `ToolRuntime` takes a single type argument (e.g., `ToolRuntime[Context]`), but in reality, it requires **two** type parameters. --- **Steps to Reproduce:** ```python from dataclasses import dataclass from langchain.tools import tool, ToolRuntime @dataclass class Context: user_id: str @tool def get_user_location(runtime: ToolRuntime[Context]) -> str: return "Florida" if runtime.context.user_id == "1" else "SF" ``` **Observed Behavior:** ```text TypeError: Too few arguments for <class 'langchain.tools.tool_node.ToolRuntime'>; actual 1, expected at least 2 ``` --- **Expected Behavior:** The documentation should show the correct generic signature: ```python from typing import Any @tool def get_user_location(runtime: ToolRuntime[Context, Any]) -> str: ... ``` or note that users can safely omit generics: ```python @tool def get_user_location(runtime: ToolRuntime) -> str: ... ``` --- **Suggested Fix:** Update the affected documentation (likely under *Tools / ToolRuntime* or related agent examples) to correctly specify that `ToolRuntime` requires two generic arguments: ```python ToolRuntime[ContextType, StateType] ``` and optionally mention that the second can be `Any` if not used. ```python from typing import Any ToolRuntime[ContextType, Any] ``` --- **Environment:** * Python 3.12 * LangChain v1 * macOS (Apple Silicon) --- **Additional Context:** This error can confuse users because the example runs fine until runtime type-checking occurs, leading to misleading `TypeError` messages. Clarifying the signature in the docs will prevent false bug reports and confusion among developers using custom runtime contexts.
yindo added the langchain label 2026-02-17 17:19:14 -05:00
yindo closed this issue 2026-02-17 17:19:14 -05:00
Author
Owner

@mdrxy commented on GitHub (Oct 20, 2025):

This is fixed in langchain 1.0.1

@mdrxy commented on GitHub (Oct 20, 2025): This is fixed in `langchain 1.0.1`
yindo changed title from [langchain]: Incorrect ToolRuntime type parameter usage in documentation to [GH-ISSUE #1010] [langchain]: Incorrect ToolRuntime type parameter usage in documentation 2026-06-05 17:25:15 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#131