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
- Working memory: the current conversation. Limited by the context window; cleared when the session ends.
- Facts and preferences: small, keyed pieces of information — "the user prefers metric units", "Acme's contact is Dana".
- Records and history: structured data the agent creates and queries — tasks, notes, decisions, logs.
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
- Key-value for facts looked up by a known key, with expiry for things that go stale.
- Tables for records you filter and list.
- A vector database when you need search by meaning across lots of text.
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.