Understanding the Agent's State › State Is Dynamic
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 › State Is DynamicOne section · Sections in this chapter7 / 12 ↓
Sections in this chapter12
Here's an important point: state isn't static. It changes constantly as the agent works.
When the user sends a message, the state updates:
In[2]:
Code## New message arrives
state["conversation_history"].append({"role": "user", "content": message})When the agent calls a tool, the state updates:
In[4]:
Code## Tool call completes
state["tools_used"].append("flight_search")
state["working_memory"]["flight_results"] = resultsWhen the agent completes a step, the state updates:
In[10]:
Code## Step complete
state["current_step"] += 1The agent is constantly reading from state (to decide what to do) and writing to state (to record what it has done). This read-update-act cycle is the heartbeat of an AI agent.