# How to Implement Cold-Start by Importing Existing Codebases and Documents in TencentDB Agent Memory

> Implement cold-start in TencentDB Agent Memory by importing codebases and documents. Give new agents full context from the start for faster, more informed interactions. Learn how now.

- Repository: [Tencent Cloud/TencentDB-Agent-Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory)
- Tags: how-to-guide
- Published: 2026-08-26

---

**You implement cold-start in TencentDB Agent Memory by importing existing codebases, documentation, and chat histories into the Memory Hub, then binding these pre-indexed assets to new agents so they start with full context instead of an empty state.**

TencentDB Agent Memory provides a comprehensive architecture to implement cold-start by importing existing codebases and documents through its centralized Memory Hub. The system ingests repositories as symbol-level CodeGraph indexes, documentation as searchable Wiki pages, and historical conversations as layered Chat Memory, allowing new agents to begin operation with immediate access to institutional knowledge rather than starting from scratch.

## Understanding the Memory Hub Architecture

The cold-start capability relies on four core components that work together to ingest, store, and serve imported assets.

### MemoryKnowledge (Knowledge Service)

**MemoryKnowledge** provides the **Wiki** (structured documents) and **CodeGraph** (symbol-level code index) functionality. When you import a repository or document set, this service builds searchable graphs and pages while the Hub records the resulting asset IDs. The core orchestration logic resides in [`MemoryKnowledge/src/module.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/module.ts), which assembles the Wiki engine, CodeGraph builder, and processing queues.

### MemoryCore

**MemoryCore** stores **Chat Memory** and **Skills** extracted from past sessions. According to [`MemoryCore/v3-api-memorycore-doc.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/v3-api-memorycore-doc.md), when you upload conversation logs, the service parses them into **L0-L3 memory layers**—ranging from raw logs to summarized facts—making them ready for immediate retrieval by new agents.

### MemoryProxy and Memory Hub Panel

The **MemoryProxy** acts as a uniform HTTP gateway that exposes a single `/v3` API surface. All agents call this endpoint, and the proxy forwards requests to Knowledge Service, Core, or Panel based on asset type. The **Memory Hub Panel** serves as the central UI and ACL-aware registry, holding metadata (owner, visibility, version) and orchestrating the binding of assets to agents during the cold-start sequence described in [`README.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/README.md) (lines 39-50).

## Step-by-Step Cold-Start Implementation

Follow this sequence to populate a new agent with existing knowledge assets.

### 1. Prepare the Environment

Start the three required services (Panel, Knowledge Service, and Core) using the provided deployment scripts. Copy the example environment files and configure your LLM parameters and ports before launching.

```bash
git clone https://github.com/TencentCloud/TencentDB-Agent-Memory.git
cd TencentDB-Agent-Memory/deploy/global-images
cp .env.example .env

# Edit .env to set LLM params, ports, etc.

./start-all.sh

```

### 2. Import Codebases via CodeGraph

Use the Knowledge Service API to clone a repository and build the symbol graph. As implemented in [`MemoryKnowledge/src/store/code-graph-service.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/code-graph-service.ts), the `codegraph_import` tool analyzes the codebase and creates an index.

```bash
curl -X POST http://localhost:8421/v3/tools/call \
     -H "Content-Type: application/json" \
     -d '{"tool":"codegraph_import","params":{"repo":"https://github.com/your/project.git"}}'

```

The service returns a `codeGraphId` that is automatically registered with the Panel. This identifier allows O(1) symbol lookups without on-the-fly parsing.

### 3. Import Documentation via Wiki

Upload markdown, PDF, or plain-text files to create searchable Wiki pages. The ingestion logic in [`MemoryKnowledge/src/store/wiki-service.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/wiki-service.ts) extracts structured pages and link graphs.

```bash
curl -X POST http://localhost:8421/v3/tools/call \
     -H "Content-Type: application/json" \
     -d '{"tool":"wiki_import","params":{"url":"https://example.com/docs.zip"}}'

```

The response contains a `wikiId` that references the processed documentation asset.

### 4. Import Historical Chat Sessions

Send raw JSON logs to the MemoryCore endpoint to populate the Chat Memory layers. This creates L0 (raw logs), L1 (facts), L2 (summaries), and L3 (high-level insights) storage.

```bash
curl -X POST http://localhost:8123/v3/memory/chat \
     -H "Content-Type: application/json" \
     -d @past_sessions.json

```

### 5. Bind Assets to the New Agent

Specify which `wikiId`, `codeGraphId`, and `chatMemoryId` the agent should load on startup. The ACL-aware binding ensures only authorized agents receive the imported assets.

```bash
curl -X POST http://localhost:8123/v3/agents/assign \
     -H "Content-Type: application/json" \
     -d '{"agentId":"agent-001","assets":["wiki-abc123","codegraph-def456","chat-789"]}'

```

### 6. Launch the Agent

When the agent contacts the MemoryProxy, it receives the bound assets immediately, allowing it to start with full context including pre-indexed code symbols, documentation links, and conversation history.

## Key Source Files and Implementation Details

| File | Purpose |
|------|---------|
| [`README.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/README.md) (lines 39-50) | Describes the cold-start flowchart and UI automation steps |
| [`MemoryKnowledge/README.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/README.md) | Documents Knowledge Service API endpoints and environment configuration |
| [`MemoryKnowledge/src/module.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/module.ts) | Assembles Wiki, CodeGraph, and queue workers for asset ingestion |
| [`MemoryKnowledge/src/store/wiki-service.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/wiki-service.ts) | Implements document parsing and structured page extraction |
| [`MemoryKnowledge/src/store/code-graph-service.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/code-graph-service.ts) | Handles repository cloning and symbol graph construction |
| [`MemoryCore/v3-api-memorycore-doc.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/v3-api-memorycore-doc.md) | Defines Chat Memory API for session import and layer generation |
| [`MemoryProxy/v3-api-memoryproxy-doc.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/v3-api-memoryproxy-doc.md) | Specifies proxy routing logic to backend services |

## Summary

- **Memory Hub** serves as the central registry for all imported assets, enforcing ACL rules during agent binding.
- **CodeGraph** indexes provide O(1) symbol lookups for imported codebases without runtime parsing overhead.
- **Wiki** assets maintain link graphs that enable LLM-driven navigation without scanning entire document sets.
- **L0-L3 Chat Memory layers** preserve facts and preferences across sessions, enabling instant context retrieval.
- The **MemoryProxy** exposes a unified `/v3` API that routes agents to the appropriate backend services (Knowledge Service, Core, or Panel).

## Frequently Asked Questions

### What is the difference between CodeGraph and Wiki assets?

**CodeGraph** assets contain symbol-level indexes of source code (functions, classes, imports) built by [`MemoryKnowledge/src/store/code-graph-service.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/code-graph-service.ts), enabling precise code navigation and context retrieval. **Wiki** assets contain processed documentation with link graphs managed by [`MemoryKnowledge/src/store/wiki-service.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/store/wiki-service.ts), optimized for semantic search and LLM-based question answering.

### How does the system handle access control during cold-start?

The Memory Hub Panel maintains **ACL-aware metadata** for every imported asset (owner, visibility, version). When you bind assets via the `/v3/agents/assign` endpoint, the system verifies permissions before allowing an agent to access the `wikiId`, `codeGraphId`, or `chatMemoryId`, ensuring privacy while enabling knowledge sharing across authorized agents.

### Can I import multiple codebases simultaneously?

Yes. The Knowledge Service processes multiple `codegraph_import` requests concurrently through its queue system defined in [`MemoryKnowledge/src/module.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryKnowledge/src/module.ts). Each repository receives a unique `codeGraphId`, and you can bind multiple IDs to a single agent using the assets array in the assignment call.

### What are the L0-L3 layers in Chat Memory?

According to [`MemoryCore/v3-api-memorycore-doc.md`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/v3-api-memorycore-doc.md), the **L0** layer stores raw conversation logs, **L1** extracts atomic facts, **L2** generates session summaries, and **L3** creates high-level insights across sessions. When you implement cold-start by importing [`past_sessions.json`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/past_sessions.json), the system populates all four layers, allowing new agents to retrieve relevant context at the appropriate granularity.