Resources / AI agents

Giving AI agents memory: state, storage and context

Agents forget everything between runs. How to give them durable memory with tools backed by key-value stores and tables.

A language model only knows what's in its context window right now. Close the chat and it's gone. For agents that work across days — tracking a project, following up with a customer, remembering preferences — you need memory outside the model.

Three kinds of memory

Memory as tools

The simplest durable memory is a pair of tools the agent calls itself:

remember(key, value)     store a fact
recall(key)              read it back

For records, add tools that insert and search: add_note, find_notes(topic). Because these are ordinary tools, any MCP client can use the same memory — your agent in Claude today, in your own app tomorrow.

Choosing the store

See Key-value, tables or blobs.

Keep memory scoped and safe

Partition memory per user or per API key, so one user's agent can't read another's. Validate what the agent writes — it may store something it shouldn't. Give users a way to view and delete what's remembered.

In Wisp

"Give my agent a memory: remember and recall facts per user, and add and search notes" becomes a few endpoints backed by Wisp's key-value store and tables — and an MCP server your agent can call.

Build it with Wisp — describe an API, get it live.

Related