Agent State Management
How agents persist and manage their internal state.
State Storage
Agent state is stored in the SQLite database. Each agent has a JSON state blob that persists across restarts.
Saving State
Agents can save state during execution:
Agent Runtime
│
├── save_state(key, value)
│ ↓
│ SQLite database
│
├── load_state(key) → value
│ ↑
│ SQLite database
│
└── clear_state(key)
State and Restarts
When a supervisor restarts an agent:
- The agent's WASM instance is destroyed
- A new WASM instance is created
- The agent can load its previous state from the database
- Execution continues from the saved state
State Inspection
naos inspect researcher --state
# Agent: researcher
# State:
# last_query: "AI trends 2025"
# results_count: 15
# checkpoint: "step-3"
State Size Limits
| Tier | Max State Size |
|---|---|
| Default | 1 MB |
| Extended | 10 MB |
| Edge (Durable Objects) | 128 KB per key |
Best Practices
- Save frequently — Don't lose work on crashes
- Save incrementally — Don't rewrite the entire state every time
- Keep state small — Large states slow down restarts
- Use checkpoints — For long-running tasks, save progress markers