SurrealDB Agent Memory turns messages and documents into facts that you can query. It keeps each fact with its source, when it was stated, and the facts it replaced, and it answers questions in plain language with a citation for each answer. An agent can use it as a memory that lasts between conversations, and an application can use it as a knowledge base over its own documents.
It runs on SurrealDB Cloud, so there is no server to set up. You can call it from an SDK, over REST, or from any coding assistant that speaks MCP.
Coding agents
If a coding agent is writing your integration, paste this prompt into it. The agent installs the SurrealDB Agent Skills, connects the Agent Memory MCP server to your context, and reads the agent guide before it writes any code:
Set me up for SurrealDB Agent Memory. Fetch https://surrealdb.com/docs/agent-memory/agents/instructions.md and follow it.The MCP server works with Cursor, VS Code, Windsurf, Zed and OpenCode, and Claude and Codex have a SurrealDB plugin. The agent guide is the single page that an agent needs to use Agent Memory correctly.
Where to start
Choose the route that matches how you work. Each one ends at the same memory, so you can switch later.


Build with the SDK or REST API
Create a context, then remember and recall a fact from TypeScript, Python or cURL.


Use a coding agent
Paste one prompt and the agent installs the skills, connects the MCP server and reads the agent guide.
Try it in Studio
Create a context on SurrealDB Cloud and chat with it, without writing code.


Move from another memory layer
Frameworks and AI SDKs that connect to Agent Memory, and migration guides from Mem0, Zep, LangMem and a vector store.
Quickstart
Sign in to SurrealDB Studio, open your organisation, and go to Contexts. A context is one agent memory store.
Create a context, then open its API keys view and create a key. Copy the key, the context ID and the context host.
Paste one of the snippets below, with your own values in place of the placeholders.
npm install @surrealdb/memoryimport { AgentMemory } from "@surrealdb/memory";
const memory = new AgentMemory({
endpoint: "https://<your-context-host>",
context: "<your-context-id>",
apiKey: "<your-api-key>",
});
await memory.remember("Alice was promoted to CTO.");
const hits = await memory.recall("What is Alice's role?");Next steps
Scopes. A scope is a path such as
org/acme/user/alicethat decides who can read a fact. Writes takescopes, reads takelens, and each path is registered first. Contexts and scope explains how.Chat.
POST /chatanswers a message from what the memory holds, with citations. See the REST API.Documents. Uploading documents adds manuals, policies and other files to the same memory.
Agent Memory runs on SurrealDB Cloud. Single-tenant deployments are available on the Enterprise plan, and self-hosted deployments in your own cloud account or data centre are in development as part of the same plan. To discuss either, contact sales. Agent Memory Enterprise lists what the plan includes.
What you can build
An agent with Agent Memory can know a customer across months of conversations, keep each user's notes private from the others, answer questions about a pile of documents with a citation for every claim, and say what was true at a date in the past as well as what is true now. A team of agents can share one memory, with each agent reading only the scopes its key allows.
These guides build the most common cases from start to finish:
Customer service. The customer support agent remembers each customer between conversations.
Personal assistants. The personal AI assistant keeps what a user tells it, and forgets on request.
Internal knowledge. Knowledge-grounded agents answer from your documents with citations.
Several agents. Multi-agent shared memory gives each agent its own scopes in one context.
Coding and research agents. A coding agent with project memory and a long-running research agent.
See it working
Each demo is a finished piece: a body of text ingested into a context, and an interactive page drawn from what the memory holds. Every demo page embeds the result and then explains how it was built, so you can repeat the steps with your own data. The Showcase lists all eight.
Calgary 1912-1913 explorer
Walk the city of Calgary built from two volumes of Henderson's Calgary Directory, where every answer a resident gives comes from a scope you can inspect.
Robin Hood character graph
Howard Pyle's The Merry Adventures of Robin Hood ingested one chapter at a time, and drawn as the cast known at each point in the book.
Vulcan, Alberta: an article's history
24 years of edits to one Wikipedia article in Agent Memory, and agents answering questions about what the article used to say. A small model with Agent Memory scores at least as well as a large one reading the history, for less than half the cost.
Rome, 753 BC to AD 1453
Every year from the founding of Rome to the fall of Constantinople on a map, with rulers and control of places read back as value histories, and an export that turns any period into a prompt for an LLM.
Night Owls: twenty years of forum memory
Seven agents on a simulated bulletin board react to five real events from 1999 to 2019. Each post shows what Agent Memory held on its author at that moment, and private notes from 1999 still come back in 2019.
Sundance Lake Loop: who can read what on a pipeline project
A fictional pipeline project in six chapters. Each employee's assistant reads Agent Memory through its own scoped key, remembers its owner's conversations, and leaves a note when its owner says something the listener should not hear.
How Agent Memory works
These are the ideas the rest of the documentation builds on. Each one has a page of its own. If context windows, compaction and embeddings are new to you, How an AI model remembers and the two pages after it explain them first.
| Idea | In short | Read more |
|---|---|---|
| Contexts and scopes | A context is one memory store. Inside it, scopes are paths such as org/acme/user/alice. A write goes to scopes, and a read or an API key is limited to the scopes it names. | Contexts and scope |
| Writing | A message or a document is sent to the context. A language model extracts the entities, attributes and relations in it, and each one is compared with what the memory already holds before it is stored. | How it works in five minutes |
| Change over time | A new value replaces an old one without deleting it, so the memory can answer for any point in time as well as for now. | Supersession, decay, and forget |
| Sources | Every fact keeps its source: the message or document it came from, and when. Answers cite these sources. | Provenance and traceability |
| Reading | A question goes to the fastest method that can answer it first: in chat, an earlier answer whose facts are still current, then a direct lookup in the graph, a combined vector, keyword and graph search, and last a rewritten query. | Coherence, retrieval, and cost tiers |
| Storage | All of this is stored in a SurrealDB database as records, graph edges, vectors and documents, written in transactions. | Unified substrate and authority |
For the design behind these ideas, start with Principles and goals and the glossary.
Integrations
Agent Memory connects to the tools an agent is usually built with:
SDKs. TypeScript, Python, Go, Kotlin, Swift, and more under Integrate.
Frameworks. LangChain, LlamaIndex, CrewAI, Pydantic AI, Mastra and Google ADK.
AI SDKs. The Vercel AI SDK and TanStack AI.
Voice. LiveKit, ElevenLabs and Gradium, for agents that remember a caller.
Moving from another memory layer. Guides for Mem0, Zep, LangMem and a vector store.
Sections
Learn - the mental model, then ingest, retrieval, reasoning, operations and tuning, the Showcase and cookbooks, and the architecture underneath.
Integrate - SDKs, the MCP server, framework and AI SDK integrations, and migration guides.
Operate - contexts on SurrealDB Cloud, single-tenant Enterprise deployments, and their configuration.
Reference - REST, MCP tools, CLI, SDKs, configuration and errors.
The name Spectron
SurrealDB Agent Memory was developed under the project name Spectron, and the rename is arriving in stages. Already renamed: the client SDKs (@surrealdb/memory, surrealdb-memory, and so on), the framework integrations, the CLI, which is now surreal memory, the Agent Memory component of the surreal command-line tool, and the MCP server, which registers as agent-memory.
Still carrying the old name: the SPECTRON_* environment variables, and the X-Spectron-* request headers. Those are configuration and wire contract rather than things the product is called, so they are unchanged for now.