TencentDB Agent Memory: 4-Tier Local Memory That Cuts Tokens 61%
TencentDB Agent Memory is an MIT-licensed open-source memory system from Tencent Cloud with 7,274 GitHub stars. It provides a 4-tier local-first memory pipeline (L0 Conversation, L1 Atom, L2 Scenario, L3 Persona) that runs entirely on SQLite + sqlite-vec with zero external API dependencies. Benchmarks show -61.38% token usage, +51.52% task success rate on WideSearch, and PersonaMem accuracy improvement from 48% to 76%. Integrates as an OpenClaw plugin (one-line install) or Hermes Gateway Docker image.
Primary Intelligence Summary:This analysis explores the architectural evolution of tencentdb agent memory: 4-tier local memory that cuts tokens 61%, focusing on the implementation of agentic AI frameworks and autonomous orchestration. By understanding these 2026 intelligence patterns, agencies and startups can build more resilient, self-correcting systems that scale beyond traditional automation limits.
By Deepak Bagada, CEO at SaaSNext. I have integrated TencentDB Agent Memory into OpenClaw-based agent workflows and measured the token reduction across 200+ agent sessions.
AI agents have a memory problem. Not the kind that requires therapy — the kind that costs you money every time your agent forgets what it learned in the previous session. Every long-running agent session accumulates thousands of context fragments, filling the window with noise and driving token costs exponentially. TencentDB Agent Memory is the first open-source system to solve this with a 4-tier semantic pyramid that runs entirely on your local machine.
[ STAT ] "7,274 GitHub stars in under 3 months. Cuts token usage by 61.38% and improves task success by 51.52%." — TencentDB Agent Memory benchmark, May 2026
Most current memory systems work the same way: shred every conversation into fragments, turn them into vectors, and drop them into a flat archive. When the agent needs to recall something, it runs a similarity search over those vectors. Tencent cloud's database team bluntly calls this "blind similarity search" and identifies two critical flaws: context bloat that fills the window with noise, and retrieval failure that pulls superficially similar but irrelevant fragments.
WHAT IS TENCENTDB AGENT MEMORY TencentDB Agent Memory is a 4-tier local-first memory pipeline: L0 Conversation captures raw dialogue, L1 Atom extracts structured facts, L2 Scenario summarizes scene blocks, and L3 Persona maintains a distilled user profile. Unlike flat vector stores, this layered approach lets agents query high-level persona first and drill down to atoms or raw conversations only when needed. The default backend is SQLite with sqlite-vec — no external API, no cloud dependency.
TOOL: TencentDB Agent Memory v0.3.4+ (MIT) 4-tier local-first agent memory. 7,274 stars. OpenClaw plugin + Hermes Gateway. Github: github.com/TencentCloud/TencentDB-Agent-Memory Cost: Free, open-source
TOOL: OpenClaw v2.x (MIT) Primary integration. One-line plugin install: openclaw plugins install @tencentdb-agent-memory/memory-tencentdb Cost: Free
TOOL: Hermes Agent (Nous Research) Secondary integration via Docker Gateway: agentmemory/hermes-memory:latest Cost: Free (bring your own LLM API key)
THE 4-TIER SEMANTIC PYRAMID L0 Conversation stores raw dialogue and tool call logs. Every message is captured and stored as JSONL. This is the evidence layer — full fidelity but high volume. L1 Atom extracts atomic facts from conversations using an LLM. These are structured, deduplicated knowledge fragments stored with vector embeddings for semantic search. L2 Scenario summarizes related L1 atoms into scene blocks stored as Markdown. Each scenario represents a coherent interaction context. L3 Persona maintains a distilled user profile as persona.md. This is queried first on every session start to inject user preferences into the system context.
WHEN WE TESTED THIS ON 200+ AGENT SESSIONS When we tested TencentDB Agent Memory across 200+ agent sessions over 3 weeks, the most dramatic improvement was in persona recall. Without the memory plugin, agents forgot user preferences after 15-20 conversation turns. With the L3 Persona layer, agents maintained consistent awareness of coding style preferences, project conventions, and recurring patterns across full 100-turn sessions. The 61% token reduction came primarily from the symbolic short-term memory component, which offloads verbose tool logs into compact Mermaid symbols on disk. On SWE-bench coding tasks, the plugin reduced context window usage by 33% while improving success rates by 9.93%.
WHO THIS IS BUILT FOR
For an AI engineer running long-horizon coding agents with Claude Code. Situation: Agent context fills up after 30 minutes. The agent forgets earlier context and repeats mistakes. Payoff: TencentDB Agent Memory recalls persona and atoms at session start. Context stays focused. Token usage drops 61%.
For a team running OpenClaw-based agent workflows. Situation: Multi-turn conversations lose context after 20+ rounds. Agents ask the same questions repeatedly. Payoff: One-line plugin install adds persistent memory. Agents remember decisions across sessions.
For a CTO evaluating AI infrastructure costs. Situation: Monthly token spend of $15,000. Context windows consume 40% of tokens with repeated information. Payoff: 61% token reduction drops monthly spend by $3,500-6,000 while improving task completion rates.
STEP BY STEP SETUP
Step 1. Install the plugin (OpenClaw — 1 min) Run openclaw plugins install @tencentdb-agent-memory/memory-tencentdb
Step 2. Enable memory (1 min) Set memory-tencentdb.enabled: true in ~/.openclaw/openclaw.json
Step 3. Use agents normally (auto) The plugin captures conversations and runs the L0-L3 pipeline automatically after N rounds.
Step 4. Observe recall (auto) On the next session start, the agent recalls your persona and relevant memories without prompting.
Step 5. Search memories (manual) Ask the agent to call tdai_memory_search or tdai_conversation_search for targeted recall.
Step 6. Manage storage (5 min) Check ~/.openclaw/memory-tdai/ for inspectable JSONL, Markdown, and text files per layer.
SETUP GUIDE
Tool [version] Role in workflow Cost / tier TencentDB Agent Memory v0.3.4+ 4-tier memory pipeline Free (MIT) OpenClaw v2.x Agent framework + plugin host Free (MIT) SQLite + sqlite-vec Default local storage backend Free
THE GOTCHA: The active recall window resets after 7 days of inactivity. If your workflow runs weekly, the agent will start session 8 with a cold recall. The memory data persists on disk, but the active injection requires recent conversation. Add a keep-alive ping to the memory endpoint every 5 days for production agents that run weekly.
ROI CASE
Metric Before (No Memory) After (TDAM) Source Token usage per task 221.31M 85.64M TencentDB benchmark (WideSearch) Task success rate 33% 50% TencentDB benchmark (WideSearch) Persona recall accuracy 48% 76% PersonaMem evaluation SWE-bench token cost 3,474.1M 2,375.4M TencentDB benchmark
The week-1 win: install the plugin, work through 3 agent sessions, then start session 4. The agent recalls your preferences from session 1 without being reminded. The strategic implication: agent memory infrastructure enables compound AI systems that improve over time, while memoryless systems restart from zero every session.
HONEST LIMITATIONS
- (moderate risk) 7-day recall window: Active recall resets after 7 days without conversation. Mitigation: Add a keep-alive every 5 days for weekly workflows.
- (significant risk) LLM dependency: L1-L3 pipeline requires LLM for extraction and summarization. Low-quality LLM degrades memory quality. Mitigation: Use Claude Sonnet 5 or GPT-5.6 for the memory pipeline.
- (minor risk) Storage growth: L0 logs grow ~10MB/week per active agent. Mitigation: Configure auto-cleanup for expired data. The plugin supports configurable retention periods.
- (moderate risk) Plugin compatibility: OpenClaw API changes may break the plugin. Mitigation: Pin OpenClaw version. Check compatibility before upgrading.
FAQ
Q: How much does TencentDB Agent Memory cost per month? A: Zero. The software is MIT-licensed and runs entirely locally. Storage uses SQLite on your machine. The only cost is the LLM calls for the L1-L3 pipeline (typically a few cents per session).
Q: Is TencentDB Agent Memory compliant with data privacy regulations? A: Yes. All data stays on your local machine. No data is sent to Tencent or any external service. The default backend is local SQLite. Optional Tencent Cloud Vector DB (TCVDB) is available but disabled by default.
Q: Can I use Mem0 or Zep instead of TencentDB Agent Memory? A: Yes, but TencentDB Agent Memory has unique advantages: the 4-tier pyramid structure preserves both raw evidence (L0) and structured profiles (L3), while Mem0 and Zep use flat vector stores. TencentDB is also the only option that runs fully local with zero API dependencies.
Q: What happens when the memory system runs out of storage space? A: L0 conversation logs can be configured with automatic cleanup. The system supports configurable retention periods for each layer. Default storage path is ~/.openclaw/memory-tdai/.
Q: How long does TencentDB Agent Memory take to set up? A: One minute for OpenClaw plugin install. Zero configuration needed — defaults to local SQLite and auto-captures after plugin enable. Hermes Gateway Docker setup takes 2-3 minutes.
Related on DailyAIWorld Headroom Context Compression Guide — Headroom provides universal context compression (60-95% fewer tokens) from a different angle. TencentDB organizes memory upstream; Headroom compresses downstream. TencentDB Agent Memory Workflow — Detailed workflow page with architecture diagram, integration guides, and benchmark data. Mesh LLM Distributed Inference Guide — Self-hosted inference pairs with self-hosted memory for a complete local AI infrastructure stack.
PUBLISHED BY
SaaSNext CEO