# What Is the Purpose of the Memory Agent in TencentDB?

> Discover the purpose of the memory agent in TencentDB. Learn how this open-source platform enhances LLM agents by storing, organizing, and reusing experience for efficient context management and team collaboration.

- Repository: [Tencent Cloud/TencentDB-Agent-Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory)
- Tags: deep-dive
- Published: 2026-08-25

---

**The memory agent in TencentDB (also called Team Memory) is an open-source platform that enables LLM agents to store, organize, and reuse experience across sessions and teams, reducing repetitive context explanation through a four-layer memory pipeline and ACL-aware asset sharing.**

The TencentCloud/TencentDB-Agent-Memory repository implements this system as a modular architecture designed for production deployment. Instead of re-explaining the same context in every prompt, agents retrieve **Chat Memory**, **Skills**, **Wiki** pages, and **CodeGraph** assets extracted from prior conversations, documents, or codebases.

## Three-Tier System Architecture

The memory agent in TencentDB operates through three distinct components that separate storage, API translation, and backend processing.

### Memory Hub

The **Memory Hub** serves as the central server that hosts memory assets, enforces ACL policies, and provides a web-based control panel for team management. According to the repository README, the Hub functions as "a control panel" rather than a simple display board, allowing administrators to configure visibility rules and manage agent teams.

### Memory Proxy

The **Memory Proxy** acts as a thin HTTP gateway that translates standard Agent API calls into Hub-compatible requests. Agents only need to change their base URL to integrate; the proxy handles the translation of `/v3/tools/list` and `/v3/tools/call` endpoints to the Hub's internal APIs. The deployment script [`deploy/panel-knowledge-combined/start-combined.sh`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/deploy/panel-knowledge-combined/start-combined.sh) demonstrates how to launch this component alongside the Core and Hub.

### Memory Core

The **Memory Core** contains the backend ingestion engine defined in [`MemoryCore/src/utils/pipeline-manager.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/src/utils/pipeline-manager.ts). This component processes raw conversation events through a staged pipeline, extracts layered memory assets, and builds searchable indices using utilities like [`MemoryCore/src/utils/text-utils.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/src/utils/text-utils.ts) for Latin and CJK text extraction.

## Layered Memory Pipeline

The memory agent in TencentDB implements a four-layer extraction pipeline that progressively abstracts raw interactions into reusable knowledge assets.

### L0 – Capture

Raw conversation events are buffered by the auto-capture module and passed to the pipeline via `notifyConversation`. This layer maintains a complete audit trail of exact wording and turn-by-turn interactions.

### L1 – Batch Extraction

When a session reaches a configurable conversation count or idle threshold, the pipeline manager invokes `enqueueL1` to schedule processing. The `runL1` method drains the buffer, invokes the L1 runner via `appendEvent`, and advances timers. This layer extracts **fact atoms**, preferences, and discrete events for precise recall.

The implementation includes a **warm-up mode** that gradually lowers the trigger threshold for new sessions (progressing from 1 → 2 → 4 → ... → `everyNConversations`) to process early conversations quickly before settling into steady-state frequency.

### L2 – Scene Extraction

After L1 completion, a downward-only timer triggers the L2 runner to generate higher-level assets such as **Wiki** pages and **CodeGraph** symbols. The `ManagedTimer` class enforces downward-only scheduling, guaranteeing that a session's next extraction can only move earlier, keeping the pipeline deterministic.

The timer respects `delayAfterL1Seconds`, `minIntervalSeconds`, and `maxIntervalSeconds` to balance freshness with resource usage, as implemented in `MemoryPipelineManager` between lines 95-119 of the pipeline manager source.

### L3 – Persona Generation

A global mutex runs the L3 runner to consolidate session-level scenes into long-term **Persona** profiles. These profiles serve as "load-outs" that can be attached to new agents to provide immediate context without requiring conversation history.

## Asset Types and ACL Controls

The memory agent in TencentDB organizes extracted knowledge into four primary asset types, each supporting three visibility levels: `private`, `team`, and `restricted`.

- **Chat Memory**: Persistent records of user preferences, decisions, and factual statements extracted from conversations.
- **Skill**: Versioned, executable snippets including validation rules extracted from successful workflows.
- **Wiki**: Structured documentation pages with link graphs automatically built from markdown, PDFs, and other documents.
- **CodeGraph**: Symbol-level indexes of codebases providing call-graph navigation and impact analysis.

These ACL-aware controls allow teams to share knowledge while protecting sensitive data, enabling scenarios where a "Builder" agent accesses project Wiki and CodeGraph assets while a "Reviewer" agent maintains private evaluation criteria.

## Operational Workflow

Deploying the memory agent in TencentDB follows a standardized sequence that integrates the layered pipeline with agent execution.

First, initialize the full stack using [`./start-all.sh`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/./start-all.sh) (or the combined start script), which launches Memory Core, Hub, and Proxy services. Next, create a team in the Hub UI at `http://localhost:8125` and configure desired assets. Then bind agents to specific memory assets—for example, attaching the project CodeGraph to a "Scout" agent for codebase navigation.

When an agent runs, it contacts the Proxy at the configured base URL; the Proxy forwards tool calls to the Hub, which retrieves appropriate memory assets on demand via the L0-L3 pipeline.

## Key Implementation Details

Several architectural patterns in [`MemoryCore/src/utils/pipeline-manager.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/src/utils/pipeline-manager.ts) ensure reliable operation under concurrent load.

**Serial Queues** (`SerialQueue`) ensure that per-session L1 and L2 jobs run one-at-a-time, preventing race conditions while allowing many sessions to progress concurrently. This is implemented in the pipeline manager's initialization logic (lines 24-27).

**Graceful Shutdown** logic flushes pending L1, L2, and L3 work within a bounded timeout, persisting state to a checkpoint so that restarts can recover unfinished jobs without data loss (lines 117-133).

The **downward-only timer** mechanism guarantees that once scheduled, extraction jobs only move earlier in time, never later, ensuring deterministic processing order for critical memory assets.

## Integration Example

The following TypeScript example demonstrates connecting an LLM agent to the memory system using the official SDK:

```typescript
// Install the client library
npm i @tencentdb-agent-memory/memory-tencentdb

import { AgentClient } from '@tencentdb-agent-memory/memory-tencentdb'

// Initialize with Proxy endpoint
const client = new AgentClient({
  baseURL: 'http://localhost:8125',   // Memory Proxy address
  apiKey: 'YOUR_PROXY_TOKEN',         // Generated in Hub UI
})

// The proxy auto-retrieves relevant memory assets
const response = await client.chat({
  role: 'assistant',
  content: 'Summarize the latest design doc for the payment service.'
})

console.log(response.content)  // May include Skill or Wiki citations

```

The SDK abstracts the `/v3/tools/list` and `/v3/tools/call` translations, allowing existing agents to incorporate TencentDB Agent Memory capabilities by changing only the base URL configuration.

## Summary

- The memory agent in TencentDB (Team Memory) provides persistent, reusable knowledge storage for LLM agents across sessions and teams.
- The architecture separates concerns into **Memory Hub** (storage/ACL), **Memory Proxy** (API translation), and **Memory Core** (processing pipeline).
- A four-layer pipeline (L0-L3) progressively extracts raw conversations into structured assets: Chat Memory, Skills, Wiki pages, and CodeGraph symbols.
- **Serial queues** and **downward-only timers** in [`MemoryCore/src/utils/pipeline-manager.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/src/utils/pipeline-manager.ts) ensure deterministic, race-free processing of memory extractions.
- **ACL-aware assets** support `private`, `team`, and `restricted` visibility levels for secure knowledge sharing.
- Agents integrate via a thin HTTP proxy that requires only a base URL change to existing codebases.

## Frequently Asked Questions

### How does the memory agent in TencentDB reduce LLM token costs?

By storing and retrieving **Chat Memory**, **Skills**, and **Wiki** assets across sessions, agents avoid repeating full context in every prompt. Instead of re-explaining project architecture or user preferences, agents reference compact, pre-extracted knowledge assets, significantly reducing the input token count for subsequent interactions.

### What distinguishes the L2 and L3 memory layers?

**L2 (Scene Extraction)** generates scenario-level knowledge blocks like Wiki pages and CodeGraph symbols shortly after L1 processing completes. **L3 (Persona Generation)** runs less frequently under a global mutex to consolidate these scenes into long-term personality profiles that can be attached to agents as immediate "load-outs" for new sessions.

### Can I deploy the TencentDB memory agent on private infrastructure?

Yes. The repository includes [`deploy/panel-knowledge-combined/start-combined.sh`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/deploy/panel-knowledge-combined/start-combined.sh), which launches the complete stack (Memory Core + Hub + Proxy) for local or private cloud deployment. The system operates independently of Tencent Cloud services once deployed, using Docker or direct Node.js execution.

### Which source files contain the core extraction logic?

The primary extraction pipeline resides in [`MemoryCore/src/utils/pipeline-manager.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/src/utils/pipeline-manager.ts), which implements the L0-L3 runners, warm-up modes, and timer logic. Text processing utilities for search indexing are located in [`MemoryCore/src/utils/text-utils.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/src/utils/text-utils.ts), while ACL configurations and team management UI definitions appear in [`MemoryPanel/README.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryPanel/README.md).