DocsQuick StartAI News
AI NewsTencent open-sources Agent Memory: reduces token consumption for long tasks by 61%
New Model

Tencent open-sources Agent Memory: reduces token consumption for long tasks by 61%

2026-05-14T09:06:32.934Z
Tencent open-sources Agent Memory: reduces token consumption for long tasks by 61%

Tencent Cloud open-sourced **TencentDB Agent Memory**, which uses context offloading and Mermaid task canvas technology to reduce token consumption by up to 61% in long-task scenarios, while also improving task success rates.

Tencent Open Sources Agent Memory: Reduce Token Usage for Long Tasks by 61%

Today, Tencent Cloud officially open-sourced TencentDB Agent Memory, a memory management system designed for Agent long-task scenarios. In multi-task continuous session experiments, the solution reduced token consumption by up to 61% while improving task success rates in long-task scenarios.

This is not just another “summary compression” tool. The Tencent Cloud Database team used the combination of “context offloading + Mermaid task canvas” to solve the hardest problem for long-task Agents: how to keep a lightweight context while ensuring the Agent knows where it is, what it has done, and what to do next.

The project is open-sourced on GitHub: https://github.com/Tencent/TencentDB-Agent-Memory

The Real Dilemma of Long-Task Agents

Ask an Agent to produce a competitor analysis report. It needs to search product information for competitors A, B, and C, then check each company’s funding dynamics and technical solutions, and finally compile a comparison table. Each search returns roughly 2,000 words of original text, but only a sentence such as “Competitor A recently raised $24 million and focuses on vector search” is truly useful.

By the time it reaches the summary stage, the context already contains tens of thousands of words from search results—mostly ads, irrelevant links, and repetitive content. They take up valuable token space but contribute little to completing the task. Worse, after 20 tool calls, the context is filled with a long linear history. The Agent can see “what it did,” but it’s hard to determine which branches are parallel, which steps have dependencies, and which stage it’s currently in.

This reflects the reality for Agents in code development, web search, and research analysis: task chains get longer, and numerous tool calls, web content, and intermediate results quickly fill the context window, driving up token costs, causing state loss, and lowering reasoning stability.

Mermaid Task Canvas: Give the Agent a Battle Map

The most dangerous thing in a long task isn’t losing information—it’s the Agent not knowing where it is.

Logs are good for recording; maps are good for navigation. The Tencent Cloud Database team used Mermaid Flowcharts to organize task execution processes into a navigable “task canvas.”

Mermaid is a textual diagramming language widely used on GitHub and in technical documentation. Mainstream large models naturally have read/write capabilities for it; it’s in plain text, can be continuously updated, and can be rendered directly for visual inspection. With this canvas, the Agent doesn’t need to memorize everything—it just needs to know what information is important, where it’s organized, and how to expand step by step when needed.

Mermaid task canvas diagram showing task nodes, dependencies, and execution paths

The system maintains an independent Flowchart for each task and manages their presence in the context through “collapse/expand/revive” strategies:

  • Current tasks are fully expanded so the Agent can see the full map at any time
  • Completed tasks are collapsed into a one-line summary and can be expanded when needed
  • Parallel branches are clearly marked on the map to avoid execution confusion

History isn’t compressed into an unrecoverable summary. It becomes an executable map—collapsible yet expandable.

Context Offloading: Save Tokens Without Losing Evidence

The canvas keeps the “structure intact,” but in long tasks, tool outputs, search results, and logs are often lengthy. Keeping them all in context quickly fills the window.

Another core technology of Agent Memory is Context Offloading—offloading complete information to external storage while preserving key states and execution paths as structured task graphs. This keeps the Agent’s context lightweight in long tasks while enabling traceability and recovery of original information layer by layer.

Symbolic Compaction: Convey the Same Information With Fewer Tokens

The first core capability of short-term memory compression is Symbolic Compaction—conveying the same information with fewer tokens. This “compression” works on two levels:

Level 1: Summary Compression — Remove fluff, keep facts.

A search returns 2,000 words, but its information value may just be: “Competitor A raised $24M…” The system extracts that into a structured summary like:

[search done] Competitor A: Funding $24M, Clients 200+ | ref: refs/001-N1.md

Eighty characters capture the essence of 2,000 words—a compression ratio of 25:1. The “ref” points to the original document stored on disk for recall anytime.

Level 2: Structured Storage — The original information isn’t lost, just relocated.

All compressed raw content is stored in external storage (a virtual file system) and linked to nodes on the task canvas through reference pointers. When needed, the Agent can expand step by step to restore full context.

Three-Level Watermark Auto-Trigger

Agent Memory uses a three-level watermark mechanism that automatically triggers different compression levels based on context usage:

  • L0 Original (default): Tool output kept entirely in context
  • L1 Summary (real-time): When context reaches 60% capacity, automatically replace originals with summaries—“mild compression” with minimal information loss
  • L2 Map (asynchronous): The system periodically generates or updates Mermaid task maps from accumulated summaries and injects them into the context. Completed tasks are “collapsed” into summaries; current tasks keep a full map view

The beauty of this mechanism lies in its progressive, reversible, and automatic nature. The Agent doesn’t need to manually manage memory—compression granularity adjusts automatically based on context pressure.

Experimental Data: Token Usage -61%, Accuracy +28%

In multi-task continuous sessions, TencentDB Agent Memory reduced token consumption by up to 61% and improved task success rates in long-task scenarios.

In the Free version, it already implemented a four-layer memory architecture for long-term memory enhancement, increasing total accuracy from 47.85% to 76.10% on the PersonaMem benchmark—an improvement of 28 percentage points.

What’s significant is that this gain didn’t come from sacrificing information integrity. The Agent still accesses all raw data; it just retrieves information “on demand from external storage” rather than “stuffing everything into the context.”

Comparison With Other Solutions: Beyond Compression, Towards Navigation

There are plenty of memory management solutions out there, but most either do summary compression (high information loss) or external storage only (Agent doesn’t know what’s stored).

Take MemMachine for example: it uses a virtual file system and L0/L1/L2 layered on-demand loading to solve external knowledge storage but lacks structured task topology. The Agent knows “which files exist” but not “how they relate or which task stage it’s in.”

TencentDB Agent Memory differentiates itself as follows:

| Dimension | MemMachine | TencentDB Agent Memory | |------------|-------------|------------------------| | Compression | Layered storage | Symbolic compaction + Mermaid task map | | Information Organization | Virtual file system | Structured task topology | | Triggering Mechanism | Manual/rule-based | Three-level auto-trigger | | Traceability | File-level | Node-level + reference pointers |

In short: MemMachine gives the Agent a hard drive, while TencentDB Agent Memory gives it a hard drive + a map + an automatic organizer.

Long-Term Memory Already Live, Short-Term Memory Newly Open-Sourced

It’s worth noting that last month, Tencent Cloud launched the long-term memory capability of TencentDB Agent Memory with free access. The focus of this open-source release is short-term memory compression.

Long-term memory addresses “how an Agent remembers user preferences, interaction history, and domain knowledge.”
Short-term memory compression addresses “how an Agent maintains lightweight context during a single long task.”
Together, they enable the Agent to have both “long-term accumulated wisdom” and “task-level clarity.”

The Pro version is already integrated in the latest ClawPro, where users can go to ClawPro’s management console, click “Memory Management” on the left panel, and enable it quickly.

Memory Systems Becoming Standard for Agents

In the latter half of 2025, a clear trend in AI Agent deployment is emerging: memory systems are becoming standard components.

Recent studies show that efficient memory mechanisms can boost complex task success rates by 30–50%, reduce token usage by 60–90%, and significantly improve personalization and contextual coherence. This shift impacts not only user experience but also directly determines enterprise-level Agent usability.

For example, a general self-evolving Agent needs only a 30k context, cutting token consumption by nearly 90%. It surpasses mainstream Agent systems across dimensions such as task completion, tool efficiency, memory validity, self-evolution, and web browsing—while using fewer tokens and interaction rounds.

By open-sourcing TencentDB Agent Memory, Tencent Cloud is effectively providing the industry with a “reference implementation for memory systems.” It’s not the most complex approach but could be the most practical one—developers can integrate it directly or adapt its design for their own Agent frameworks.

Final Thoughts

The Agent’s memory challenge is, at its core, an engineering problem: how to ensure the Agent sees the big picture while focusing on the present within a limited context window.

Tencent Cloud’s answer: don’t try to cram all information into the context—give the Agent a map so it knows where information is, how to retrieve it, and when it’s needed. It’s not a new idea, but executed very well.

The 61% reduction in token usage wasn’t achieved by sacrificing information integrity—it came from smarter information organization.
That’s what makes this open-source project truly noteworthy.


References

Related Articles

View All

Contact Us

We usually reply quickly during business hours

Scan WeChat

Support: Hub Assistant

WeChat ID: