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.
Context Prefixes by Role
Assign each agent a context prefix that reflects its role:
agent:planner— high-level plans, decisions, prioritiesagent:coder— implementation details, code patterns, errorsagent:reviewer— review feedback, quality observationsagent: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:
- Planner stores task breakdowns and architectural decisions.
- Coder retrieves decisions, implements, and stores code patterns and errors encountered.
- Reviewer retrieves code patterns and implementation notes, then stores review feedback.
- 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.