How to Read and Write L3 Core/Persona Data in TencentDB Agent Memory

To read and write L3 core (persona) data, instantiate a MemoryClient with team_id, agent_id, and user_id—no session_id required—then call read_core() or write_core(content) to access long-term user profiles.

L3 core data represents persistent persona information stored independently of any conversation session in the TencentDB Agent Memory system. Unlike L1 (session memory) or L2 (cross-session memory), this layer maintains a durable profile bound to a team-agent-user triplet. The SDK enforces this isolation automatically, making L3 operations straightforward once the client is properly configured.

Understanding L3 Core Data Isolation

L3 data isolation relies on three mandatory identifiers supplied at MemoryClient instantiation:

  • team_id – The organizational team context
  • agent_id – The specific AI agent
  • user_id – The end user profile

These values populate the isolation context via self._iso.base_body() in sdk/memory-core/python/tencentdb_agent_memory/v3/client.pyIsolation context】. The implementation deliberately excludes session_id, confirming that L3 operations are session-agnostic.

Internally, all L3 requests target /v3/core/* endpoints with the isolation triplet attached in the POST body. This design is documented as the "strict-isolation data-plane" in the TypeScript SDK【TS SDK – L3 methods】.

Reading L3 Core Data with read_core()

The read_core() method retrieves the current persona JSON stored for the configured triplet.

Python Implementation

In sdk/memory-core/python/tencentdb_agent_memory/v3/client.py, read_core() sends a POST to /v3/core/read with the base isolation body【Python client – read_core】:

from tencentdb_agent_memory.v3.client import MemoryClient

client = MemoryClient(
    endpoint="http://127.0.0.1:8420",
    api_key="YOUR_API_KEY",
    service_id="mem-instance-1",
    team_id="team-123",
    agent_id="agent-abc",
    user_id="user-xyz",
)

persona = client.read_core()
print("Current persona:", persona)

TypeScript Implementation

The TypeScript SDK provides readCore() with identical semantics in sdk/memory-core/typescript/src/v3/client.tsTS client – L3】:

import { MemoryClient } from "@tencentdb-agent-memory/memory-sdk-ts-v2";

const client = new MemoryClient({
  endpoint: "http://127.0.0.1:8420",
  apiKey: "YOUR_API_KEY",
  serviceId: "mem-instance-1",
  teamId: "team-123",
  agentId: "agent-abc",
  userId: "user-xyz",
});

client.readCore().then((data) => console.log("Persona:", data));

Writing L3 Core Data with write_core()

The write_core(content) method replaces the entire L3 persona with new content. This is a full overwrite operation, not a merge or patch.

Python write_core() Usage

From sdk/memory-core/python/tencentdb_agent_memory/v3/client.pyPython client – write_core】:

new_content = """
{
  "name": "Alice",
  "preferences": {
    "language": "en",
    "timezone": "Asia/Shanghai"
  },
  "goals": ["increase productivity", "learn Go"]
}
"""
write_res = client.write_core(new_content)
print("Write response:", write_res)

TypeScript writeCore() Usage

const coreContent = JSON.stringify({
  name: "Bob",
  interests: ["cloud computing", "AI"],
  lastActive: "2026-09-01",
});
client.writeCore(coreContent).then((res) => console.log("Write result:", res));

Important: The content parameter accepts a string representation of the persona. While JSON is the typical format, the API contract does not enforce schema validation at the SDK level—structure consistency is the caller's responsibility.

Key Differences: L3 vs. L1/L2 Memory Layers

Aspect L3 Core/Persona L1/L2 Memory
Session dependency None – no session_id required Required for L1; optional for L2
Isolation context team_id + agent_id + user_id Same triplet, plus session_id for L1
Data scope Long-term user profile Conversation history (L1) or cross-session summaries (L2)
Endpoints /v3/core/* /v3/memory/*

This distinction is explicit in the TypeScript SDK README, which segregates L3 methods into their own "strict-isolation data-plane" section【TS SDK – L3 table】.

Critical Implementation Files

These source files define the complete L3 read/write pipeline:

Summary

  • L3 core data stores persistent persona profiles tied to team_id, agent_id, and user_id—never to a session.

  • Use read_core() (Python) or readCore() (TypeScript) to fetch the current persona via POST /v3/core/read.

  • Use write_core(content) or writeCore(content) to replace the persona via POST /v3/core/write.

  • No session_id parameter exists for L3 operations—attempting to include one will not affect the request behavior.

  • Both SDKs implement the same strict-isolation data-plane contract, ensuring consistent behavior across Python and TypeScript environments.

Frequently Asked Questions

Can I update only part of an L3 persona without overwriting everything?

No. The write_core operation performs a full replacement of the stored persona. To make partial updates, read the current value, modify the desired fields in your application code, then write the complete updated content back.

What happens if I provide a session_id when creating the MemoryClient for L3 operations?

The L3 methods ignore session_id entirely. The isolation context built by base_body() in sdk/memory-core/python/tencentdb_agent_memory/v3/client.py includes only team_id, agent_id, and user_idIsolation context】. Including a session_id in the client constructor has no effect on L3 reads or writes.

Is there a size limit for L3 core content?

The source analysis does not specify enforced limits. However, because L3 stores long-term profile data rather than conversation history, keep persona JSON reasonably sized—typically under 100KB—for optimal retrieval performance. Consult your specific TencentDB Agent Memory deployment documentation for hard limits.

Can multiple agents share the same L3 persona?

No. The agent_id is a mandatory isolation component. Each team-agent-user triplet maintains a distinct L3 namespace. To share persona data across agents for the same user, you must implement that logic at the application layer by reading from one agent's L3 and writing to another's.

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 →