Key Takeaways
- Retrieval-only memory accumulates contradictions, so agents repeat mistakes.
- Production memory needs controlled writes, deduplication, staleness management, and cross-type queries.
- The two-store pattern breaks on consistency, complexity, and an open write-back loop.
- TiDB reads, joins, and writes back corrected state in one ACID engine.
I’ve spent the last year helping enterprise teams put AI agents into real workflows: Fraud detection, infrastructure monitoring, customer intelligence. The conversations follow a predictable pattern.
The first question is always about the model. Which LLM? Which orchestrator?
The second question, about six weeks after go-live, is always about the data. Why is the agent making the same mistake it made last Tuesday? Why does it contradict itself between sessions, and does the output drift over time even though the prompt hasn’t changed?
The answer is almost always the same: the agent has nowhere to write back to. This post breaks down what a production agent actually needs from its memory layer, why the common two-store pattern fails, and how a database built for AI agent workloads closes the write-back loop.
The Read-Only Assumption
Most AI memory architectures today are designed around retrieval. You embed documents, store vectors, and let the agent search at query time. That works well for RAG pipelines over static content.
But agents in production aren’t reading static content. They observe events, make decisions, update state, and run continuously. They need to do what every transactional system has always needed to do: Read, then write, then confirm the write succeeded.
When the memory layer is read-optimized, or append-only, agents accumulate contradictions instead of resolving them. A fraud detection agent flags a transaction pattern as suspicious. Twelve hours later, a human reviewer clears the same pattern. The agent never learns that. The next similar transaction gets flagged again. The reviewer gets frustrated. The team loses confidence in the system.
That’s not a model problem. That’s a database problem.
What Agent Memory Actually Requires
Agent memory is the persistent state an agent reads from and writes to across sessions so it can act on what it learned before, rather than starting cold every run. When you decompose what a production agent needs from that layer, four requirements come up repeatedly.
- Controlled writes. Not every agent should be able to overwrite every record. When multiple agents share a memory space, which they will in any enterprise deployment, you need transactional guarantees so one agent’s update doesn’t silently corrupt another’s state.
- Deduplication at write time. Agents generate redundant observations. An anomaly detection agent running every five minutes logs the same underlying event dozens of times before a human acknowledges it. Without deduplication logic at the storage layer, the memory grows noisy and retrieval degrades.
- Staleness management. Agent memory has a shelf life. A customer’s account status from three weeks ago may actively mislead an agent running today. The storage layer needs to track when facts were written and allow queries that filter by recency, not just by relevance.
- Cross-type queries. Real agent workflows join structured facts with vector similarity in a single query. “Show me the customers semantically similar to this complaint who also have an overdue payment in the last 30 days” is not a vector search. It’s not a SQL query. It’s both, and it needs to be consistent.
None of this is exotic. It’s what databases have always been asked to do, applied to a new class of workload. And each requirement depends on the one before it: Deduplication is useless if write control doesn’t gate what enters, and staleness management is meaningless if you can’t correct what’s already there.
The Five Duties of an Agent Memory Layer
The five duties below are how a working agent memory layer holds that line in production.
| Duty | Mechanism | Purpose |
|---|---|---|
| Write control | Stores only final, confirmed, or escalated outcomes. Ephemeral working thoughts are left out. | Keeps the data footprint bounded by actual investigations rather than endless reasoning steps. |
| Deduplication | Checks new inputs against existing data using vector cosine distance. | Merges highly similar entries and increments an evidence count instead of duplicating data. |
| Reconciliation | Links and chains conflicting data automatically. | Supersedes older memories when a newly discovered fact directly contradicts them. |
| Confidence decay | Gradually reduces the confidence score of unreinforced memories over time. | Deprecates information that hasn’t been validated recently, preventing stale data from poisoning future decisions. |
| Compaction | Runs scheduled jobs to re-cluster and merge drifting memories. | Consolidates evidence and maintains fast retrieval over months of operation. |
Why This is Harder Than It Looks
The agent tooling ecosystem has converged on a pattern: Use a vector store for semantic retrieval, use a separate transactional database for structured state, and wire them together in application code. That works in a demo. In production it creates three problems.

Figure 1. The two-store pattern stitches a vector store and a transactional database together in application code; TiDB handles vectors, transactions, and analytics in one engine with ACID guarantees.
First, consistency. When two systems hold complementary facts, they diverge. The vector store says one thing; the relational store says another. The agent gets caught in the middle.
Second, operational complexity. Every joint in the pipeline is a failure mode, a latency addition, and an infrastructure cost. Enterprise teams building on AWS or Azure don’t want to manage five specialized stores behind every agent.
Third, the write-back loop never closes. Retrieval-only stores have no mechanism for an agent to say “I was wrong, update the record.” The memory is immutable. The agent learns nothing.
How TiDB Closes the Write-Back Loop
TiDB uses an HTAP architecture, meaning hybrid transactional/analytical processing: A single engine that handles transactions, analytics, and vector search together. That is the exact property this problem needs. An agent can read a vector similarity result, join it against live transactional rows, and write the result back under ACID guarantees, all in one consistent store.
The evidence is in production. Manus migrated to TiDB Cloud in roughly two weeks to support the viral launch of its agentic AI platform, because its agents needed durable state across thousands of concurrent, stateful iterations per task. On the consolidation side, Atlassian collapsed more than 750 PostgreSQL clusters into 16 TiDB clusters, cutting the operational overhead of fragmented storage rather than managing it.
The pattern is consistent. Teams that build agent memory on purpose-built retrieval stores eventually hit the write-back wall. Teams that start with a database capable of handling the full read-write lifecycle don’t.
The Question Worth Asking Early
If you’re building an agent system today, the architecture question worth asking before production is simple: What happens when the agent is wrong?
Can the system correct itself while a human reviewer closes the loop? Can the corrected state propagate to every downstream query without a pipeline rebuild?
If the answer depends on your application code rather than your database, you have a design risk that will surface at the worst possible moment. Agent memory that can only accumulate is not memory. It’s a log. The difference matters when the stakes are real.
TiDB is the open-source distributed SQL database built for agentic workloads. Spin up a free TiDB Cloud cluster and build your first agent memory layer in minutes.
FAQs
What is agent memory?
Agent memory is the persistent state an AI agent reads from and writes to across sessions. It lets the agent act on what it learned in prior runs instead of starting cold each time. In production it needs controlled writes, deduplication, staleness management, and cross-type queries, not just retrieval.
Why isn’t a vector database enough for agent memory?
A vector store answers semantic similarity questions well, but it has no mechanism to correct a record when the agent is wrong. It can’t gate concurrent writes, filter by recency, or join semantic results against live transactional state in one consistent query. Those are the operations a production agent depends on.
What does “write-back” mean for AI agents?
Write-back is the agent’s ability to update its own memory after acting: Correcting a prior conclusion, merging a duplicate observation, or superseding a stale fact. Retrieval-only architectures are effectively append-only, so the agent accumulates contradictions instead of resolving them.
Why does TiDB fit agent memory workloads?
TiDB processes transactions, vector search, and analytical queries with distributed ACID guarantees in a single engine. An agent can run a similarity search, join the result against transactional rows, and write the corrected state back in the same SQL call, without reconciling separate systems.
Experience modern data infrastructure firsthand.
TiDB Cloud Dedicated
A fully-managed cloud DBaaS for predictable workloads
TiDB Cloud Starter
A fully-managed cloud DBaaS for auto-scaling workloads