Understanding the Agent's State › Visualizing State Flow
Michael BrenndoerferJuly 7, 20251 min read
AI Agent HandbookAll chapters Part 7 of 15Agent State and Architecture - Putting It All Together
Understanding the Agent's State › Visualizing State FlowOne section · Sections in this chapter8 / 12 ↓
Sections in this chapter12
Let's trace how state evolves through a simple interaction:
Initial State:
In[11]:
Code{"current_goal": None, "conversation_history": [], "working_memory": {}}Out[11]:
Console{'current_goal': None, 'conversation_history': [], 'working_memory': {}}User asks: "What's 1234 times 5678?"
State after receiving message:
In[12]:
Code{
"current_goal": "Calculate 1234 × 5678",
"conversation_history": [
{"role": "user", "content": "What's 1234 times 5678?"}
],
"working_memory": {},
}Out[12]:
Console{'current_goal': 'Calculate 1234 × 5678',
'conversation_history': [{'role': 'user',
'content': "What's 1234 times 5678?"}],
'working_memory': {}}Agent decides to use calculator tool
State after tool call:
In[13]:
Code{
"current_goal": "Calculate 1234 × 5678",
"conversation_history": [
{"role": "user", "content": "What's 1234 times 5678?"}
],
"working_memory": {"calculation_result": 7006652},
"tools_used": ["calculator"],
}Out[13]:
Console{'current_goal': 'Calculate 1234 × 5678',
'conversation_history': [{'role': 'user',
'content': "What's 1234 times 5678?"}],
'working_memory': {'calculation_result': 7006652},
'tools_used': ['calculator']}Agent responds with answer
Final state:
In[14]:
Code{
"current_goal": "Calculate 1234 × 5678",
"goal_status": "completed",
"conversation_history": [
{"role": "user", "content": "What's 1234 times 5678?"},
{"role": "assistant", "content": "1234 × 5678 = 7,006,652"},
],
"working_memory": {"calculation_result": 7006652},
"tools_used": ["calculator"],
}Out[14]:
Console{'current_goal': 'Calculate 1234 × 5678',
'goal_status': 'completed',
'conversation_history': [{'role': 'user',
'content': "What's 1234 times 5678?"},
{'role': 'assistant', 'content': '1234 × 5678 = 7,006,652'}],
'working_memory': {'calculation_result': 7006652},
'tools_used': ['calculator']}You can see the state evolving step by step. Each action the agent takes updates some part of the state, and each decision the agent makes is informed by the current state.