diff --git a/libs/prebuilt/langgraph/prebuilt/tool_node.py b/libs/prebuilt/langgraph/prebuilt/tool_node.py index 6585b8abf..fe190aa96 100644 --- a/libs/prebuilt/langgraph/prebuilt/tool_node.py +++ b/libs/prebuilt/langgraph/prebuilt/tool_node.py @@ -908,6 +908,16 @@ def tools_condition( class InjectedState(InjectedToolArg): """Annotation for injecting graph state into tool arguments. + .. deprecated:: 0.2.0 + Use reserved keyword 'state' instead of InjectedState annotation. + The annotation-based approach will be removed in a future version. + + Instead of: + def tool(x: int, state: Annotated[dict, InjectedState]) -> str: + + Use: + def tool(x: int, state) -> str: + This annotation enables tools to access graph state without exposing state management details to the language model. Tools annotated with InjectedState receive state data automatically during execution while remaining invisible @@ -1318,3 +1328,4 @@ def _get_runtime_arg(tool: BaseTool) -> Optional[str]: +