# TencentDB Agent Memory: Enhancing AI Agents with Layered Long-Term Memory

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/tencentcloud-tencentdb-agent-memory
Generated for open source discovery and AI-assisted research.

TencentDB Agent Memory provides AI agents with fully local, long-term memory through a 4-tier progressive pipeline, eliminating external API dependencies. It significantly reduces token usage and improves task success rates by employing symbolic short-term memory and layered long-term memory. This innovative approach helps agents learn workflows and retain context more effectively.

GitHub: https://github.com/TencentCloud/TencentDB-Agent-Memory
OSRepos URL: https://osrepos.com/repo/tencentcloud-tencentdb-agent-memory

## Summary

TencentDB Agent Memory provides AI agents with fully local, long-term memory through a 4-tier progressive pipeline, eliminating external API dependencies. It significantly reduces token usage and improves task success rates by employing symbolic short-term memory and layered long-term memory. This innovative approach helps agents learn workflows and retain context more effectively.

## Topics

- AI Agent
- Long-Term Memory
- LLM
- TypeScript
- Vector Search
- OpenClaw Plugin
- Hermes Agent
- Local-First AI

## Repository Information

Last analyzed by OSRepos: Tue Jul 07 2026 01:33:07 GMT+0100 (Western European Summer Time)
Detail views: 4
GitHub clicks: 1

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

TencentDB Agent Memory is an advanced solution designed to equip AI agents with robust, fully local long-term memory capabilities. It introduces a novel 4-tier progressive pipeline, ensuring zero external API dependencies for memory management. This project addresses critical challenges in AI agent performance, particularly in reducing token consumption and enhancing task success rates over long-horizon sessions. By moving beyond flat storage, TencentDB Agent Memory enables agents to remember, learn, and reason more effectively.

## Installation

The project supports integration with OpenClaw and Hermes agents.

### For OpenClaw:

1.  **Install the plugin:**
    bash
    openclaw plugins install @tencentdb-agent-memory/memory-tencentdb
    openclaw gateway restart
    
2.  **Enable zero-config:**
    Add the following to `~/.openclaw/openclaw.json`:
    c
    // ~/.openclaw/openclaw.json
    {
      "memory-tencentdb": {
        "enabled": true
      }
    }
    
3.  **Enable short-term compression (optional, requires version ? 0.3.4):**
    First, update `~/.openclaw/openclaw.json` to enable offloading:
    c
    {
      "memory-tencentdb": {
        "config": {
          "offload": {
            "enabled": true
          }
        }
      }
    }
    
    Then, register the slot in your plugin config:
    c
    {
      "plugins": {
        "slots": {
          "contextEngine": "memory-tencentdb"
        }
      }
    }
    
    Finally, apply the runtime patch:
    bash
    bash scripts/openclaw-after-tool-call-messages.patch.sh
    

### For Hermes:

There are two main ways to integrate with Hermes:

*   **Docker (greenfield, requires version ? 0.3.4):**
    Navigate to the `docker/opensource` directory in the cloned repository.
    Build the Docker image:
    bash
    docker build -f Dockerfile.hermes -t hermes-memory .
    
    Run the container, replacing `your-api-key` with your actual key:
    bash
    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 the Gateway:
    bash
    curl http://localhost:8420/health
    
    Enter the Hermes interactive shell:
    bash
    docker exec -it hermes-memory hermes
    

*   **Attach to Existing Hermes (No Docker):**
    1.  Download the plugin package:
        bash
        mkdir -p ~/.memory-tencentdb
        TEMP_DIR=$(mktemp -d)
        cd "$TEMP_DIR"
        npm init -y --silent
        npm install @tencentdb-agent-memory/memory-tencentdb@latest --omit=dev
        cp -r node_modules/@tencentdb-agent-memory/memory-tencentdb \
              ~/.memory-tencentdb/tdai-memory-openclaw-plugin
        rm -rf "$TEMP_DIR"
        
    2.  Install Gateway dependencies:
        bash
        cd ~/.memory-tencentdb/tdai-memory-openclaw-plugin
        npm install --omit=dev
        npm install tsx
        
    3.  Link to the Hermes plugin directory:
        bash
        rm -rf ~/.hermes/hermes-agent/plugins/memory/memory_tencentdb
        ln -sf ~/.memory-tencentdb/tdai-memory-openclaw-plugin/hermes-plugin/memory/memory_tencentdb \
               ~/.hermes/hermes-agent/plugins/memory/memory_tencentdb
        
    4.  Declare the provider in `~/.hermes/config.yaml`:
        yaml
        memory:
          provider: memory_tencentdb
        
    5.  Configure Gateway environment variables in `~/.hermes/.env`:
        bash
        MEMORY_TENCENTDB_GATEWAY_CMD="sh -c 'cd ~/.memory-tencentdb/tdai-memory-openclaw-plugin && exec npx tsx src/gateway/server.ts'"
        MEMORY_TENCENTDB_GATEWAY_HOST="127.0.0.1"
        MEMORY_TENCENTDB_GATEWAY_PORT="8420"
        TDAI_LLM_API_KEY="sk-your-api-key-here"
        TDAI_LLM_BASE_URL="https://api.openai.com/v1"
        TDAI_LLM_MODEL="gpt-4o"
        
    6.  Start the Gateway (auto-discovery or manual run):
        bash
        cd ~/.memory-tencentdb/tdai-memory-openclaw-plugin
        npx tsx src/gateway/server.ts
        
    7.  Verify:
        bash
        curl http://127.0.0.1:8420/health
        

## Examples

The project's README includes video demonstrations showcasing TencentDB Agent Memory in action with both OpenClaw and Hermes. These demos visually illustrate how the memory system enhances agent performance, particularly in handling complex, long-horizon tasks and maintaining context.

*   [OpenClaw × Agent Memory Demo](https://github.com/user-attachments/assets/09c64a2c-9997-42c0-90a3-a15e250cfa43){:target="_blank"}
*   [Hermes × Agent Memory Demo](https://github.com/user-attachments/assets/69045512-e75f-4c84-99dd-52ffa6e9e317){:target="_blank"}

## Why Use TencentDB Agent Memory

TencentDB Agent Memory offers significant advantages for AI agents, moving beyond traditional flat memory systems. Its core technologies, memory layering and symbolic memory, provide a robust framework for improved agent performance.

*   **Reduced Token Usage and Improved Success Rates:** By offloading heavy tool logs and condensing information into compact Mermaid symbols, the system drastically cuts token usage, achieving up to a 61.38% reduction. This leads to a substantial increase in task success rates, with benchmarks showing a 51.52% relative improvement in some scenarios.
*   **Layered Long-Term Memory:** Instead of fragmented vector stores, it distills conversations into a semantic pyramid, from raw dialogue (L0) to atomic facts (L1), scene blocks (L2), and user personas (L3). This hierarchical structure ensures that agents remember what's important and can drill down for details when necessary.
*   **Symbolic Short-Term Memory:** Task state transitions are encoded using high-density Mermaid syntax. This allows agents to reason over a concise symbol graph, while full logs are offloaded, maintaining full traceability via `node_id` for detail retrieval.
*   **White-Box Debuggability:** Unlike opaque memory systems, TencentDB Agent Memory keeps key intermediates as readable files. Scenario blocks are Markdown, personas are in `persona.md`, and task canvases are Mermaid, making debugging a transparent process from high-level abstractions to ground-truth evidence.
*   **Production-Ready Engineering:** The project is designed for real-world applications, offering an OpenClaw plugin, Hermes Gateway adapter, local SQLite backend with `sqlite-vec`, and hybrid retrieval (BM25 + vector + RRF) for both keyword and semantic recall.

## Links

*   **GitHub Repository:** [TencentCloud/TencentDB-Agent-Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory){:target="_blank"}
*   **GitHub Issues:** [Report bugs or ask questions](https://github.com/Tencent/TencentDB-Agent-Memory/issues){:target="_blank"}
*   **GitHub Discussions:** [Share ideas and engage with the community](https://github.com/Tencent/TencentDB-Agent-Memory/discussions){:target="_blank"}
*   **Discord Community:** [Join the chat](https://discord.gg/kDtHb5RW2){:target="_blank"}