TencentDB-Agent-Memory: a layered memory system that reduces agent token usage via symbolic offloading and semantic pyramids

TencentDB-Agent-Memory: a layered memory system that reduces agent token usage via symbolic offloading and semantic pyramids

What it solves

TencentDB Agent Memory addresses the problem of "context overload" in AI agents. Traditional agents either hoard every single interaction in their context window (consuming massive tokens) or use lossy summarization that destroys detail. This project provides a structured way for agents to remember workflows, user preferences, and task history without repeating themselves or wasting tokens.

How it works

The system uses a layered architecture to move away from "flat" vector storage:

  • Memory Layering: It organizes information into a semantic pyramid. Long-term memory moves from raw conversations (L0) to atomic facts (L1), then to scenario blocks (L2), and finally to a user persona (L3). This allows the agent to use high-level personas for general guidance and "drill down" into raw data only when specific details are needed.
  • Symbolic Short-Term Memory: To handle verbose tool logs (like code or search results), the system offloads the full text to external files and replaces them in the agent's context with a compact Mermaid symbol graph. The agent can then use a node_id to retrieve the original raw text if necessary.
  • Heterogeneous Storage: It uses databases for raw facts and logs (bottom layer) and human-readable Markdown files for personas and scenes (top layer).

Who it’s for

Developers building long-horizon AI agents (using frameworks like OpenClaw or Hermes) who need their agents to maintain consistent personas and task states across long sessions while reducing LLM token costs.

Highlights

  • Significant Token Reduction: Reduces token usage by up to 61.38% in certain benchmarks.
  • Improved Accuracy: Increases PersonaMem accuracy from 48% to 76%.
  • Lossless Recovery: Maintains a deterministic path from high-level abstractions back to the original raw evidence.
  • Integration Ready: Provides plugins for OpenClaw and Hermes agents.

Sources