Key Takeaways
- SQLite is the right default for local, single-user agent memory. Keep it if you do not need shared recall or cross-device continuity.
- The signal to move on is sync logic accumulating around SQLite, not the file getting too big.
- Patching SQLite with metadata tables, file sync, and a separate vector store costs as much as a real backend without the ergonomics of one.
- TiDB Cloud Zero gives you an instant SQL plus vector backend you can provision in seconds. mem9 gives you a managed memory API on top of the same storage. Pick based on how much of the stack you want to own.
Coding agents now run for hours, span multiple tools, and move between machines and sessions. However, the agent memory layer underneath them has not kept up. Most still look the way they did in the first prototype: SQLite for notes and records, local files for summaries, and embeddings bolted on later if they are needed at all.
That works until it doesn’t. The longer an agent runs, the more its memory has to carry. At some point, a session writes something useful and the next session cannot see it. You want the same context on another machine and find yourself writing sync logic around what was supposed to be local state. Semantic recall works but exact lookup does not. You add a metadata table here, a second store there, and quietly accumulate the cost of a backend without the stability of one.
That is a shape problem, not a scaling problem. The memory has started behaving like runtime infrastructure, but it is still stored like a file.
This blog explores when SQLite is still the right call, what signals it has stopped being a good fit, and what to move to when it has. SQLite is not the problem. The problem is treating memory as a local file once it has become shared runtime state.
When SQLite is Still the Right Answer for Agent Memory
SQLite remains one of the best defaults in the AI builder stack. It is local, easy to inspect, easy to back up, and usually fast enough. That is exactly why so many coding-agent memory systems start the same way: Notes and memory records in SQLite, summaries in local files, embeddings added later if needed.
For a local-first prototype, that architecture is often correct. Keep SQLite if most of these are true:
- One user, one machine, one active agent at a time.
- Low stakes if local state is lost between sessions.
- No requirement to share memory across users, agents, or machines.
- No need to inspect or query memory outside the agent harness.
- No need for cross-device continuity.
If you check those boxes, you do not need shared recall, exact filtering, or a queryable task history yet. Stay put.
What Changes When Agent Memory Has to Outlive One Process
SQLite does not get worse over time. The memory requirements change while the storage model stays local. That is the boundary worth naming clearly.
Once agent memory has to outlive one process on one machine, it stops being a retrieval problem and becomes a runtime problem. Session continuity, device portability, workspace-specific context, tool history, and exact filtering do not fit the local-file model. They require something that behaves like a service.
This is why the same pattern keeps showing up in coding-agent projects:
- Version one works locally with SQLite.
- Version two accumulates sync logic, metadata tables, and a second store for vectors.
- Version three is a custom backend, whether the team planned it or not.
The first sign you have crossed this boundary is rarely “the database file got too big.” It is more often one of these:
- The next session cannot reliably see what the last one wrote.
- Semantic recall works, but exact lookup against tool history or session metadata does not.
- You are writing sync logic around what was supposed to be simple state.
- Multiple agents or tools need a shared memory space and there is no clean way to give them one.
By the time people say “SQLite is breaking,” they usually mean something more specific: Memory has stopped behaving like local state and started behaving like runtime infrastructure.
Why Patching SQLite Usually Costs More Than Moving On
The instinct, when SQLite starts to creak, is to preserve it and add just enough around it. The patch list usually looks like:
- Sync the SQLite file between machines.
- Keep summaries in Markdown and embeddings in a separate store.
- Add metadata tables for exact filtering.
- Expose a small local API in front of SQLite.
- Stand up a second store because vector retrieval and structured lookup want different data shapes.
Any one of those can work in isolation. The cost compounds when two or three of them stack up. At that point, you are paying for the complexity of a backend without the ergonomics or stability of one.
This is also the point where local memory collides with how coding agents are actually used. Engineers change repos, swap laptops, share context with teammates, and need to query memory from outside the harness. The question is no longer “can SQLite store this row?” It is whether the memory system needs to behave like a service rather than a file.
What a Purpose-Built Agent Memory Backend Should Solve
If you have decided to stop patching, the next step needs to solve three things at the same time:
- Persistence across sessions, restarts, and machines, without sync logic in the harness.
- Hybrid retrieval, which means both exact filtering on structured metadata and semantic search on embeddings, in the same query.
- A backend you can provision quickly, ideally without a full migration before you know whether the new shape works.
Two tools solve this from different angles, depending on how much of the stack you want to own.
TiDB Cloud Zero: An Instant SQL Plus Vector Backend You Control
For teams who want to build the state layer themselves, TiDB Cloud Zero gives you a TiDB Cloud database in seconds, with no signup required to start. It is MySQL-compatible, supports vector search and ACID transactions in the same engine, and is disposable by default. That makes it suitable for agent backends, MCP server tooling, RAG prototypes, and demos. When you are ready to keep the database, you can claim it and upgrade to a persistent TiDB Cloud account without rebuilding.
The shape this fits is: You want full control over the schema, the queries, and the access patterns; you want one backend that handles structured lookup and vector retrieval in the same transaction; and you want to test it without committing to a migration first.
mem9: A Managed Memory API on Top of TiDB Cloud
For teams who would rather call an API than manage a backend, mem9 is the managed memory layer. It targets the first state problem most coding-agent users hit: Persistent recall, hybrid retrieval, shared memory spaces, and cross-session use across Claude Code, OpenCode, OpenClaw, and custom harnesses. You write memory records and queries through the API and TiDB Cloud handles the storage underneath.
The shape this fits is: You want to stop thinking about the memory backend and ship agent features instead.
The Pressure is Visible in the Projects Developers Are Already Shipping
You can see this demand in the open-source projects developers are building around Claude Code and similar harnesses. Memory plugins, context databases, and persistent cross-session memory tools keep appearing because builders keep hitting the same wall.
A few examples:
- claude-mem. A Claude Code plugin that captures session activity, compresses it with the Claude Agent SDK, and injects relevant context into future sessions. As of this writing, it has roughly 46K stars on GitHub.
- OpenViking. An open-source context database from Volcengine (ByteDance) that organizes agent memory, resources, and skills into a filesystem-style hierarchy.
- claude-memory-compiler. Captures Claude Code sessions and compiles them into structured knowledge articles using the Claude Agent SDK.
These are not edge cases. They are the natural next step once an agent is useful enough that losing its memory between sessions has a real cost. The lesson from looking across them: Developers are willing to install plugins, run worker services, and learn new abstractions to keep memory persistent. They are no longer treating local-only memory as acceptable.
Two pieces of writing help explain why this keeps happening. OpenAI’s unrolling the Codex agent loop makes the harness boundary explicit and shows that the harness, not the model, manages the loop, the tool calls, and the context. Anthropic’s work on effective harnesses for long-running agents shows what happens when an agent spans multiple context windows: Continuity depends on durable artifacts and on usable state from prior work. Both point at the same pressure. The more capable the agent, the more its memory has to carry. Progress state, tool history, repo-specific memory, compaction output, and cross-session continuity do not fit the local-file model.
Stay or Move: A Quick Decision Rule
Stay with SQLite if memory lives on one machine, the harness is the only reader and writer, you do not need to inspect memory from outside the harness, and losing session continuity is acceptable.
Move on when sync logic is accumulating around SQLite, sessions cannot see each other’s state, memory needs to survive restarts reliably, multiple agents or tools need a shared memory space, retrieval requirements outgrow what a single local store can satisfy, or you need persistent agent memory without building your own service.
The better question is not “should I replace SQLite?” It is: “Has my agent memory stopped being local state and started behaving like shared runtime state?” If the answer is yes, the next step should preserve what people liked about local memory (simplicity, low setup, fast iteration) and give it the behavior of a real backend.
Ready to move agent memory off SQLite? Spin up a free TiDB Cloud Zero database in seconds and point your agent harness at a real SQL plus vector backend. No signup, no credit card, no migration plan required to start.
FAQ
When should I move my agent off SQLite?
Move when memory needs to survive across sessions, machines, or processes; when multiple agents or tools need to share a memory space; when you need exact filtering on metadata and semantic search in the same query; or when you find yourself writing sync logic around the SQLite file. Local-only memory stops being sufficient once continuity and coordination matter.
Is SQLite a good database for AI agent memory?
For a local-first, single-user, single-machine prototype, yes. SQLite is fast, easy to inspect, and easy to back up. It stops being a good fit once memory has to outlive one process, move across devices, support shared access, or handle hybrid retrieval that combines exact lookup with vector search.
What is the difference between mem9 and TiDB Cloud Zero?
mem9 is a managed memory API. You call the API and skip the backend work. TiDB Cloud Zero is an instant SQL plus vector backend you provision yourself in seconds. Use mem9 when you want to ship agent features without managing memory infrastructure. Use TiDB Cloud Zero when you want to own the state layer, design the schema, and control the access patterns. Both run on TiDB Cloud underneath.
What is hybrid retrieval and why does it matter for agent memory?
Hybrid retrieval combines exact filtering on structured metadata with semantic similarity search on embeddings, in the same query. Agents need both. Exact filtering answers questions like “what tool calls did this session make in the last hour” and “what did this user request yesterday.” Semantic search answers questions like “what past memories are relevant to this prompt.” A backend that supports only one or the other forces the harness to stitch results together in application code.
Do I need to migrate my whole stack to test a new memory backend?
No. TiDB Cloud Zero is disposable by default. You can spin up a database in seconds, point a harness at it, and tear it down. mem9 is a managed API you can call from any harness without changing storage. Both are designed to test against an existing system before you commit.
Spin up a database with 25 GiB free resources.
TiDB Cloud Dedicated
A fully-managed cloud DBaaS for predictable workloads
TiDB Cloud Starter
A fully-managed cloud DBaaS for auto-scaling workloads