# How to Implement Cross-Agent Memory Sharing Without Exposing Private Data

> Securely share agent memory with TencentDB Agent Memory. Learn how to implement cross-agent memory sharing without exposing private data using visibility flags and ACL checks.

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

---

**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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryPanel/web/src/pages/SkillsPage/components/SkillsPanel.tsx)), this corresponds to toggling the "Share" switch, which triggers the visibility update.

```typescript
// 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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryPanel/src/panel/api/meta-api.openapi.yaml). The grant payload specifies:

- `subject_type`: `user`, `agent`, or `role`
- `subject_id`: The specific identifier
- `permission`: `read`, `write`, etc.
- `effect`: `allow` or `deny`

```typescript
// 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',
});

```

```bash

# 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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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.

```typescript
// 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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/src/utils/manifest.ts) — Defines the `visibility` field that drives team sharing
- **ACL client (check)**: [`MemoryProxy/src/tdai/client.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/tdai/client.ts) — Performs `acl/check` before any asset read/write (lines 329-353)
- **ACL service definition**: [`MemoryPanel/src/panel/api/meta-api.openapi.yaml`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryPanel/src/panel/api/meta-api.openapi.yaml) — OpenAPI spec for `acl/grant`, `acl/check`, etc.
- **Agent-side binding**: [`MemoryProxy/src/workbuddyHandler.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryPanel/src/panel/domain/chat-memory-governance.ts) — Determines read permission based on `memory_shared_with_team` flag and ACL
- **UI toggle for sharing**: [`MemoryPanel/web/src/pages/SkillsPage/components/SkillsPanel.tsx`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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 in [`MemoryCore/src/utils/manifest.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryCore/src/utils/manifest.ts)
- **ACL enforcement** via [`MemoryProxy/src/tdai/client.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/MemoryProxy/src/tdai/client.ts) validates 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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/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.