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. This gives every agent access to the full wisdom graph while keeping contributions traceable.

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.

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 signal.

Cross-Agent Knowledge Flow

A typical multi-agent flow:

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

Each agent improves the shared graph. The wisdom 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 stored wisdom for richer context.