Agent Memory

A language model remembers nothing. Every single call starts from an empty room, and anything it seems to remember was pasted back into the prompt by your code. Once you internalize that, most agent bugs become obvious.

Four kinds, four jobs

Scratchpad

What happened during this run: thoughts, tool calls, observations. Lives for one task, then goes away. This is what turns a sequence of calls into a loop.

Conversation

Earlier turns with the same person. Cheap to add, and the thing users notice missing first.

Long term

Facts worth keeping across sessions: preferences, account IDs, decisions already made. A store your code writes to and reads from. Here it is your browser's localStorage.

Retrieval

Too much to fit in a prompt, so you fetch only the relevant slice at question time. This is RAG, and it is memory with a search engine in front of it.

Optional: load a real model

Memory on, memory off

Talk to the agent for a few turns, then ask it something that depends on an earlier turn, such as "what did I say my name was?". Switch the toggle and ask the same thing again. Nothing about the model changes. Only what your code chose to send changes.

The conversation appears here, with the exact prompt size the model receives.

Long term memory you can inspect

Facts saved here persist across page loads, exactly as an agent's memory store would. They are written into the prompt on every turn above, and they stay on this device.

Nothing stored yet.
The trap. Memory is not free: every remembered turn is tokens you pay for and context the model has to read past. Real systems summarize old turns, keep a short profile of durable facts, and retrieve the rest on demand instead of carrying it all. When an agent starts getting worse the longer a conversation runs, look at what you are stuffing into the prompt before you blame the model.

Next: planning and breaking a goal into steps.

Free from AI School - no signup, everything runs in your browser.