How TencentDB Agent Memory Stores and Distributes Experience Across Agent Sessions

TencentDB Agent Memory uses a central Memory Hub backed by SQLite to capture agent outputs, then distributes accumulated knowledge to new sessions via session filters and real-time pub/sub streams.

TencentDB Agent Memory implements a closed-loop system to store and distribute experience across agent sessions, ensuring every interaction contributes to a collective knowledge base. The architecture centers on a Memory Hub that persists agent assets to SQLite and streams updates to active sessions. This design enables fresh agents to inherit team history without cold-start penalties, as implemented in the TencentCloud/TencentDB-Agent-Memory repository.

The Central Memory Hub Architecture

The Memory Hub serves as the coordination layer for all experience assets. Implemented in MemoryCore/index.ts, this service hosts the SQLite database, exposes REST APIs, and manages session lifecycles. When agents generate knowledge—whether conversation logs, code snippets, or tool results—the hub writes these assets to durable storage and broadcasts changes to the fleet.

SQLite Persistence Layer

All experience data resides in a SQLite database managed by MemoryKnowledge/src/store/sqlite-store.ts. This module provides the low-level persistence layer for wiki pages, LLM bindings, and code-graph data. By centralizing storage in SQLite, the system ensures ACID compliance and portable backups for all accumulated agent knowledge.

Session Routing and Filtering

Not every session requires access to the entire knowledge base. The MemoryCore/src/utils/session-filter.ts module computes which assets belong to a specific agent session, enabling selective loading. When a new session initializes, the filter queries the SQLite store and extracts only the relevant historical context, reducing memory overhead and improving startup latency.

Real-Time Distribution Mechanism

Distribution extends beyond initial session setup. The system maintains long-lived connections to push incremental updates, ensuring active sessions stay synchronized with the latest team knowledge.

The Offload Server Pub/Sub System

The MemoryCore/src/offload_server/router.ts implements a lightweight publish/subscribe mechanism built on the offload server architecture. This component handles long-running tasks and streams incremental updates to connected agents. When one agent creates a new skill or updates a wiki page, the offload server pushes the change to all subscribed sessions in real time.

Auto-Sync Scheduling

To prevent data loss during network partitions or hub restarts, MemoryKnowledge/src/store/auto-sync-scheduler.ts periodically synchronizes the local SQLite cache with the central hub. This scheduler runs background tasks that reconcile state differences, ensuring every session operates on a consistent, up-to-date view of the experience database.

The Experience Lifecycle

The system orchestrates a four-phase lifecycle for experience management: capture, persist, distribute, and reuse.

Capture via REST APIs

As agents work, they persist assets to the hub via REST endpoints exposed in MemoryCore/index.ts. Key routes include /api/wiki for documentation pages and /api/llm-binding for model configuration artifacts. These endpoints validate and queue incoming data before committing to the SQLite store.

Session Inheritance and Reuse

When an agent starts a new session, it reads the latest snapshot from the hub based on the session filter criteria. The session instantly inherits the team's accumulated distilled executable experience—previously generated skills and validated procedures—enabling cold-start friendly operation. Agents can query this inherited knowledge to embed reusable skills directly into their execution pipelines without retraining.

Implementation Example

The following TypeScript demonstrates how to interact with the Memory Hub to store and retrieve experience:

// Initialize a Memory-Hub client (using the official TS SDK)
import { MemoryClient } from '@tencentdb/memory-core';
const mem = new MemoryClient({ baseURL: 'http://localhost:8080' });

// Save a piece of experience (e.g., a wiki page)
await mem.wiki.save({
  id: 'page-123',
  title: 'How to upgrade MySQL',
  content: 'Step‑by‑step upgrade guide …',
  tags: ['upgrade', 'mysql'],
});

// Load the latest experience when a new session starts
const sessionId = 'session-abc';
const assets = await mem.session.load(sessionId);   // uses session-filter internally
console.log('Inherited assets:', assets);

// Subscribe to real‑time updates (offload server pushes)
mem.session.subscribe(sessionId, update => {
  console.log('Live update:', update);
});

Summary

Frequently Asked Questions

What storage backend does TencentDB Agent Memory use for experience data?

The system uses SQLite as its primary durable store, implemented in MemoryKnowledge/src/store/sqlite-store.ts. This backend persists all experience assets including wiki pages, LLM bindings, and code-graph data, providing ACID guarantees and efficient local querying for session filters.

How does the system distribute updates to active agent sessions?

Active sessions receive updates through the offload server (MemoryCore/src/offload_server/router.ts), which implements a pub/sub streaming mechanism. When new experience is captured via /api/wiki or /api/llm-binding, the hub pushes incremental changes to all subscribed sessions, ensuring real-time synchronization without polling overhead.

Can newly created sessions access historical team experience immediately?

Yes. When a new session initializes, the session filter (MemoryCore/src/utils/session-filter.ts) queries the SQLite store and loads the latest relevant snapshot. This cold-start friendly design allows fresh agents to inherit distilled executable skills and historical context instantly, without requiring retraining or manual data migration.

Where is the session-specific asset selection logic implemented?

The asset selection logic resides in MemoryCore/src/utils/session-filter.ts. This module computes which rows from the central SQLite database belong to a given session ID, enabling selective loading that minimizes bandwidth and memory consumption for individual agents.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →