{"id":968,"date":"2026-05-24T03:31:12","date_gmt":"2026-05-23T19:31:12","guid":{"rendered":"https:\/\/connectword.dpdns.org\/?p=968"},"modified":"2026-05-24T03:31:12","modified_gmt":"2026-05-23T19:31:12","slug":"tencent-open-sources-tencentdb-agent-memory-a-4-tier-local-memory-pipeline-for-ai-agents","status":"publish","type":"post","link":"https:\/\/connectword.dpdns.org\/?p=968","title":{"rendered":"Tencent Open-Sources TencentDB Agent Memory: A 4-Tier Local Memory Pipeline for AI Agents"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Tencent has released <a href=\"https:\/\/github.com\/Tencent\/TencentDB-Agent-Memory\/tree\/main\" target=\"_blank\" rel=\"noreferrer noopener\">TencentDB Agent Memory<\/a>, an open-source memory system for AI agents. The project ships under the MIT license. It targets a problem familiar to anyone shipping long-horizon agents: context bloat and recall failure.<\/p>\n<p class=\"wp-block-paragraph\">It is symbolic short-term memory along with layered long-term memory. It integrates with OpenClaw as a plugin and with the Hermes Agent through a Gateway adapter. The default backend is local SQLite with the sqlite-vec extension, so no external API is required.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Why agent memory is hard<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">Most current memory stacks shred data into fragments and dump them into a flat vector store. Recall then becomes a blind similarity search across disconnected fragments, with no macro-level guidance. The architecture rests on two pillars: memory layering and symbolic memory.<\/p>\n<h2 class=\"wp-block-heading\"><strong>A 4-tier semantic pyramid<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">For long-term personalization, TencentDB Agent Memory builds a four-level pyramid instead of a flat log. The layers are L0 Conversation, L1 Atom, L2 Scenario, and L3 Persona. These correspond to raw dialogue, atomic facts, scene blocks, and a user profile.<\/p>\n<p class=\"wp-block-paragraph\">The Persona layer carries day-to-day user preferences and is queried first. The system drills down to Atoms or raw Conversations only when finer detail is needed. Lower layers preserve evidence; upper layers preserve structure.<\/p>\n<p class=\"wp-block-paragraph\">Storage is heterogeneous. Facts, logs, and traces are persisted in databases for full-text retrieval. Personas, scenes, and canvases are stored as human-readable Markdown files. Layered memory artifacts live under <code>~\/.openclaw\/memory-tdai\/<\/code>.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Symbolic short-term memory via Mermaid<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">Long-running agent tasks consume tokens through verbose tool logs, search results, code, and error traces. TencentDB Agent Memory addresses this through context offloading combined with symbolic memory.<\/p>\n<p class=\"wp-block-paragraph\">Full tool logs are offloaded to external files under <code>refs\/*.md<\/code>. State transitions are encoded in Mermaid syntax inside a lightweight task canvas. The agent reasons over the symbol graph in its context window.<\/p>\n<p class=\"wp-block-paragraph\">When it needs the raw text, it greps for a <code>node_id<\/code> and retrieves the corresponding file. The Tencent dev team describes this as a deterministic drill-down from top-layer symbol to mid-layer index to bottom-layer raw text.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Benchmark numbers<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">Results are measured over continuous long-horizon sessions, not isolated turns. SWE-bench, for example, runs 50 consecutive tasks per session to simulate context-accumulation pressure.<\/p>\n<p class=\"wp-block-paragraph\">On WideSearch, integrating the plugin with OpenClaw raises pass rate from 33% to 50%, a 51.52% relative improvement. Token usage drops from 221.31M to 85.64M, a 61.38% reduction.<\/p>\n<p class=\"wp-block-paragraph\">On SWE-bench, success climbs from 58.4% to 64.2% while tokens fall from 3474.1M to 2375.4M, a 33.09% reduction. On AA-LCR, the success rate moves from 44.0% to 47.5%. Tokens drop from 112.0M to 77.3M, a 30.98% reduction.<\/p>\n<p class=\"wp-block-paragraph\">For long-term memory, PersonaMem accuracy rises from 48% to 76%. Note: these numbers come from Tencent\u2019s own evaluations.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Recall and retrieval<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">Retrieval defaults to a hybrid strategy. The system combines BM25 keyword search with vector embeddings, fused using Reciprocal Rank Fusion (RRF). Developers can switch to pure <code>keyword<\/code> or <code>embedding<\/code> mode through a config field. The BM25 tokenizer supports both Chinese (jieba) and English.<\/p>\n<p class=\"wp-block-paragraph\">Default settings trigger an L1 memory extraction every five turns. A user persona is generated every 50 new memories. Recall returns five items by default with a 5-second timeout. On timeout, the system skips injection rather than blocking the conversation.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Installation and developer surface<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">The OpenClaw integration ships as a single npm package: <code>@tencentdb-agent-memory\/memory-tencentdb<\/code>. The project requires Node.js 22.16 or higher. Enabling it takes one config flag. The plugin then handles conversation capture, memory extraction, scene aggregation, persona generation, and recall.<\/p>\n<p class=\"wp-block-paragraph\">For Hermes, a Docker image bundles the agent, the plugin, and the TDAI Memory Gateway. The default model is Tencent Cloud\u2019s DeepSeek-V3.2. Any OpenAI-compatible endpoint works through the <code>MODEL_PROVIDER=custom<\/code> flag.<\/p>\n<p class=\"wp-block-paragraph\">Two tools are exposed to agents during a session: <code>tdai_memory_search<\/code> and <code>tdai_conversation_search<\/code>. Both return references with <code>node_id<\/code> and <code>result_ref<\/code> fields for traceback. A Tencent Cloud Vector Database (TCVDB) backend is also available as an alternative to local SQLite.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Marktechpost\u2019s Visual Explainer<\/strong><\/h2>\n<p><title>TencentDB Agent Memory \u2014 Preview<\/title><\/p>\n<div>\n<div class=\"tg-header\">\n<p class=\"tg-eyebrow\">Open Source \u00a0\/\u00a0 Tencent<\/p>\n<h2 class=\"tg-title\">TencentDB Agent Memory<\/h2>\n<p class=\"tg-subtitle\">A quick-start guide to fully local, 4-tier long-term memory for AI agents.<\/p>\n<\/div>\n<p><span class=\"tg-step-line\"><\/span><\/p>\n<div class=\"tg-stage\">\n<div class=\"tg-slides\">\n<div class=\"tg-slide active\" data-slide=\"1\">\n<p class=\"tg-slide-num\">01 \u00a0\/\u00a0 OVERVIEW<\/p>\n<h3 class=\"tg-slide-title\">What is TencentDB Agent Memory?<\/h3>\n<p class=\"tg-slide-lead\">An MIT-licensed memory system for AI agents that combines symbolic short-term memory with a 4-tier long-term memory pipeline. Runs fully local with zero external API dependencies.<\/p>\n<div class=\"tg-grid-2\">\n<div class=\"tg-card\">\n<h5>Short-term memory<\/h5>\n<p>Offloads verbose tool logs to files and keeps a compact Mermaid task canvas in context.<\/p>\n<\/div>\n<div class=\"tg-card\">\n<h5>Long-term memory<\/h5>\n<p>Distills conversations into a 4-tier semantic pyramid: L0 \u2192 L1 \u2192 L2 \u2192 L3.<\/p>\n<\/div>\n<div class=\"tg-card\">\n<h5>Local backend<\/h5>\n<p>Defaults to SQLite + sqlite-vec. Tencent Cloud Vector Database (TCVDB) is optional.<\/p>\n<\/div>\n<div class=\"tg-card\">\n<h5>Integrations<\/h5>\n<p>Ships as an OpenClaw plugin and a Hermes Agent Docker image.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"2\">\n<p class=\"tg-slide-num\">02 \u00a0\/\u00a0 ARCHITECTURE<\/p>\n<h3 class=\"tg-slide-title\">The 4-Tier Semantic Pyramid<\/h3>\n<p class=\"tg-slide-lead\">Long-term memory is layered, not flat. Upper layers carry structure; lower layers preserve evidence.<\/p>\n<div class=\"tg-pyramid\">\n<div class=\"tg-layer tg-layer-l3\"><span class=\"tg-layer-name\">L3 \u00b7 Persona<\/span><span class=\"tg-layer-desc\">User profile (persona.md)<\/span><\/div>\n<div class=\"tg-layer tg-layer-l2\"><span class=\"tg-layer-name\">L2 \u00b7 Scenario<\/span><span class=\"tg-layer-desc\">Scene blocks (Markdown)<\/span><\/div>\n<div class=\"tg-layer tg-layer-l1\"><span class=\"tg-layer-name\">L1 \u00b7 Atom<\/span><span class=\"tg-layer-desc\">Atomic facts (JSONL)<\/span><\/div>\n<div class=\"tg-layer tg-layer-l0\"><span class=\"tg-layer-name\">L0 \u00b7 Conversation<\/span><span class=\"tg-layer-desc\">Raw dialogue<\/span><\/div>\n<\/div>\n<div class=\"tg-callout\">Drill-down path: Persona \u2192 Scenario \u2192 Atom \u2192 Conversation. References use <code>node_id<\/code> and <code>result_ref<\/code> for deterministic traceback.<\/div>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"3\">\n<p class=\"tg-slide-num\">03 \u00a0\/\u00a0 SYMBOLIC SHORT-TERM<\/p>\n<h3 class=\"tg-slide-title\">Mermaid task canvas + context offloading<\/h3>\n<p class=\"tg-slide-lead\">Verbose intermediate logs are the largest token consumers in long tasks. The plugin offloads them to disk and keeps a high-density symbol graph in context.<\/p>\n<div class=\"tg-section\">\n<h4>How it works<\/h4>\n<ul>\n<li>Full tool logs are offloaded to <code>refs\/*.md<\/code> under the data directory.<\/li>\n<li>State transitions are encoded in Mermaid syntax inside a lightweight task canvas.<\/li>\n<li>The agent reasons over the symbol graph, then greps a <code>node_id<\/code> to pull raw text.<\/li>\n<\/ul>\n<\/div>\n<div class=\"tg-callout\">Storage path on disk: <code>~\/.openclaw\/memory-tdai\/<\/code>. All artifacts are human-readable for white-box debugging.<\/div>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"4\">\n<p class=\"tg-slide-num\">04 \u00a0\/\u00a0 INSTALL<\/p>\n<h3 class=\"tg-slide-title\">Install the OpenClaw plugin<\/h3>\n<p class=\"tg-slide-lead\">Requires Node.js 22.16 or higher and an OpenClaw installation.<\/p>\n<pre><code><span class=\"tg-comment\"># Install the npm package as an OpenClaw plugin<\/span>\nopenclaw plugins install @tencentdb-agent-memory\/memory-tencentdb\nopenclaw gateway restart<\/code><\/pre>\n<div class=\"tg-section\">\n<h4>Zero-config enable<\/h4>\n<p>Add the following to <code>~\/.openclaw\/openclaw.json<\/code> to turn it on with default SQLite + sqlite-vec.<\/p>\n<\/div>\n<pre><code>{\n  \"memory-tencentdb\": {\n    \"enabled\": true\n  }\n}<\/code><\/pre>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"5\">\n<p class=\"tg-slide-num\">05 \u00a0\/\u00a0 CONFIGURATION<\/p>\n<h3 class=\"tg-slide-title\">Daily-tuning parameters<\/h3>\n<p class=\"tg-slide-lead\">Every field has a sensible default. The most common knobs are listed below.<\/p>\n<div class=\"tg-table-wrap\">\n<table>\n<thead>\n<tr>\n<th>Field<\/th>\n<th>Default<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>storeBackend<\/code><\/td>\n<td>sqlite<\/td>\n<td>Storage backend<\/td>\n<\/tr>\n<tr>\n<td><code>recall.strategy<\/code><\/td>\n<td>hybrid<\/td>\n<td>keyword \/ embedding \/ hybrid (RRF)<\/td>\n<\/tr>\n<tr>\n<td><code>recall.maxResults<\/code><\/td>\n<td>5<\/td>\n<td>Items returned per recall<\/td>\n<\/tr>\n<tr>\n<td><code>recall.timeoutMs<\/code><\/td>\n<td>5000<\/td>\n<td>Skip injection on timeout<\/td>\n<\/tr>\n<tr>\n<td><code>pipeline.everyNConversations<\/code><\/td>\n<td>5<\/td>\n<td>L1 extraction every N turns<\/td>\n<\/tr>\n<tr>\n<td><code>persona.triggerEveryN<\/code><\/td>\n<td>50<\/td>\n<td>Generate persona every N memories<\/td>\n<\/tr>\n<tr>\n<td><code>offload.enabled<\/code><\/td>\n<td>false<\/td>\n<td>Short-term compression toggle<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"6\">\n<p class=\"tg-slide-num\">06 \u00a0\/\u00a0 SHORT-TERM COMPRESSION<\/p>\n<h3 class=\"tg-slide-title\">Enable Mermaid offloading (v0.3.4+)<\/h3>\n<p class=\"tg-slide-lead\">Three steps to turn on context offload for long-horizon tasks.<\/p>\n<div class=\"tg-section\">\n<h4>Step 1 \u00b7 Enable offload in plugin config<\/h4>\n<\/div>\n<pre><code>{\n  \"memory-tencentdb\": {\n    \"config\": {\n      \"offload\": { \"enabled\": true }\n    }\n  }\n}<\/code><\/pre>\n<div class=\"tg-section\">\n<h4>Step 2 \u00b7 Register the slot so OpenClaw routes offload requests<\/h4>\n<\/div>\n<pre><code>{\n  \"plugins\": {\n    \"slots\": {\n      \"contextEngine\": \"openclaw-context-offload\"\n    }\n  }\n}<\/code><\/pre>\n<div class=\"tg-section\">\n<h4>Step 3 \u00b7 Apply the runtime patch (once per OpenClaw install)<\/h4>\n<\/div>\n<pre><code>bash scripts\/openclaw-after-tool-call-messages.patch.sh<\/code><\/pre>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"7\">\n<p class=\"tg-slide-num\">07 \u00a0\/\u00a0 HERMES DOCKER<\/p>\n<h3 class=\"tg-slide-title\">Run memory-enabled Hermes in one container<\/h3>\n<p class=\"tg-slide-lead\">A single Docker image bundles Hermes Agent, the memory_tencentdb plugin, and the TDAI Memory Gateway.<\/p>\n<pre><code><span class=\"tg-comment\"># Build the image<\/span>\ndocker build -f Dockerfile.hermes -t hermes-memory .\n\n<span class=\"tg-comment\"># Run the container (default model: DeepSeek-V3.2 on Tencent Cloud LKE)<\/span>\ndocker run -d \n  --name hermes-memory \n  --restart unless-stopped \n  -p 8420:8420 \n  -e MODEL_API_KEY=\"your-api-key\" \n  -e MODEL_BASE_URL=\"https:\/\/api.lkeap.cloud.tencent.com\/v1\" \n  -e MODEL_NAME=\"deepseek-v3.2\" \n  -e MODEL_PROVIDER=\"custom\" \n  -v hermes_data:\/opt\/data \n  hermes-memory\n\n<span class=\"tg-comment\"># Health check<\/span>\ncurl http:\/\/localhost:8420\/health<\/code><\/pre>\n<div class=\"tg-callout\">Any OpenAI-compatible endpoint works through <code>MODEL_PROVIDER=custom<\/code>. Memory data persists in the <code>hermes_data<\/code> volume.<\/div>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"8\">\n<p class=\"tg-slide-num\">08 \u00a0\/\u00a0 AGENT TOOLS &amp; RECALL<\/p>\n<h3 class=\"tg-slide-title\">What the agent sees<\/h3>\n<p class=\"tg-slide-lead\">Two tools are exposed to the agent during a session. Recall uses BM25 + vector + RRF fusion by default.<\/p>\n<div class=\"tg-grid-2\">\n<div class=\"tg-card\">\n<h5>tdai_memory_search<\/h5>\n<p>Search across L1 Atoms, L2 Scenarios, and L3 Persona.<\/p>\n<\/div>\n<div class=\"tg-card\">\n<h5>tdai_conversation_search<\/h5>\n<p>Search raw L0 Conversation history.<\/p>\n<\/div>\n<\/div>\n<div class=\"tg-section\">\n<h4>Retrieval defaults<\/h4>\n<ul>\n<li>Hybrid strategy: BM25 keyword + vector embedding, fused via Reciprocal Rank Fusion.<\/li>\n<li>BM25 tokenizer supports Chinese (jieba) and English.<\/li>\n<li>Returns 5 items per recall; 5000 ms timeout; on timeout it skips injection.<\/li>\n<li>References include <code>node_id<\/code> and <code>result_ref<\/code> for traceback.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"9\">\n<p class=\"tg-slide-num\">09 \u00a0\/\u00a0 BENCHMARKS<\/p>\n<h3 class=\"tg-slide-title\">Reported gains with OpenClaw<\/h3>\n<p class=\"tg-slide-lead\">Measured over continuous long-horizon sessions, not isolated turns. SWE-bench runs 50 consecutive tasks per session.<\/p>\n<div class=\"tg-table-wrap\">\n<table>\n<thead>\n<tr>\n<th>Benchmark<\/th>\n<th>Baseline<\/th>\n<th>With Plugin<\/th>\n<th>\u0394 Pass<\/th>\n<th>\u0394 Tokens<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>WideSearch<\/td>\n<td>33%<\/td>\n<td>50%<\/td>\n<td>+51.52%<\/td>\n<td>\u221261.38%<\/td>\n<\/tr>\n<tr>\n<td>SWE-bench<\/td>\n<td>58.4%<\/td>\n<td>64.2%<\/td>\n<td>+9.93%<\/td>\n<td>\u221233.09%<\/td>\n<\/tr>\n<tr>\n<td>AA-LCR<\/td>\n<td>44.0%<\/td>\n<td>47.5%<\/td>\n<td>+7.95%<\/td>\n<td>\u221230.98%<\/td>\n<\/tr>\n<tr>\n<td>PersonaMem<\/td>\n<td>48%<\/td>\n<td>76%<\/td>\n<td>+59%<\/td>\n<td>\u2014<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"tg-callout\">Numbers come from Tencent\u2019s own evaluations and reflect the integration with OpenClaw.<\/div>\n<\/div>\n<div class=\"tg-slide\" data-slide=\"10\">\n<p class=\"tg-slide-num\">10 \u00a0\/\u00a0 RESOURCES<\/p>\n<h3 class=\"tg-slide-title\">Where to go next<\/h3>\n<p class=\"tg-slide-lead\">Documentation, source code, and community channels.<\/p>\n<div class=\"tg-grid-2\">\n<div class=\"tg-card\">\n<h5>Source code<\/h5>\n<p>github.com\/Tencent\/TencentDB-Agent-Memory<\/p>\n<\/div>\n<div class=\"tg-card\">\n<h5>npm package<\/h5>\n<p>@tencentdb-agent-memory\/memory-tencentdb<\/p>\n<\/div>\n<div class=\"tg-card\">\n<h5>License<\/h5>\n<p>MIT<\/p>\n<\/div>\n<div class=\"tg-card\">\n<h5>Roadmap<\/h5>\n<p>Portable memory, automatic Skill generation, visual debugging dashboard.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><span class=\"tg-step-line\"><\/span><\/p>\n<div class=\"tg-controls\">\n<div class=\"tg-dots\"><\/div>\n<div class=\"tg-nav\">\n<button class=\"tg-btn\" aria-label=\"Previous slide\">\u2039<\/button><br \/>\n<span class=\"tg-counter\">01 \/ 10<\/span><br \/>\n<button class=\"tg-btn\" aria-label=\"Next slide\">\u203a<\/button>\n<\/div>\n<\/div>\n<p><span class=\"tg-step-line\"><\/span><\/p>\n<div class=\"tg-tagline\">\n<p class=\"tg-tagline-text\">Curated by <strong>MARKTECHPOST<\/strong> \u00a0\u00b7\u00a0 AI Research, Engineered for Builders<\/p>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Tencent has released TencentDB&hellip;<\/p>\n","protected":false},"author":1,"featured_media":29,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-968","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts\/968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=968"}],"version-history":[{"count":0,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts\/968\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/media\/29"}],"wp:attachment":[{"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}