What Is Agent State?
Agent state is a structured data store that holds everything the agent knows about the current task, conversation, and user. It is updated after every action.
8 min•By Priygop Team•Updated 2026
State Structure
State Structure
# Comprehensive agent state structure
from datetime import datetime
from typing import Any
agent_state = {
# Task information
"task_id": "TASK-2024-001",
"goal": "Research and summarise the top 3 Python web frameworks",
"started_at": datetime.now().isoformat(),
"status": "running", # running | complete | failed | escalated | waiting
# Execution tracking
"step": 3,
"max_steps": 15,
"history": [
{
"step": 1,
"action": "web_search",
"args": {"query": "top Python web frameworks 2024"},
"observation": {"status": "success", "count": 5, "results": [...]},
"timestamp": "2024-01-15T10:01:00Z"
},
# ... more history entries
],
# Intermediate results
"data": {
"frameworks_found": ["Django", "FastAPI", "Flask"],
"research_complete": False,
"summaries": {}
},
# Error tracking
"errors": [],
"retry_counts": {},
# Output
"result": None # Final result when complete
}
print(f"Task: {agent_state['goal']}")
print(f"Step: {agent_state['step']}/{agent_state['max_steps']}")
print(f"Status: {agent_state['status']}")