> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memoclaw.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Multi-Agent Memory

> Share context between multiple AI agents.

Enable multiple AI agents to share and coordinate memory.

## Use Case

A team of AI agents working on a project:

* Research agent finds information
* Coding agent implements features
* Review agent checks code quality
* All share context via MemoClaw

## Implementation

### Share Findings Between Agents

<CodeGroup>
  ```bash CLI theme={null}
  # Research agent stores findings
  memoclaw store "Found that pgvector HNSW index performs better than IVFFlat for small datasets" \
    --importance 0.85 \
    --agent research-001 \
    --namespace project-backend \
    --type decision

  # Coding agent recalls research findings
  memoclaw recall "vector database performance research" \
    --namespace project-backend \
    --limit 5
  ```

  ```python Python theme={null}
  from memoclaw import MemoClaw

  research_agent = MemoClaw()
  research_agent.agent_id = "research-001"

  coding_agent = MemoClaw()
  coding_agent.agent_id = "coding-001"

  # Research agent stores findings
  research_agent.store(
      content="Found that pgvector HNSW index performs better than IVFFlat for small datasets",
      importance=0.85,
      agent_id="research-001",
      namespace="project-backend",
      memory_type="decision"
  )

  # Coding agent recalls research findings
  findings = coding_agent.recall(
      query="vector database performance research",
      namespace="project-backend",
      limit=5
  )
  ```

  ```typescript TypeScript theme={null}

  import { MemoClawClient } from "memoclaw";

  const researchAgent = new MemoClawClient({ agentId: "research-001" });
  const codingAgent = new MemoClawClient({ agentId: "coding-001" });

  // Research agent stores findings
  await researchAgent.store({
    content: "Found that pgvector HNSW index performs better than IVFFlat for small datasets",
    importance: 0.85,
    agent_id: "research-001",
    namespace: "project-backend",
    memory_type: "decision",
  });

  // Coding agent recalls research findings
  const findings = await codingAgent.recall({
    query: "vector database performance research",
    namespace: "project-backend",
    limit: 5,
  });
  ```
</CodeGroup>

### Filter by Agent

<CodeGroup>
  ```bash CLI theme={null}
  memoclaw list --agent research-001 --namespace project-backend
  ```

  ```python Python theme={null}
  agent_memories = client.list(
      agent_id="research-001",
      namespace="project-backend"
  )
  ```

  ```typescript TypeScript theme={null}

  const agentMemories = await client.list({
    agent_id: "research-001",
    namespace: "project-backend",
  });
  ```
</CodeGroup>

### Create Relations Between Agents' Memories

<CodeGroup>
  ```bash CLI theme={null}
  # Store research finding
  memoclaw store "HNSW is better for our use case" \
    --agent research-001 --namespace project-backend
  # Note the returned ID, e.g. <research-id>

  # Store implementation note
  memoclaw store "Implemented HNSW index for vector search" \
    --agent coding-001 --namespace project-backend
  # Note the returned ID, e.g. <impl-id>

  # Link them
  memoclaw relate <impl-id> <research-id> --type derived_from
  ```

  ```python Python theme={null}
  research_memory = research_agent.store(
      content="HNSW is better for our use case",
      agent_id="research-001",
      namespace="project-backend"
  )

  implementation_memory = coding_agent.store(
      content="Implemented HNSW index for vector search",
      agent_id="coding-001", 
      namespace="project-backend"
  )

  client.create_relation(
      memory_id=implementation_memory.id,
      target_id=research_memory.id,
      relation_type="derived_from"
  )
  ```

  ```typescript TypeScript theme={null}

  const researchMemory = await researchAgent.store({
    content: "HNSW is better for our use case",
    agent_id: "research-001",
    namespace: "project-backend",
  });

  const implMemory = await codingAgent.store({
    content: "Implemented HNSW index for vector search",
    agent_id: "coding-001",
    namespace: "project-backend",
  });

  await client.createRelation(implMemory.id, {
    targetId: researchMemory.id,
    relationType: "derived_from",
  });
  ```
</CodeGroup>

## Memory Isolation

* **Same wallet** = same user identity
* **Different agent\_ids** = different agent perspectives on same memory store
* **Namespaces** = completely separate memory pools

## Best Practices

1. Use consistent `agent_id` naming: `{role}-{number}` or `{name}`
2. Use `namespace` to separate projects
3. Use relations to link cross-agent dependencies
4. Use `memory_type` to distinguish findings vs implementations vs reviews
