What Data Is Deleted and Preserved with Asset-Level `clearChatMemory` in TencentDB Agent Memory
Asset-level clearChatMemory deletes all conversational content layers (L0-L3, vectors, and storage files) while preserving asset metadata including memory_id, ownership, ACLs, and bindings.
The TencentDB Agent Memory system implements a precise separation between content and asset identity when clearing chat memory. This design allows agents to perform a clean-slate operation without losing their memory configuration or requiring re-registration. The clear operation is implemented in MemoryCore/src/gateway/chat-memory-handlers.ts and follows a strict "content-only deletion" policy.
What Gets Deleted: All Content Layers
The clearChatMemory operation removes every piece of conversational data through the clearChatMemoryContent → clearProfileStorage pipeline. According to the source code at lines 66-70, the following content is permanently erased:
Layered Memory Contents (L0-L3)
- L0 raw dialogue — Original conversation transcripts and messages
- L1 extracted facts — Structured factual extractions from conversations
- L2 scene blocks — Contextual scene summaries and narrative segments
- L3 profile records — Generated persona and behavioral profiles
Associated Storage and Vectors
The clearProfileStorage function (lines 45-63) enumerates and deletes the entire scoped storage prefix under profiles/<team>:<agent>/.... These files include:
profiles/<team>:<agent>/<memory_id>/
├── persona.md
├── scene_blocks/
└── .metadata/scene_index.json
The function uses createScopedStorageAdapter to achieve scoped deletion of all profile-associated files.
Audit Trail Records
For each cleared layer, the system records a delete audit event via recordClearAudit (lines 112-115). These events log that deletion occurred without retaining the original content, ensuring compliance and traceability.
What Gets Preserved: Asset Metadata and Identity
The top-level comment at lines 4-7 explicitly states the design principle: "clear 只删内容**,不删资产"** ("clear only deletes content, not the asset"). The following remains intact:
| Preserved Element | Purpose |
|---|---|
asset_id / memory_id |
Stable identifier for memory addressability |
| Team/Agent ownership | Organizational binding and attribution |
| ACL rules | Access control permissions (who can read/write) |
| Bindings | Agent-to-memory associations |
| Owner, name, visibility flags | Administrative metadata |
This preservation means subsequent agent writes will reuse the original memory_id without requiring asset recreation. The asset record continues to exist in the metadata service and remains fully addressable.
How to Invoke the Clear Operation
REST API Endpoint
import fetch from "node-fetch";
async function clearChatMemory(memoryIds: string[]) {
const resp = await fetch("https://your-memory-hub/v3/chat-memory/clear", {
method: "POST",
headers: {
"Content-Type": "application/json",
// Admin credentials required (see handler lines 13-16)
Authorization: "Bearer <admin-token>",
"x-tdai-service-id": "<service-id>",
},
body: JSON.stringify({ memory_ids: memoryIds }),
});
const data = await resp.json();
console.log(data);
}
// Clear multiple assets in one call
clearChatMemory(["team1/agentA/memory123", "team2/agentB/memory456"]);
TypeScript SDK
import { MemoryClient } from "@tencentdb/agent-memory-core";
const client = new MemoryClient({ baseUrl: "https://your-memory-hub" });
await client.chatMemory.clear({
memory_ids: ["team1/agentA/memory123"],
});
Both approaches invoke handleChatMemoryClear (lines 50-58), which orchestrates the deletion pipeline while respecting the content-only policy.
Request Flow and Validation
The clear request passes through multiple layers before reaching the core handler:
- MemoryPanel route validation —
MemoryPanel/src/panel/http/routes/chat-memory.tsperforms owner validation and permission checks - Target resolution —
resolveChatMemoryTargets(frommetadata-service.ts) mapsmemory_ids to their team/agent context - Core execution —
chat-memory-handlers.tsexecutesclearChatMemoryContentandclearProfileStorage
This architecture ensures that only authorized callers can trigger asset-level clears, while the core implementation guarantees consistent behavior across all entry points.
Summary
- Deleted: All conversational content (L0-L3), vectors, profile storage files, and associated vectors — achieving a complete memory wipe
- Preserved: Asset identity (
memory_id), ownership, ACLs, bindings, and administrative metadata — enabling seamless continuation - Key benefit: Agents can reset their memory state without reconfiguration or asset re-registration
- Implementation:
clearChatMemoryinMemoryCore/src/gateway/chat-memory-handlers.tsenforces this separation throughclearChatMemoryContentandclearProfileStorage
Frequently Asked Questions
What happens to the memory_id after a clear operation?
The memory_id remains unchanged and valid. Because asset-level clearChatMemory preserves the metadata record, the same identifier can be used for subsequent read and write operations. The agent does not need to create a new memory asset or update any references.
Can I recover data after calling clearChatMemory?
No recovery is possible. The deletion of L0-L3 content and profile storage files is permanent. While audit events record that the clear occurred, they do not retain the original content. Treat clearChatMemory as an irreversible operation.
What's the difference between asset-level clear and content-level clear?
Asset-level clear (the clearChatMemory endpoint) operates on the entire memory asset and its associated storage, removing all layers while preserving metadata. Content-level operations would target specific layers or time ranges. The asset-level operation is atomic and comprehensive, designed for complete memory reset scenarios.
Which credentials are required to call clearChatMemory?
The handler at lines 13-16 indicates that admin-level credentials are required: a Bearer token in the Authorization header and an x-tdai-service-id header. The MemoryPanel route performs additional owner validation before forwarding to the core handler, ensuring only authorized principals can trigger data deletion.
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 →