Generative AI

Tencent Open-Sources Memory for TencentDB agent: A 4-tier local memory pipeline for AI Agents

Tencent released TencentDB Agent Memory, an open source memory system for AI agents. The project runs under the MIT license. It addresses a common problem for anyone deploying long-horizon agents: context bloat and recall failure.

It is symbolic short-term memory and superimposed long-term memory. It also integrates OpenClaw as a plugin and Hermes Agent via Gateway adapter. The default backend is local SQLite with the sqlite-vec extension, so no external API is needed.

Why agent memory is difficult

Most current stacks the data into chunks and dump them into a flat vector store. Recall then becomes a uniform blind search for all disconnected pieces, without macro-level manipulation. The architecture relies on two pillars: memory layering and symbolic memory.

Semantic pyramid with 4 levels

With long-term customization, 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. This includes raw dialogue, atomic facts, scenes, and user profiles.

The Persona layer holds the user's daily preferences and is queried first. The system pulls down to raw Atoms or Conversations only when less detail is needed. The lower layers store evidence; the upper layers maintain the structure.

Storage is not the same. Facts, logs, and traces are persisted to databases for full-text retrieval. People, scenes, and canvases are saved as human-readable Markdown files. Layered memory artifacts reside underneath ~/.openclaw/memory-tdai/.

A short memory of a Mermaid

Long-running agent jobs consume tokens by using verbose tool logs, search results, code, and error tracing. TencentDB agent memory addresses this by decontextualizing in combination with virtual memory.

Full tool logs are uploaded to the external files below refs/*.md. State changes are coded in Mermaid syntax within a lightweight task canvas. The agent places reasons over the symbol graph in its content window.

If it needs raw text, it greps for a node_id and finds the corresponding file. The Tencent dev team describes this as a deterministic pull-down from the top layer symbol to the middle layer index to the raw text of the lower layers.

Benchmark numbers

Results are measured in continuous sessions over a long horizon, not individual curves. The SWE bench, for example, runs 50 consecutive jobs per session to simulate stress accumulation.

In WideSearch, combining the plugin with OpenClaw increases the pass rate from 33% to 50%, a relative improvement of 51.52%. The usage of tokens decreased from 221.31M to 85.64M, a decrease of 61.38%.

On the SWE bench, success increases from 58.4% to 64.2% while tokens fall from 3474.1M to 2375.4M, a decrease of 33.09%. For AA-LCR, the success rate went from 44.0% to 47.5%. Tokens decreased from 112.0M to 77.3M, a decrease of 30.98%.

For long-term memory, PersonaMem's accuracy increases from 48% to 76%. Note: these numbers are from Tencent's research.

Also remember to give back

Recovery is automatic in a hybrid strategy. The program combines BM25 keyword search and vector embedding, combined using Reciprocal Rank Fusion (RRF). Developers can switch to pure keyword or embedding mode by using the edit field. The BM25 tokenizer supports both Chinese (jieba) and English.

The default settings trigger the L1 memory release every five turns. A user's persona is generated every 50 new memories. Recall automatically recalls five items with a 5 second timeout. During shutdown, the system skips the injection rather than blocking the conversation.

Installation and developer environment

OpenClaw integration is shipped as a single npm package: @tencentdb-agent-memory/memory-tencentdb. The project requires Node.js 22.16 or higher. Enabling it takes one configuration flag. The plugin then handles conversation capture, memory extraction, scene synthesis, character generation, and recall.

For Hermes, a Docker image includes an agent, a plugin, and a TDAI Memory Gateway. The default model is DeepSeek-V3.2 for Tencent Cloud. Any OpenAI compatible endpoint works with MODEL_PROVIDER=custom the flag.

Two tools are exposed to agents during a session: tdai_memory_search again tdai_conversation_search. Both return references with node_id again result_ref tracking fields. The Tencent Cloud Vector Database (TCVDB) backend is also available as a local SQLite alternative.

Marktechpost Visual Explainer



TencentDB agent memory – Preview

01 / VIEWING

What is TencentDB Agent Memory?

An MIT-licensed memory system for AI agents that combines symbolic short-term memory with a 4-pipeline long-term memory. It works fully natively with no external API dependencies.

Short-term memory

It loads the verbose tool logs into files and saves a unified Mermaid canvas in the context.

Long-term memory

It distributes conversations into a 4-tier semantic pyramid: L0 → L1 → L2 → L3.

The background of the place

Defaults to SQLite + sqlite-vec. Tencent Cloud Vector Database (TCVDB) is preferred.

Integration

It ships as an OpenClaw plugin and a Hermes Agent Docker image.

02 / ARCHITECTURE

Semantic pyramid with 4 levels

Long-term memory is layered, not flat. The upper layers carry the structure; the lower layers store the evidence.

L3 · HumanUser profile (persona.md)

L2 · ConditionMarkdown blocks

L1 · AtomAtomic Facts (JSONL)

L0 · DiscussionRaw chat

Drop-down menu: Persona → Status → Atom → Conversation. Use of references node_id again result_ref for deterministic traceback.

03 / SHORT SHORT

Mermaid work canvas + content loading

Verbose intermediate logs are the biggest token buyers for long runs. The plugin extracts them from disk and stores a high-density symbol graph in the context.

How does this work

  • Full tool logs are uploaded to refs/*.md under the data list.
  • State changes are coded in Mermaid syntax within a lightweight task canvas.
  • The agent reasons over the symbol graph, and greps a node_id to extract the raw text.

How to save to disk: ~/.openclaw/memory-tdai/. All artifacts are human readable to eliminate the white box error.

04 / ENTER

Install the OpenClaw plugin

Requires Node.js 22.16 or higher and installation of OpenClaw.


openclaw plugins install @tencentdb-agent-memory/memory-tencentdb
openclaw gateway restart

Enable Zero-config

Add the following to ~/.openclaw/openclaw.json to open it automatically SQLite + sqlite-vec.

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

05 / PREPARATION

Daily tuning parameters

Every field has a logical default. The most common knots are listed below.

The field Default Explanation
storeBackend sqlite Storage background
recall.strategy a mixture keyword / embed / hybrid (RRF)
recall.maxResults 5 Items returned for each recall
recall.timeoutMs 5000 Skip the injection during the shutdown
pipeline.everyNConversations 5 Release of L1 every turn of N
persona.triggerEveryN 50 Generate a persona with all N memories
offload.enabled lies Changing short-term stress

06 / SHORT-TERM COMPRESSION

Enable Mermaid download (v0.3.4+)

Three steps to unlock content uploading for long-term horizon jobs.

Step 1 · Enable upload in plugin config

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

Step 2 · Register a domain for OpenClaw to submit extraction requests

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

Step 3 · Install the runtime patch (along with the OpenClaw installation)

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

07 / HERMES DOCKER

Run memory-enabled Hermes in one container

A single Docker image includes the Hermes Agent, the memory_tencentdb plugin, and the TDAI Memory Gateway.


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


docker run -d 
  --name hermes-memory 
  --restart unless-stopped 
  -p 8420:8420 
  -e MODEL_API_KEY="your-api-key" 
  -e MODEL_BASE_URL=" 
  -e MODEL_NAME="deepseek-v3.2" 
  -e MODEL_PROVIDER="custom" 
  -v hermes_data:/opt/data 
  hermes-memory


curl 

Any endpoint compatible with OpenAI works MODEL_PROVIDER=custom. Memory data continues to hermes_data capacity.

08 / TOOLS OF AGENCY AND REMEMBERING

What the agent sees

Two tools are exposed to the agent during a session. Recall uses BM25 + vector + RRF fusion by default.

tdai_memory_search

Search in L1 Atoms, L2 Scenarios, and L3 Persona.

tdai_conversation_search

Search L0 raw chat history.

Automatic retrieval

  • Hybrid strategy: BM25 keyword + vector embedding, combined with Reciprocal Rank Fusion.
  • BM25 tokenizer supports Chinese (jieba) and English.
  • Returns 5 items per recall; 5000 ms timeout; during shutdown it skips the injection.
  • References include node_id again result_ref following the trail.

09 / SCRIPTURES

Reported benefits with OpenClaw

It is measured over long time horizon continuous sessions, not single curves. The SWE bench runs 50 consecutive jobs per session.

Benchmark The foundation With a plugin Δ Pass Δ Tokens
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% +59%

The numbers come from Tencent's testing and show the integration with OpenClaw.

10 / THINGS

Where will you go next

Documentation, source code, and community channels.

Source code

github.com/Tencent/TencentDB-Agent-Memory

npm package

@tencentdb-agent-memory/memory-tencentdb

A road map

Portable memory, automatic Skill generation, debugging dashboard.

Chosen by Company MARKTECHPOST · AI Research, Built for Builders

Key Takeaways

  • TencentDB Agent Memory is Tencent's open source (MIT) memory system for AI agents, built on a symbolic short-term memory and long-term memory pipeline with zero external API.
  • Long-term memory is structured as a 4-tier semantic pyramid (L0 Conversation → L1 Atom → L2 Scenario → L3 Persona), with drill-down through node_id again result_ref instead of remembering the flat vector.
  • The temporary memory outputs verbose tool logs to him refs/*.md and keeps only the unified Mermaid canvas of work in context, cutting the use of tokens while maintaining full traceability.
  • Reported benefits when combined with OpenClaw: WideSearch pass rate 33% → 50% with token reduction 61.38%, SWE bench 58.4% → 64.2%, AA-LCR 44.0% → 47.5%, and PersonaMem accuracy → 76% →
  • It ships as a single npm plugin for OpenClaw and a Docker image for Hermes, with local SQLite + sqlite-vec by default, mixed retrieval of BM25 + vector + RRF, and a Tencent Cloud Vector Database (TCVDB) backend.

Check it out Repo. Also, feel free to follow us Twitter and don't forget to join our 150k+ ML SubReddit and Subscribe to Our newspaper. Wait! are you on telegram? now you can join us on telegram too.

Need to work with us on developing your GitHub Repo OR Hug Face Page OR Product Release OR Webinar etc.? contact us


Michal Sutter is a data science expert with a Master of Science in Data Science from the University of Padova. With a strong foundation in statistical analysis, machine learning, and data engineering, Michal excels at turning complex data sets into actionable insights.

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button