What Is the MemoryKnowledge Module in TencentDB-Agent-Memory?
The MemoryKnowledge module transforms raw documents, code, and conversation logs into structured, searchable knowledge assets that agents can retrieve on-demand via a unified REST API.
The MemoryKnowledge module serves as the central knowledge engine within the TencentDB-Agent-Memory repository, converting unstructured project artifacts into queryable Memory Assets that power intelligent agent behaviors. By abstracting storage complexities behind a REST-style interface, it enables agents to access Wiki pages, code relationships, and conversation history without knowing the underlying data topology.
Core Purpose and Architecture
The primary function of the MemoryKnowledge module is to bridge raw data sources and agent consumption. When a project is imported, the system initiates a multi-stage pipeline that extracts, structures, and indexes information for immediate retrieval.
Asset Extraction Pipeline
During ingestion, the module parses distinct artifact types into specialized knowledge structures:
- CodeGraph – Built from source code analysis to map symbol relationships and call hierarchies
- Wiki – Generated from documentation to create searchable, rendered markdown pages
- Chat Memory – Extracted from conversation histories to preserve context and decisions
- Skills – Identified reusable operation patterns from agent interactions
These extracted items become Memory Assets with standardized metadata including version, owner, visibility level (private, team, or restricted), and usage analytics.
Layered Storage and Access Control
Each asset persists in a tiered storage system that supports permission-aware retrieval. Before returning any data, the module evaluates ACLs against team, user, and agent contexts, filtering results to ensure private or restricted knowledge remains inaccessible to unauthorized requesters.
Asynchronous Indexing Workflow
Both Wiki generation and CodeGraph indexing execute in background workers to prevent ingestion bottlenecks. Assets transition through explicit states (processing → ready), ensuring agents receive only fully-indexed, consistent information rather than partial or corrupted data.
Unified REST API for Agent Integration
Agents interact with the knowledge base through a REST-style OpenAPI defined in MemoryKnowledge/openapi.yaml, abstracting the underlying storage mechanisms. The endpoints /v3/tools/list and /v3/tools/call provide the primary interface for discovery and execution.
Listing Available Knowledge Tools
Agents first discover capabilities by querying the tool registry:
import axios from 'axios';
async function listTools() {
const resp = await axios.get('http://localhost:8125/v3/tools/list');
console.log(resp.data);
// => [{ name: 'wiki', description: 'search wiki pages' }, …]
}
listTools();
Retrieving Wiki Content
To fetch structured documentation, agents call the Wiki tool with specific query parameters:
import axios from 'axios';
async function getWikiPage(topic: string) {
const resp = await axios.post('http://localhost:8125/v3/tools/call', {
tool: 'wiki',
args: { query: topic }
});
console.log(resp.data.content);
// rendered markdown of the Wiki page
}
getWikiPage('authentication flow');
Querying Code Relationships
The CodeGraph tool exposes symbol-level analysis, such as caller identification:
import axios from 'axios';
async function findCallers(symbol: string) {
const resp = await axios.post('http://localhost:8125/v3/tools/call', {
tool: 'codegraph',
args: { action: 'callers', symbol }
});
console.log('Callers of', symbol, ':', resp.data.callers);
}
findCallers('UserService.createUser');
Key Implementation Files
The MemoryKnowledge module implementation spans several critical files in the TencentDB-Agent-Memory repository:
MemoryKnowledge/src/store/wiki-service.ts– Implements Wiki creation, indexing, and search functionalityMemoryKnowledge/src/telemetry.ts– Emits usage metrics and health data for monitoring the knowledge pipelineMemoryKnowledge/openapi.yaml– Defines the public API specification (/v3/tools/*) used by agents to query knowledge assetsMemoryKnowledge/start.sh– Bootstrap script that initializes the Knowledge serviceMemoryCore/openclaw.plugin.json– Registers the Knowledge service as a plugin within the OpenClaw framework architecture
Benefits for Agent Teams
Implementing the MemoryKnowledge module provides concrete operational advantages:
- Reduced Re-work – Agents reuse previously extracted facts and skills rather than reprocessing raw sources
- Fast Context Bootstrapping – High-level L2/L3 assets load first, with fallback to raw L0/L1 data only when necessary
- Cross-Framework Compatibility – Framework-agnostic assets allow any agent (Claude, DeepSeek, CodeBuddy, etc.) to consume knowledge via the standard API
- Cold-Start Capability – Agents initialize with pre-populated knowledge bases rather than empty context windows
- Continuous Learning – New documents and code commits automatically integrate into the knowledge pool
Summary
- The MemoryKnowledge module converts raw project artifacts into structured, queryable assets called Memory Assets
- It encompasses four primary knowledge types: CodeGraph, Wiki, Chat Memory, and Skills
- Agents access knowledge through a unified REST API (
/v3/tools/list,/v3/tools/call) defined inopenapi.yaml - Permission-aware retrieval enforces ACLs based on visibility levels (
private,team,restricted) - Asynchronous indexing ensures agents receive only fully-processed, consistent data
- Implementation resides primarily in
MemoryKnowledge/src/store/wiki-service.tsand related service files
Frequently Asked Questions
How does the MemoryKnowledge module handle permission control?
The module evaluates access control lists (ACLs) at retrieval time, checking team membership, user identity, and agent authorization against asset metadata. Assets carry visibility flags—private, team, or restricted—and the system filters results accordingly before returning data to the requester.
What types of data can the MemoryKnowledge module index?
According to the source code architecture, the module indexes four primary categories: Code (structured into CodeGraphs), Documentation (rendered as Wiki pages), Conversation Logs (preserved as Chat Memory atoms), and ** reusable Skills** extracted from agent interaction histories.
Is the MemoryKnowledge API synchronous or asynchronous?
While the API endpoints (/v3/tools/call) return synchronous responses to agents, the underlying indexing processes operate asynchronously. Background workers handle Wiki generation and CodeGraph construction, transitioning assets through processing states to ready before they become available for queries.
How do agents discover what knowledge tools are available?
Agents query the /v3/tools/list endpoint to retrieve a catalog of available knowledge tools, including their names and descriptions. This discovery mechanism allows agents to dynamically understand which knowledge domains—Wiki, CodeGraph, or Chat Memory—they can access without hardcoding endpoint paths.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →