II.
Page JSON
Structured · livepage:docs-agent-mux-tutorials-multi-agent
Multi-Agent Dispatch json
Inspect the normalized record payload exactly as the atlas UI reads it.
{
"id": "page:docs-agent-mux-tutorials-multi-agent",
"_kind": "Page",
"_file": "wiki/docs/agent-mux/tutorials/multi-agent.md",
"_cluster": "wiki",
"attributes": {
"nodeKind": "Page",
"sourcePath": "docs/agent-mux/tutorials/multi-agent.md",
"sourceKind": "repo-docs",
"title": "Multi-Agent Dispatch",
"displayName": "Multi-Agent Dispatch",
"slug": "docs/agent-mux/tutorials/multi-agent",
"articlePath": "wiki/docs/agent-mux/tutorials/multi-agent.md",
"article": "\n# Multi-Agent Dispatch\n\nagent-mux lets you fan out a prompt to multiple adapters and merge the result stream. This is useful for voting, consensus, or comparison.\n\n## Parallel dispatch\n\n```ts\nimport { createClient } from '@a5c-ai/agent-mux';\n\nconst client = createClient();\n\nconst handles = await Promise.all([\n client.run({ agent: 'claude', prompt: 'Explain the PR' }),\n client.run({ agent: 'gemini', prompt: 'Explain the PR' }),\n client.run({ agent: 'opencode', prompt: 'Explain the PR' }),\n]);\n\nconst results = await Promise.all(\n handles.map(async (h) => {\n let text = '';\n for await (const ev of h.events()) {\n if (ev.type === 'text_delta') text += ev.delta;\n }\n return { agent: h.agent, text };\n }),\n);\n```\n\n## CLI\n\n```bash\namux run claude,gemini,opencode --prompt \"Explain the PR\" --json | \\\n jq -s 'group_by(.agent)'\n```\n\nThe CLI interleaves events from all adapters on stdout, tagged with `agent` so consumers can demux.\n\n## Strategies\n\n- **First-to-finish** — await `Promise.race(handles.map(h => h.done()))` and cancel the rest with `handle.abort()`.\n- **Consensus** — collect all final texts, run a reducer agent (e.g. Claude) to pick the best.\n- **Subagent dispatch** — on adapters with `supportsSubagentDispatch` (Claude), use one agent as the orchestrator and others as workers via the remote adapter.\n\n## Combining with invocation modes\n\nEach handle can use a different invocation mode — for example, run Claude locally and Gemini in a container:\n\n```ts\nclient.run({ agent: 'claude', prompt, invocationMode: { kind: 'local' } });\nclient.run({\n agent: 'gemini',\n prompt,\n invocationMode: { kind: 'docker', image: 'my/gemini:latest' },\n});\n```\n\nSee the per-agent pages for flag compatibility.\n",
"documents": []
},
"outgoingEdges": [],
"incomingEdges": [
{
"from": "page:docs-agent-mux-tutorials",
"to": "page:docs-agent-mux-tutorials-multi-agent",
"kind": "contains_page"
}
]
}