langchain-ai/langgraph · error · DeprecationWarning
Setting attribute ' ' on ToolCallRequest is deprecated. Use…
Error message
Setting attribute '{name}' on ToolCallRequest is deprecated. Use the override() method instead to create a new instance with modified values. What it means
Deprecation warning from ToolCallRequest.__setattr__: ToolCallRequest is a frozen-style dataclass, and directly assigning to its fields after construction is deprecated. The assignment is still applied via object.__setattr__, but mutation should go through override(), which returns a new instance.
Solutions
- Replace 'req.state = new_state' with 'req = req.override(state=new_state)'
- Build modified copies via override() for tool, state, or runtime fields instead of mutating in place
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:162 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26).
Data as JSON: /api/errors/35ec789a389ed6a8.
Report an issue: GitHub.
Appendix: source
Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:162
"""
tool_call: ToolCall
tool: BaseTool | None
state: Any
runtime: ToolRuntime
def __setattr__(self, name: str, value: Any) -> None:
"""Raise deprecation warning when setting attributes directly.
Direct attribute assignment is deprecated. Use the `override()` method instead.
"""
import warnings
# Allow setting attributes during initialization
if not hasattr(self, "__dataclass_fields__") or not hasattr(self, name):
object.__setattr__(self, name, value)
else:
warnings.warn(
f"Setting attribute '{name}' on ToolCallRequest is deprecated. "
"Use the override() method instead to create a new instance with modified values.",
DeprecationWarning,
stacklevel=2,
)
object.__setattr__(self, name, value)
def override(
self, **overrides: Unpack[_ToolCallRequestOverrides]
) -> ToolCallRequest:
"""Replace the request with a new request with the given overrides.
Returns a new `ToolCallRequest` instance with the specified attributes replaced.
This follows an immutable pattern, leaving the original request unchanged.
Args:
**overrides: Keyword arguments for attributes to override.
View on GitHub (pinned to 38031739e5)