Skip to main content
← All articles

Stateful vs stateless AI agents

A stateless AI agent treats every conversation as fresh — it has no memory of past sessions, no per-user history, no relationship continuity. A stateful AI agent remembers users across sessions, evolves over time, and stays in character. The difference is the presence of a memory layer and (optionally) a personality, mood, and relationship model. Stateless is simpler and cheaper. Stateful is required for any product where users come back.

What "stateless" means in practice

A stateless agent is just a function: prompt in, response out. The model doesn't remember anything between calls. If you want continuity within a conversation, you stuff the message history into the prompt. If you want continuity across conversations, you'd have to stuff the entire user history into every prompt — which gets expensive fast and doesn't scale past a few sessions.

ChatGPT was famously stateless until OpenAI added memory in 2024. Most LLM API integrations are still stateless by default.

What "stateful" means in practice

A stateful agent has external storage that persists across conversations: facts about the user, summaries of past sessions, relationship context, and (in richer systems) personality and mood. Before each LLM call, the relevant slice of state is retrieved and injected into the prompt. After the call, new information is written back.

The state lives outside the model — usually in a memory layer like Sonzai, Mem0, Zep, or Letta. The LLM itself stays the same.

When stateless is enough

When you need stateful

How to turn a stateless agent stateful

Three steps:

With Sonzai, this is three API calls: create an agent, post a chat turn, and the memory tree is built and maintained for you.

Stateful is more than memory

The biggest mistake people make is thinking "stateful" means "remembers facts." Real statefulness includes:

A truly stateful agent has all five. Most "memory layers" only provide the first one. Sonzai bundles all five into one API.

Build a stateful agent with Sonzai

Memory, personality, mood, relationships, and a knowledge base in one API. SDKs for TypeScript, Python, and Go.