Skip to content

Multi-Agent Orchestration

AgentCTX’s orchestrator coordinates multiple agents working on complex tasks. This guide covers delegation, process groups, and building multi-agent workflows.

The ^ (delegate) operator dispatches work to other agents via the agents plane:

^a code-review agent="claude-opus" context="PR #42"
^a security-audit agent="security-agent" context="auth module"
^a documentation agent="gemini-flash" context="API reference"

Find available agents:

?a "code reviewer" Search by capability
?a #security Search by role tag
!a agent-123 Lookup by ID

Agents working on related tasks are organized into process groups:

Orchestrator
├── Agent A (code review) → Process Group "PR-42"
├── Agent B (security audit) → Process Group "PR-42"
└── Agent C (documentation) → Process Group "docs-sprint"

Process groups enable:

  • Coherence detection — prevent duplicate work
  • Dependency ordering — ensure tasks execute in the right sequence
  • State sharing — agents in the same group share team-level memory

When one agent completes its portion, it hands off state to the next:

// Agent A finishes code review
+m:handoff "review complete, 3 issues found" #state
+m:context "Issues: SQL injection in search, XSS in comments, missing rate limit"
// Agent B picks up security audit
?m #handoff @1h Find recent handoffs
?m @traverse "PR-42-review" Get full context graph
+m:context "continuing from code review handoff"

Pipeline verbs create structured reasoning traces that persist across agent handoffs:

// Agent A's trace
+m:context "reviewing PR #42"
+m:check "code style compliance"
+m:edge "SQL injection in search endpoint"
+m:escalate "critical security issue" #p0
// Agent B sees Agent A's full reasoning
?m #pipeline @1h ^20 Get recent cognition trace

Multi-agent communication uses SurrealDB LIVE SELECT as the default transport:

PatternTransportUse
Event routingSurrealDB LIVE SELECT (SovereignBus)Default — all dispatch events and state transitions
Cross-network fan-outCF Tunnel + ctxb-transportSame-machine IPC or cross-network push
Enterprise scaleNATS JetStream (optional)High-throughput, cross-region durability

The SDK provides tools for orchestration:

import { Gateway, Dispatcher } from '@agentctx/core';
const gw = new Gateway();
const result = await gw.process('^a code-review context="PR #42"');
// Dispatch agents to ready workstreams
const dispatcher = new Dispatcher();
dispatcher.loadWorkstreams([{ id: 'PR-42', phase: 1, deps: [], status: 'pending' }]);
dispatcher.registerAgents([{ id: 'reviewer-1', roles: ['code-review'], available: true }]);
const dispatch = dispatcher.dispatch(1); // dispatch all ready workstreams in phase 1
// dispatch.dispatched — assigned agents
// dispatch.blocked — workstreams with unmet dependencies