Multi-Agent Shared Memory

Memory architecture for collaborative agent systems

advancedmulti-agentcollaborationshared-stateorchestration

Overview

When multiple AI agents work together on complex tasks, they need shared memory to coordinate, avoid redundant work, and build on each other's progress. This architecture describes how to design memory systems that enable effective multi-agent collaboration.

The Coordination Challenge

Without Shared Memory

  • Agents duplicate research efforts
  • Contradictory conclusions go unnoticed
  • No accumulated team knowledge
  • Orchestrator lacks visibility
  • Handoffs lose context
  • With Shared Memory

  • Work builds on previous findings
  • Contradictions surface for resolution
  • Knowledge compounds across agents
  • Orchestrator makes informed decisions
  • Seamless context transfer
  • Memory Layers

    Agent-Private Memory

    Each agent's working memory:

  • Current task context
  • Intermediate results
  • Draft outputs
  • Internal reasoning traces
  • Agent-specific learned patterns
  • Shared Team Memory

    Accessible by all agents:

  • Completed research findings
  • Established facts
  • Team decisions made
  • Shared glossary/definitions
  • Cross-agent learnings
  • Orchestrator Memory

    Coordination layer:

  • Task allocation history
  • Agent capabilities and performance
  • Dependency tracking
  • Overall progress state
  • Error and retry history
  • Architecture Design

    ┌─────────────────────────────────────────────────────────────┐

    │ ORCHESTRATOR │

    │ ┌─────────────────────────────────────────────────────┐ │

    │ │ Orchestrator Memory │ │

    │ │ - Task queue and status │ │

    │ │ - Agent assignments │ │

    │ │ - Dependency graph │ │

    │ └─────────────────────────────────────────────────────┘ │

    └──────────────────────────┬──────────────────────────────────┘

    ┌─────────────────┼─────────────────┐

    ▼ ▼ ▼

    ┌─────────┐ ┌─────────┐ ┌─────────┐

    │ Agent A │ │ Agent B │ │ Agent C │

    │Research │ │Analysis │ │Writing │

    └────┬────┘ └────┬────┘ └────┬────┘

    │ │ │

    │ Private │ Private │ Private

    │ Memory │ Memory │ Memory

    │ │ │

    └────────────┬────┴────┬────────────┘

    ▼ ▼

    ┌─────────────────────────┐

    │ Shared Team Memory │

    │ - Research findings │

    │ - Analysis results │

    │ - Decisions made │

    │ - Fact repository │

    └─────────────────────────┘

    Coordination Patterns

    Publish-Subscribe

    Agents publish findings, others subscribe:

  • Research agent publishes discovered facts
  • Analysis agent subscribes to research updates
  • Writing agent subscribes to analysis conclusions
  • Loose coupling, eventual consistency
  • Blackboard Pattern

    Shared workspace all agents read/write:

  • Central knowledge store
  • Agents add contributions when ready
  • Others build on available knowledge
  • Orchestrator monitors for completion
  • Message Passing

    Explicit communication between agents:

  • Structured handoffs with context
  • Request-response for specific needs
  • Notifications for relevant updates
  • Clear ownership and responsibility
  • Memory Operations

    Writing to Shared Memory

    When an agent has a finding:

    shared_memory.add({

    "agent_id": "research-agent-1",

    "type": "finding",

    "content": "Discovered that X relates to Y",

    "confidence": 0.85,

    "sources": ["doc1", "doc2"],

    "timestamp": now(),

    "task_id": current_task

    })

    Reading from Shared Memory

    Before starting work:

    relevant_context = shared_memory.search(

    query=current_task_description,

    filters={

    "task_id": current_task,

    "type": ["finding", "decision", "fact"]

    },

    exclude_agent=self.id # Don't re-read own outputs

    )

    Conflict Resolution

    When agents disagree:

  • Flag contradictions in memory
  • Escalate to orchestrator
  • Run reconciliation process
  • Update with resolved conclusion
  • Task Handoff

    Context Package

    When handing off work:

  • Summary of completed work
  • Key findings and decisions
  • Open questions remaining
  • Relevant memory references
  • Suggested next steps
  • Memory Pointer

    Don't copy, reference:

  • Point to shared memory entries
  • Receiving agent retrieves as needed
  • Avoids duplication
  • Ensures consistency
  • Scaling Considerations

    Memory Partitioning

    For large agent teams:

  • Partition by task/project
  • Partition by domain area
  • Replicate hot data
  • Archive completed projects
  • Consistency Models

    Choose appropriate consistency:

  • Strong consistency for critical decisions
  • Eventual consistency for findings
  • Conflict-free types where possible
  • Explicit sync points when needed
  • Use Cases

  • Research teams synthesizing information
  • Code review with multiple specialist agents
  • Complex document generation
  • Multi-step reasoning tasks
  • Game AI with collaborating NPCs