HazelJS LogoHazelJS
HazelJS Blog

Stateful vs Stateless AI Agents

Author
HazelJS Team
10/21/2026
General
Stateful vs Stateless AI Agents
← Back to Blog

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:

ConceptWhat it storesHazelJS home
Conversation / working memoryMessages, facts, embeddings@hazeljs/​memory and related memory docs
Durable agent runsExecution checkpoints, leases, HITL tasksDurableRunStore / 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:

  1. The agent is read-mostly
  2. Failures are safe to redo from the original user message
  3. No mid-flight human approval is required

Move to durable / stateful execution when:

  1. Gatekeeper returns require-approval
  2. Tools mutate external systems
  3. Runs must survive hazeld restarts
  4. 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.

Read next