How to Implement Cross-Agent Memory Sharing Without Exposing Private Data
TencentDB Agent Memory enables secure cross-agent memory sharing by separating asset storage from access control, using visibility flags (private, team, restricted) and ACL checks to ensure agents reference shared data without copying sensitive information.
Cross-agent memory sharing allows AI agents to collaborate using shared knowledge bases while maintaining strict privacy boundaries. In the TencentDB Agent Memory architecture, this is achieved through a decoupled design where memory assets remain single-source-of-truth records, and access is governed by visibility flags and Access Control Lists (ACL). This approach ensures that private data never leaves its protective boundary while enabling seamless team-wide collaboration.
Understanding the Asset Visibility Model
The foundation of secure sharing lies in the asset manifest schema defined in MemoryCore/src/utils/manifest.ts. Each memory asset—whether Chat Memory, Skill, Wiki, or CodeGraph—carries a visibility field that determines its discovery scope.
The three visibility levels are:
- private: Accessible only to the owner; ACL checks are bypassed entirely, ensuring complete isolation
- team: Discoverable by all members of the same team without explicit grants
- restricted: Requires explicit ACL entries for access, enabling fine-grained control
When an asset is created, it defaults to private, ensuring that sensitive data remains invisible to other agents until explicitly shared.
Enforcing Access Control with ACL
For fine-grained permissions beyond team-wide sharing, the platform implements an ACL service. Every read or write request passes through the acl/check endpoint implemented in MemoryProxy/src/tdai/client.ts (lines 329-353).
The validation process checks a user/agent/team tuple against the requested action (read, write, assign, etc.). The ACL service defaults to "deny" unless an explicit grant exists. For restricted visibility assets, the system requires specific ACL entries, while private assets skip ACL validation entirely, guaranteeing owner-exclusive access.
According to MemoryPanel/src/panel/domain/chat-memory-governance.ts, the memory_shared_with_team flag serves as an additional guard, only allowing reads when the flag is true or a valid ACL entry is present.
Step-by-Step Implementation
Step 1: Define Asset Visibility
To share an asset with your team, update the visibility field from private to team. This is handled via the meta service API endpoint /v3/meta/asset/update.
In the UI layer (MemoryPanel/web/src/pages/SkillsPage/components/SkillsPanel.tsx), this corresponds to toggling the "Share" switch, which triggers the visibility update.
// Update a Skill to be team-shared using the SDK
import { SkillClient } from '@tencentdb-agent-memory/memory-sdk-ts/v3';
const client = new SkillClient({
endpoint: 'https://memory.tencentyun.com',
apiKey: '…',
serviceId: 'svc-1'
});
await client.update({
skill_id: 'skill-123',
// Switch visibility from "private" to "team"
visibility: 'team',
});
Step 2: Grant Explicit ACL Permissions (Optional)
For restricted visibility or specific user access, use the acl/grant endpoint defined in MemoryPanel/src/panel/api/meta-api.openapi.yaml. The grant payload specifies:
subject_type:user,agent, orrolesubject_id: The specific identifierpermission:read,write, etc.effect:allowordeny
// Grant read permission to a specific teammate via ACL
import { MetadataClient } from '@tencentdb-agent-memory/memory-sdk-ts/v3';
const meta = new MetadataClient({
endpoint: 'https://memory.tencentyun.com',
apiKey: '…',
serviceId: 'svc-1'
});
await meta.grantAcl({
asset_id: 'skill-123',
subject_type: 'user',
subject_id: 'user-456', // teammate's user ID
permission: 'read',
effect: 'allow',
});
# CURL example for ACL grant (raw HTTP)
curl -X POST https://memory.tencentyun.com/v3/meta/acl/grant \
-H "Authorization: Bearer <api-key>" \
-H "Content-Type: application/json" \
-d '{
"asset_id":"skill-123",
"subject_type":"user",
"subject_id":"user-456",
"permission":"read",
"effect":"allow",
"granted_by":"owner-id"
}'
Step 3: Bind Shared Assets to Agents
Agents do not duplicate shared data. Instead, they store references (memory_id or skill_id) that point to the shared asset. When an agent requests the asset, MemoryProxy/src/workbuddyHandler.ts extracts the bound asset IDs and forwards the request to retrieve the same storage row.
This reference-based architecture ensures that updates propagate instantly to all consumers without creating data copies that could leak private information.
// Agent code that reads a shared Chat Memory
import { MemoryClient } from '@tencentdb-agent-memory/memory-sdk-ts/v3';
const mem = new MemoryClient({
endpoint: 'https://memory.tencentyun.com',
apiKey: '…',
serviceId: 'svc-1'
});
const history = await mem.getChatMemory({
memory_id: 'chat_memory-team-xyz', // shared ID
});
Key Source Files
Understanding the implementation requires familiarity with these critical components:
- Asset manifest & visibility:
MemoryCore/src/utils/manifest.ts— Defines thevisibilityfield that drives team sharing - ACL client (check):
MemoryProxy/src/tdai/client.ts— Performsacl/checkbefore any asset read/write (lines 329-353) - ACL service definition:
MemoryPanel/src/panel/api/meta-api.openapi.yaml— OpenAPI spec foracl/grant,acl/check, etc. - Agent-side binding:
MemoryProxy/src/workbuddyHandler.ts— Retrieves bound asset IDs for an agent and forwards the request - Governance logic:
MemoryPanel/src/panel/domain/chat-memory-governance.ts— Determines read permission based onmemory_shared_with_teamflag and ACL - UI toggle for sharing:
MemoryPanel/web/src/pages/SkillsPage/components/SkillsPanel.tsx— Provides the "Share" switch that updates visibility
Summary
- Visibility flags (
private,team,restricted) determine asset discoverability at creation time inMemoryCore/src/utils/manifest.ts - ACL enforcement via
MemoryProxy/src/tdai/client.tsvalidates every request against explicit grants or team membership - Reference-based binding ensures agents share pointers rather than data copies, preventing private data duplication
- Private assets bypass ACL checks entirely, guaranteeing owner-exclusive access regardless of other permissions
- Team sharing requires only a visibility update, while restricted sharing uses granular ACL grants via
acl/grant
Frequently Asked Questions
How does TencentDB Agent Memory prevent private data leakage during cross-agent sharing?
Private data leakage is prevented through a layered defense strategy. Assets default to visibility: private, which skips ACL checks entirely and restricts access to the owner. When sharing is enabled, agents receive only references (memory_id) to the shared asset rather than data copies, ensuring the actual storage row remains controlled by the platform's ACL service in MemoryProxy/src/tdai/client.ts.
What is the difference between team visibility and restricted visibility?
Team visibility makes an asset automatically discoverable to all members of the same team without requiring individual ACL entries. Restricted visibility hides the asset from team members unless explicitly granted access via the acl/grant endpoint defined in MemoryPanel/src/panel/api/meta-api.openapi.yaml. Use team for broad collaboration and restricted for sensitive data shared with specific individuals.
Do agents copy shared memory data to their local storage?
No. According to the implementation in MemoryProxy/src/workbuddyHandler.ts, agents store only references (memory_id or skill_id) pointing to the shared asset. When an agent reads the asset, the Proxy retrieves the same storage row used by other agents. This design ensures memory consistency and prevents private data from being cached or duplicated in agent-local storage.
Where is the ACL validation logic implemented?
The primary ACL validation occurs in MemoryProxy/src/tdai/client.ts (lines 329-353), where the acl/check endpoint is called for every asset access request. Additionally, MemoryPanel/src/panel/domain/chat-memory-governance.ts contains secondary guards using the memory_shared_with_team flag to validate read permissions before serving data.
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 →