Stateless and stateful agents
What it is
Two designs, by where the record of the task lives:
- A stateless agent keeps nothing between requests. Each request arrives with everything needed, is answered, and is forgotten.
- A stateful agent keeps a record of the task between requests, so it can continue where it stopped.
Why it matters
The model itself is always stateless. The question is whether your system around it is.
- Stateless is simple and scales easily: any server can handle any request.
- Stateful is needed the moment a task spans more than one request: a conversation, a wait for approval, a job that runs for an hour.
- The usual production design is stateless servers with state in a database: any server can load a task's state and continue it.
In the real world: An agent that kept conversations in a Python dictionary lost every live chat on each deploy; moving state to a database made deploys invisible to users.
Visual example
ComparisonMost production systems are the last row: stateless servers, stored state.
Keeping state in the server's memory. It works on one machine and breaks as soon as there are two servers, a restart or a deployment. State belongs in a store every server can reach.
Practise it: Design an AI Customer Support Agent