Types of State
| Type | Scope | Persists After Call | Example |
|---|---|---|---|
| Turn state | Single response | No | Current tool results |
| Session state | Entire call | No | Customer ID, collected data |
| Persistent state | Across calls | Yes | User preferences, history |
Session State (Instance Variables)
Store data onself to remember it across turns within a call.
Initial Variables
Access caller-provided data viaself.initial_variables in __init__.
Context History
The conversation context tracks all messages:Extracting Information
Use tools to extract and store structured data:Turn Counting
Track conversation progress:Shared State Across Nodes
For multi-node graphs, use the session for shared state:Persistent State
For data that survives across calls, use an external store:State Validation
Validate collected data before proceeding:Tips
Use instance variables for session state
Use instance variables for session state
The simplest and most reliable approach. Each session gets its own agent instance.
Access initial_variables in start()
Access initial_variables in start()
Session context is available in the init_event. Store what you need as instance variables.
Validate before proceeding
Validate before proceeding
Build tools that check required fields are present before taking action.

