
What State Represents
State is the memory of your application.
What State Represents
The State is the single source of truth for your agent. It is a shared dictionary (or object) that all nodes can access.
The Schema
You define the schema upfront using Python's TypedDict.
from typing import TypedDict, List
class AgentState(TypedDict):
# The chat history
messages: List[str]
# Internal thought process
current_plan: str
# Results from API calls
tools_output: dict
# User metadata
user_info: dict
Global vs Local
In LangGraph, State is Global to the execution run.
- If Node A writes to
user_info, Node Z (running 10 steps later) can read it. - You don't need to pass arguments function-to-function. You just update the shared state.
This mimics how human memory works during a task. We hold the context in our "working memory" while we perform different actions.