Skip to main contentSkip to navigation
[email protected]
Client AreaSupport
Hosting Mammoth
HostingMammothYour Data, Our Responsibility
Home
Solutions
Hosting Services
Store
Pricing
About
Blog
API
Contact

Stay Ahead of the Curve

Get the latest insights on cybersecurity, AI innovations, and enterprise data solutions delivered to your inbox.

Hosting Mammoth
HostingMammothEnterprise Solutions

Enterprise-grade data solutions. Hosting, recovery, cybersecurity, and AI-powered services for businesses worldwide.

[email protected]
Sun - Fri, 9:00am - 5:00pm

Services

  • Cloud Hosting
  • Data Recovery
  • Cybersecurity
  • Legal Support
  • MSP Services
  • Web Development
  • AI Services
  • Free Server Migration

Hosting

  • VPS Hosting (NVMe SSD)
  • VDS Hosting (NVMe)
  • Storage VPS (High SSD)
  • GPU Servers
  • Managed Services
  • Cloud Firewall
  • Load Balancer
  • One-Click Apps
  • n8n Hosting
  • Object Storage
  • FAQ

Company

  • Store
  • Pricing
  • About Us
  • Locations
  • Blog
  • Testimonials
  • Contact
  • Affiliate Program
  • White-Label
  • Terms of Service
  • Privacy Policy
  • Browser Cookies
  • SLA

Support

  • Client Area
  • Submit Ticket
  • Knowledge Base
  • Server Status
  • API Documentation

© 2026 Hosting Mammoth. All rights reserved.

← Back to Blog
aiMay 25, 20265 min read

Tencent Open-Sources TencentDB Agent Memory: A 4-Tier Local Memory Pipeline for AI Agents

Explore TencentDB Agent Memory's 4-tier local memory pipeline for AI agents. Runs on SQLite, no API calls, solves context bloat and recall degradation.

R

Ryan Park

May 25, 2026

Why Agent Memory Is Still a Largely Unsolved Problem

If you've shipped a long-horizon AI agent in production, you already know the pain: context windows bloat with tool logs, the agent hallucinates facts it "saw" three turns ago, and recall degrades into a noisy similarity search across a flat vector dump. Most memory stacks treat this as a retrieval problem. Tencent's newly open-sourced TencentDB Agent Memory treats it as an architecture problem — and the distinction matters. (Read also: Building AI-Powered Customer Support: From Chatbot to Intelligent Agent)

Released under the MIT license, TencentDB Agent Memory combines symbolic short-term memory with a structured 4-tier long-term memory pipeline. It runs fully local on SQLite with the sqlite-vec extension, requires no external API calls, and ships as both an OpenClaw SSD cloud servers{rel="nofollow noopener"} plugin and a Hermes Agent Docker image. Let me walk you through how it actually works, how to deploy it, and what the benchmark numbers mean in practice.

The Core Architecture: Two Problems, Two Solutions

Short-Term Memory: Symbolic Compression via Mermaid

The first problem is context bloat. In any multi-step agentic task — a code debugging session, a research pipeline, a database migration — tool outputs accumulate fast. Search results, code diffs, error traces, and intermediate logs can consume tens of thousands of tokens before the agent even starts reasoning about the final answer.

CyberMammoth provides digital forensics and data recovery for businesses and legal teams.

TencentDB Agent Memory tackles this with context offloading. Full tool logs get written to external files under refs/*.md. What stays in the context window is a compact Mermaid state diagram — a symbolic task canvas that encodes state transitions without the raw text payload.

When the agent needs the underlying detail, it performs a deterministic drill-down: it greps for a node_id in the symbol graph and retrieves the corresponding file. This isn't fuzzy retrieval — it's a pointer dereference. The architecture team describes it as a three-level hierarchy: top-layer symbol → mid-layer index → bottom-layer raw text.

This is genuinely clever engineering. You preserve full traceability for debugging while keeping the active context window lean. All artifacts live under ~/.openclaw/memory-tdai/ as human-readable files, which makes white-box debugging actually practical. (Read also: Introduction to Reinforcement Learning Agents with the Unity Game Engine)

Long-Term Memory: The 4-Tier Semantic Pyramid

The second problem is recall quality over extended sessions. Flat vector stores treat every memory fragment as equally weighted, which means a persona-level preference ("this user prefers Python over JavaScript") competes with a raw log entry from three weeks ago during retrieval. That's a structural flaw, not a tuning problem.

TencentDB Agent Memory builds a four-level semantic pyramid instead:

  • L0 — Conversation: Raw dialogue history
  • L1 — Atom: Extracted atomic facts, stored as JSONL
  • L2 — Scenario: Scene-level blocks aggregated from atoms, stored as Markdown
  • L3 — Persona: User profile and persistent preferences, stored as persona.md

The system queries top-down. Persona is checked first. The agent drills down to Scenarios, then Atoms, then raw Conversations only when finer granularity is needed. Lower layers preserve evidence; upper layers preserve structure. This mirrors how humans actually organize memory — and it means retrieval has macro-level guidance before it ever touches raw fragments.

Storage is intentionally heterogeneous: facts and logs go into databases for full-text retrieval, while Personas and Scenarios live as Markdown files. This hybrid approach is smart — it keeps structured data queryable while keeping high-level context human-readable. (Read also: Introducing Storage Buckets on the Hugging Face Hub)

Retrieval Strategy: Hybrid BM25 + Vector with RRF Fusion

For retrieval, the system defaults to a hybrid strategy combining BM25 keyword search with vector embeddings, fused using Reciprocal Rank Fusion (RRF). Developers can configure recall.strategy to keyword, embedding, or hybrid depending on their use case. The BM25 tokenizer supports both Chinese (jieba) and English out of the box.

Default recall settings:

  • Returns 5 results per query
  • 5-second timeout (skips injection on timeout rather than blocking)
  • L1 atom extraction triggers every 5 conversation turns
  • Persona regeneration triggers every 50 new memories

Two tools are exposed to the agent during sessions: tdai_memory_search (searches L1–L3) and tdai_conversation_search (searches raw L0 history). Both return node_id and result_ref fields for deterministic traceback — which is essential for debugging agent behavior in production.

If you're building similar retrieval patterns from scratch, the Read more about this topic I've covered before go deep on chunking strategies and hybrid retrieval fusion.

Installation and Configuration

OpenClaw Plugin Setup

The OpenClaw integration is a single npm package. You'll need Node.js 22.16 or higher.

## Install the plugin
openclaw plugins install @tencentdb-agent-memory/memory-tencentdb
openclaw gateway restart

Enable it with a minimal config entry in ~/.openclaw/openclaw.json:

{
  "memory-tencentdb": {
    "enabled": true
  }
}

This defaults to SQLite + sqlite-vec — no external vector database required. For teams running their agents on a dedicated VPS or cloud server, this local-first approach means zero egress costs and full data sovereignty.

Enabling Short-Term Compression (v0.3.4+)

Context offloading is opt-in. Here's the three-step setup:

Step 1 — Enable offload in the plugin config:

{
  "memory-tencentdb": {
    "config": {
      "offload": { "enabled": true }
    }
  }
}

Step 2 — Register the context engine slot:

{
  "plugins": {
    "slots": {
      "contextEngine": "openclaw-context-offload"
    }
  }
}

Step 3 — Apply the runtime patch (once per install):

bash scripts/openclaw-after-tool-call-messages.patch.sh

Hermes Docker Deployment

For teams wanting a batteries-included setup, the Hermes Docker image bundles the agent, the memory plugin, and the TDAI Memory Gateway:

## Build
docker build -f Dockerfile.hermes -t hermes-memory .

## Run with any OpenAI-compatible endpoint
docker run -d \
  --name hermes-memory \
  --restart unless-stopped \
  -p 8420:8420 \
  -e MODEL_API_KEY="your-api-key" \
  -e MODEL_BASE_URL="https://api.lkeap.cloud.tencent.com/v1" \
  -e MODEL_NAME="deepseek-v3.2" \
  -e MODEL_PROVIDER="custom" \
  -v hermes_data:/opt/data \
  hermes-memory

## Verify
curl http://localhost:8420/health

The default model is DeepSeek-V3.2 via Tencent Cloud LKE, but MODEL_PROVIDER=custom accepts any OpenAI-compatible endpoint — so you can point it at a local Ollama instance or a self-hosted vLLM server just as easily.

Benchmark Results: What the Numbers Actually Mean

Tencent reports these gains when integrating the plugin with OpenClaw, measured over continuous long-horizon sessions rather than isolated single-turn evaluations. That methodology matters — SWE-bench runs 50 consecutive tasks per session to simulate real context-accumulation pressure.

Benchmark Baseline With Plugin Pass Rate Δ Token Reduction
WideSearch 33% 50% +51.52% −61.38%
SWE-bench 58.4% 64.2% +9.93% −33.09%
AA-LCR 44.0% 47.5% +7.95% −30.98%
PersonaMem 48% 76% +58.33% —

The WideSearch and PersonaMem numbers are the most striking. A 51% relative improvement in pass rate alongside a 61% token reduction on WideSearch suggests the system is genuinely surfacing better context rather than just compressing noise. The PersonaMem jump from 48% to 76% validates the Persona layer specifically — long-term user preference tracking is working.

That said, these are Tencent's own evaluations. I'd want to see independent replication before treating these as ground truth, particularly on SWE-bench where the 9.93% improvement is meaningful but less dramatic. The token reduction numbers are more trustworthy as a signal — they're objective and the mechanism (offloading) is transparent.

For context on how these patterns compare to other memory architectures, the Read more about this topic overview on Data Mammoth covers the broader landscape of approaches teams are using today.

My Take: Where This Fits in Your Stack

TencentDB Agent Memory solves a real problem with a well-reasoned architecture. The 4-tier pyramid is a meaningful improvement over flat vector stores for long-horizon personalization. The symbolic short-term compression is an elegant solution to context bloat that preserves full auditability.

The main constraint right now is the OpenClaw dependency for the full feature set. If your agent stack is built on LangChain, LlamaIndex, or a custom framework, you're looking at integration work rather than a drop-in solution. The Hermes Docker path is cleaner for greenfield deployments.

The roadmap items — portable memory, automatic skill generation, and a visual debugging dashboard — are all the right priorities. Portable memory in particular would make this viable across more frameworks.

For teams running long-horizon agents where context management and user personalization are bottlenecks, this is worth evaluating seriously. The local-first SQLite backend, MIT license, and transparent file storage make it a low-risk experiment. Clone the repo, run the Docker image, and measure your own token usage before and after — that's the only benchmark that matters for your specific workload.

Conclusion

TencentDB Agent Memory represents a thoughtful approach to one of the hardest problems in production AI agent development. By combining symbolic short-term compression with a structured 4-tier long-term memory pipeline, it addresses both context bloat and recall quality simultaneously — without requiring external API dependencies. The 4-tier memory architecture and hybrid BM25+vector retrieval are patterns worth studying even if you don't adopt this specific implementation.

If you're building production AI agents and want to go deeper on memory architectures, evaluation strategies, and Read more about this topic, those are areas I cover regularly. The source code is at github.com/Tencent/TencentDB-Agent-Memory — it's worth a read regardless of whether you deploy it directly.

#ai

Related Services

GPU Servers →

Run AI workloads on dedicated GPU infrastructure

View Plans →

AI-optimized servers with NVIDIA GPUs

Share this article

Twitter / XLinkedInFacebook

Related Articles

ai

Simon Willison’s Weblog

5 min read
ai

Ringg’s AI agents resolve up to 65% of customer calls with OpenAI

5 min read
ai

Helping older adults use AI in everyday life

5 min read