Stateful vs Stateless AI Agents

When agents need durable run state, HITL suspend, and recovery — and when a stateless request/response loop is enough.
A stateless agent treats each request as independent: prompt in, answer out. That is enough for many read-only assistants and FAQ bots.
A stateful / durable agent keeps execution state across turns, failures, and human waits. You need that when a tool call requires approval mid-flight, work spans minutes or hours, or the process may crash and must resume.
Stateless: when it is the right call
Stateless agents win when:
- Every request is independently answerable from retrieval + a short prompt
- Side effects are read-only or idempotent and cheap to retry from scratch
- You do not need human approval inside a multi-step tool path
They fail when money moves, tickets update, or a human must sign off before the next tool runs — restarting from zero is either unsafe or expensive.
Stateful chat memory ≠ durable execution
Two different ideas get mixed in marketing copy:
| Concept | What it stores | HazelJS home |
|---|---|---|
| Conversation / working memory | Messages, facts, embeddings | @hazeljs/memory and related memory docs |
| Durable agent runs | Execution checkpoints, leases, HITL tasks | DurableRunStore / DurableJobStore + HumanTaskService |
You can have chat memory without durable runs (a chatbot that forgets mid-refund). You can have durable runs without long-term user memory (a batch ops agent). Production Agent OS usually needs both, but they are not the same package or API.
Why while (true) is not durability
Avoid:
while (true) {
await agent.run();
}
…unless you accept losing in-memory state on every crash. Process death drops the loop. Model and tool failures need retries with leases. Long-running tasks and human approvals need suspend/resume.
HazelJS Agent OS stores durable runs (DurableRunStore), supports worker leases, and resumes HITL after restart when durable suspend is enabled. That composition is what we call the durable kernel — architecture language, not a separate npm package named DurableKernel.
Practical checklist
Use a stateless path when:
- The agent is read-mostly
- Failures are safe to redo from the original user message
- No mid-flight human approval is required
Move to durable / stateful execution when:
- Gatekeeper returns
require-approval - Tools mutate external systems
- Runs must survive
hazeldrestarts - Operators need
hazel agent runs resume/ approval CLI flows
Local commands that matter
hazel apply
hazel approvals
hazel approve <taskId>
hazel agent runs resume <runId>
Foreground hazel dev dies with the terminal. Durable agents assume hazeld stays up after hazel apply.