Memory · Free preview

Durable State

Watch an agent remember

Agents are stateless by default — each turn forgets the last. Durable state gives an agent memory it can write down, then read back even after a restart, by serializing it to a store and rehydrating it later.

Make the agent remember across a restart

By default a model is stateless: each turn starts cold and forgets the last. To build an agent that remembers, you give it durable state — a place to write facts down and read them back later. But "later" hides the hard part. Memory inside the running process vanishes the moment the process restarts, the request ends, or the agent is rescheduled onto a different machine. Durable means the state outlives all of that.

The move has two halves. Persist: before the lights go out, serialize your state into something a store can hold — JSON.stringify(state) turns the live object into a plain string you could write to a database, a file, or a Durable Object. Restore: when a fresh, empty process boots, rehydrate it by reading that string back — JSON.parse(saved) reconstructs the object. Skip the persist and there's nothing to read; skip the restore and the fresh state stays empty. Either gap and the memory is gone.

Watch the agent save a fact on one turn and recall it on a later turn instead of guessing:

Now build the mechanism that makes that possible. Below, the state is assembled from a few events and the print lines are wired — but the persist and restore steps are left as TODOs, so the "restarted" state comes up empty. Serialize the state to saved, then rehydrate restored from it, until the order and note survive the restart and it prints restored after restart: 2 items.

The memory isn't in the model, and it isn't in the running process — it's in the bytes you wrote down. Persist before the restart, restore after it, and the agent remembers.

In the full academy, you watch a real agent run this — live:

🔒 Live code execution, real agent runs, mastery tracking and verifiable credentials unlock with the full academy.

This is 1 of 50 lessons.

The full academy: write real code, watch real agents run, and earn verifiable credentials — across 8 tracks, in a 3D campus.

Unlock the full academy — $100 →

More free lessons: An LLM Is a Function  ·  The Agent Loop  ·  Define a Tool  ·  Give an Agent a Tool

← The Agent Marketplace