Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Multi-Agent Collaboration

Shared graphs, scoped contexts, agent-to-agent knowledge.

Shared Graph, Scoped Contexts

Multiple agents share a single LocusGraph. Each agent reads and writes to the same graph, but uses its own context prefix to organize its knowledge. Every agent gets the full Structured Agent Knowledge graph; contributions stay traceable.

Multiple agents share one LocusGraph through scoped contexts so the team's knowledge compounds.

Context Prefixes by Role

Assign each agent a context prefix that reflects its role:

  • agent:planner — high-level plans, decisions, priorities
  • agent:coder — implementation details, code patterns, errors
  • agent:reviewer — review feedback, quality observations
  • agent:tester — test results, coverage gaps, flaky tests

Shared contexts like project:api or decision:architecture let agents communicate through stored knowledge instead of stuffing each other's chat logs into prompts.

How Agents Collaborate

The pattern is simple: one agent stores, another retrieves.

// Planner stores a decision
await client.storeEvent({
  graph_id: 'team-project',
  event_kind: 'decision',
  source: 'planner',
  context_id: 'agent:planner',
  payload: { topic: 'auth_approach', value: 'Use JWT with refresh tokens, 15-minute expiry' },
});
 
// Coder retrieves planner decisions before implementing
const decisions = await client.retrieveMemories({
  query: 'authentication design decisions',
  limit: 5,
  contextTypes: { agent: ['planner'] },
});

The contextTypes filter scopes retrieval to specific context prefixes. The coder retrieves only planner decisions without wading through its own past events.

Use contextTypes to filter by role. An agent that retrieves everything gets noise. An agent that retrieves from the right contexts gets validated signal.

Cross-Agent Knowledge Flow

A typical multi-agent flow:

  1. Planner stores task breakdowns and architectural decisions.
  2. Coder retrieves decisions, implements, and stores code patterns and errors encountered.
  3. Reviewer retrieves code patterns and implementation notes, then stores review feedback.
  4. Planner retrieves review feedback and error patterns, adjusts future plans.

Each agent improves the shared graph. Knowledge compounds across all agents, not just within one.

Keep context prefixes consistent across sessions. Changing prefixes fragments the graph and breaks retrieval.

Next

Single Agent Loop
Start with the simplest pattern before scaling to multi-agent.
Memory-Augmented RAG
Combine retrieval with structured agent knowledge for richer context.