An optional TypedDict schema that extends AgentState.
When provided, this schema is used instead of AgentState as the base
schema for merging with middleware state schemas. This allows users to
add custom state fields without needing to create custom middleware.
Generally, it's recommended to use state_schema extensions via middleware
to keep relevant extensions scoped to corresponding hooks / tools.
Whether to enable verbose logging for graph execution.
When enabled, prints detailed information about each node execution, state
updates, and transitions during agent runtime. Useful for debugging
middleware behavior and understanding agent execution flow.
This name will be automatically used when adding the agent graph to
another graph as a subgraph node - particularly useful for building
multi-agent systems.
A compiled StateGraph that can be used for chat interactions.
The agent node calls the language model with the messages list (after applying
the system prompt). If the resulting AIMessage
contains tool_calls, the graph will then call the tools. The tools node executes
the tools and adds the responses to the messages list as
ToolMessage objects. The agent node then calls
the language model again. The process repeats until no more tool_calls are present
in the response. The agent then returns the full list of messages.
Example
fromlangchain.agentsimportcreate_agentdefcheck_weather(location:str)->str:'''Return the weather forecast for the specified location.'''returnf"It's always sunny in {location}"graph=create_agent(model="anthropic:claude-sonnet-4-5-20250929",tools=[check_weather],system_prompt="You are a helpful assistant",)inputs={"messages":[{"role":"user","content":"what is the weather in sf"}]}forchunkingraph.stream(inputs,stream_mode="updates"):print(chunk)