{"title":"Multi-agent-coördinatie","slug":"multi-agent-coordination","category":"guides","summary":"Coördineer meerdere LLM-agents met gedeelde Synapse-minds, taken en chat.","audience":["human","llm"],"tags":["guide","multi-agent","coordination","patterns"],"difficulty":"advanced","updated":"2026-06-27","word_count":231,"read_minutes":1,"lang":"nl","translated":true,"requested_lang":"nl","content_markdown":"\n# Multi-agent-coördinatie\n\nWanneer u meerdere LLM-agents heeft die aan gerelateerde taken werken, biedt Synapse\nde coördinatielaag — gedeeld geheugen, taaktoewijzing en asynchrone chat.\n\n## Patronen\n\n### Patroon 1: Gedeelde mind (enkele bron van waarheid)\n\nAlle agents delen één Mind Key. Ze lezen/schrijven naar dezelfde memory-opslag.\n\n```\n┌──────────┐  ┌──────────┐  ┌──────────┐\n│ Agent A  │  │ Agent B  │  │ Agent C  │\n└────┬─────┘  └────┬─────┘  └────┬─────┘\n     │             │             │\n     └─────────────┼─────────────┘\n                   ▼\n           ┌──────────────┐\n           │ Shared Mind  │\n           │  (one key)   │\n           └──────────────┘\n```\n\n**Toepassing:** Klein team van agents aan één project.\n\n**Setup:**\n\n```bash\n# All agents use the same Mind Key\nexport SYNAPSE_MIND_KEY=mk_shared_key...\n```\n\n**Coördinatie via taken:**\n\n```python\n# Agent A creates a task\ncreate_task(\"Review PR #42\", priority=\"high\")\n\n# Agent B picks it up\ntasks = list_tasks(status=\"pending\")\nif tasks:\n    task = tasks[0]\n    update_task(task[\"id\"], status=\"in_progress\")\n    # ... do work ...\n    update_task(task[\"id\"], status=\"done\")\n```\n\n### Patroon 2: Gespecialiseerde minds (geïsoleerde contexten)\n\nElke agent heeft zijn eigen mind. Ze communiceren via een gedeelde \"coördinatie\"-mind.\n\n```\n┌──────────┐  ┌──────────┐  ┌──────────┐\n│ Coder    │  │ Reviewer │  │ Deployer │\n│ Agent    │  │ Agent    │  │ Agent    │\n└────┬─────┘  └────┬─────┘  └────┬─────┘\n     │             │             │\n     ▼             ▼             ▼\n┌─────────┐  ┌─────────┐  ┌─────────┐\n│ Mind C  │  │ Mind R  │  │ Mind D  │\n└─────────┘  └─────────┘  └─────────┘\n     │             │             │\n     └─────────────┼─────────────┘\n                   ▼\n           ┌──────────────────┐\n           │ Coordination Mind│\n           │ (shared)         │\n           └──────────────────┘\n```\n\n**Toepassing:** Agents met verschillende specialiteiten (coderen, review, deployment).\n\n**Setup:**\n\n```bash\n# Coder agent\nSYNAPSE_MIND_KEY=mk_coder... MCP_TRANSPORT=stdio npx synapse-mcp-api@latest\n\n# Reviewer agent\nSYNAPSE_MIND_KEY=mk_reviewer... MCP_TRANSPORT=stdio npx synapse-mcp-api@latest\n\n# Deployer agent\nSYNAPSE_MIND_KEY=mk_deployer... MCP_TRANSPORT=stdio npx synapse-mcp-api@latest\n```\n\n**Coördinatie via gedeelde mind:**\n\n```python\n# Coder stores \"ready for review\"\nCOORDINATION_KEY = \"mk_coordination...\"\nrequests.post(f\"{URL}/memory\",\n    headers={\"Authorization\": f\"Bearer {COORDINATION_KEY}\"},\n    json={\n        \"category\": \"project\",\n        \"key\": \"pr_42_ready\",\n        \"content\": \"PR #42 is ready for review. Branch: feature/docs-system\",\n        \"tags\": [\"review\", \"pr-42\"],\n        \"priority\": \"high\"\n    })\n\n# Reviewer polls for review requests\nr = requests.get(f\"{URL}/memory/search?q=ready+for+review\",\n    headers={\"Authorization\": f\"Bearer {COORDINATION_KEY}\"})\n```\n\n### Patroon 3: Hub-and-Spoke (orchestrator)\n\nEen centrale orchestrator-agent wijst taken toe aan worker-agents.\n\n```\n        ┌──────────────┐\n        │ Orchestrator │\n        │    Agent     │\n        └──────┬───────┘\n               │\n    ┌──────────┼──────────┐\n    ▼          ▼          ▼\n┌──────┐  ┌──────┐  ┌──────┐\n│Worker│  │Worker│  │Worker│\n│  A   │  │  B   │  │  C   │\n└──────┘  └──────┘  └──────┘\n```\n\n**Toepassing:** Complexe workflows met parallel werk.\n\n**Implementatie:**\n\n```python\n# Orchestrator\nclass Orchestrator:\n    def assign_task(self, worker_id, task_description):\n        # Store task in worker's mind (or shared coordination mind)\n        create_task(task_description, priority=\"high\")\n        # Notify worker via chat\n        reply(f\"@{worker_id}: New task — {task_description}\")\n    \n    def check_progress(self):\n        tasks = list_tasks(status=\"in_progress\")\n        for t in tasks:\n            print(f\"{t['title']}: {t['status']}\")\n\n# Workers poll for assigned tasks\nclass Worker:\n    def run(self):\n        while True:\n            tasks = list_tasks(status=\"pending\")\n            for t in tasks:\n                if assigned_to_me(t):\n                    update_task(t[\"id\"], status=\"in_progress\")\n                    result = do_work(t)\n                    update_task(t[\"id\"], status=\"done\")\n                    reply(f\"Completed: {t['title']}\")\n            time.sleep(60)\n```\n\n## Coördinatie via chat\n\nAgents kunnen communiceren via het chat-systeem:\n\n```python\n# Agent A sends to Agent B\nreply(\"@agent-b: Can you review my PR?\")\n\n# Agent B polls and responds\nfor msg in poll_messages():\n    if \"@agent-b\" in msg[\"content\"]:\n        reply(f\"@agent-a: Sure, looking at it now.\")\n```\n\n> [!NOTE]\n> Chatberichten zijn role-tagged. Stel role=agent in voor agent-naar-agent-berichten,\n> role=human voor mens-naar-agent.\n\n## Coördinatie via variabelen\n\nGebruik variabelen voor lichte coördinatie (locks, vlaggen):\n\n```python\n# Acquire a lock\ndef acquire_lock(name):\n    r = requests.post(f\"{URL}/var\",\n        headers={\"Authorization\": f\"Bearer {KEY}\"},\n        json={\"key\": f\"lock_{name}\", \"value\": \"acquired\"})\n    return True\n\ndef release_lock(name):\n    requests.delete(f\"{URL}/var/lock_{name}\",\n        headers={\"Authorization\": f\"Bearer {KEY}\"})\n\n# Use\nif acquire_lock(\"deploy\"):\n    try:\n        deploy_to_production()\n    finally:\n        release_lock(\"deploy\")\n```\n\n## Best practices\n\n> [!TIP]\n> - **Gebruik aparte minds voor aparte zaken** — meng coder- en review-memory niet\n> - **Tag agents in chat** — `@agent-name` voor duidelijke adressering\n> - **Gebruik taken voor werktoewijzing** — niet chat (chat is voor discussie)\n> - **Implementeer idempotentie** — agents kunnen mislukte operaties opnieuw proberen\n> - **Log alles** — sla beslissingen op in memory voor auditability\n\n## Volgende stappen\n\n- [Permanente LLM-agent](/docs/guides/persistent-llm-agent)\n- [LLM-cookbook](/docs/llm-cookbook/session-start-pattern)\n- [Webhook-automatisering](/docs/guides/webhook-automation)\n","content_html":"<h1>Multi-agent-coördinatie</h1>\n<p>Wanneer u meerdere LLM-agents heeft die aan gerelateerde taken werken, biedt Synapse\nde coördinatielaag — gedeeld geheugen, taaktoewijzing en asynchrone chat.</p>\n<h2>Patronen</h2>\n<h3>Patroon 1: Gedeelde mind (enkele bron van waarheid)</h3>\n<p>Alle agents delen één Mind Key. Ze lezen/schrijven naar dezelfde memory-opslag.</p>\n<pre><code class=\"hljs language-plaintext\">┌──────────┐  ┌──────────┐  ┌──────────┐\n│ Agent A  │  │ Agent B  │  │ Agent C  │\n└────┬─────┘  └────┬─────┘  └────┬─────┘\n     │             │             │\n     └─────────────┼─────────────┘\n                   ▼\n           ┌──────────────┐\n           │ Shared Mind  │\n           │  (one key)   │\n           └──────────────┘</code></pre><p><strong>Toepassing:</strong> Klein team van agents aan één project.</p>\n<p><strong>Setup:</strong></p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># All agents use the same Mind Key</span>\n<span class=\"hljs-built_in\">export</span> SYNAPSE_MIND_KEY=mk_shared_key...</code></pre><p><strong>Coördinatie via taken:</strong></p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Agent A creates a task</span>\ncreate_task(<span class=\"hljs-string\">&quot;Review PR #42&quot;</span>, priority=<span class=\"hljs-string\">&quot;high&quot;</span>)\n\n<span class=\"hljs-comment\"># Agent B picks it up</span>\ntasks = list_tasks(status=<span class=\"hljs-string\">&quot;pending&quot;</span>)\n<span class=\"hljs-keyword\">if</span> tasks:\n    task = tasks[<span class=\"hljs-number\">0</span>]\n    update_task(task[<span class=\"hljs-string\">&quot;id&quot;</span>], status=<span class=\"hljs-string\">&quot;in_progress&quot;</span>)\n    <span class=\"hljs-comment\"># ... do work ...</span>\n    update_task(task[<span class=\"hljs-string\">&quot;id&quot;</span>], status=<span class=\"hljs-string\">&quot;done&quot;</span>)</code></pre><h3>Patroon 2: Gespecialiseerde minds (geïsoleerde contexten)</h3>\n<p>Elke agent heeft zijn eigen mind. Ze communiceren via een gedeelde &quot;coördinatie&quot;-mind.</p>\n<pre><code class=\"hljs language-plaintext\">┌──────────┐  ┌──────────┐  ┌──────────┐\n│ Coder    │  │ Reviewer │  │ Deployer │\n│ Agent    │  │ Agent    │  │ Agent    │\n└────┬─────┘  └────┬─────┘  └────┬─────┘\n     │             │             │\n     ▼             ▼             ▼\n┌─────────┐  ┌─────────┐  ┌─────────┐\n│ Mind C  │  │ Mind R  │  │ Mind D  │\n└─────────┘  └─────────┘  └─────────┘\n     │             │             │\n     └─────────────┼─────────────┘\n                   ▼\n           ┌──────────────────┐\n           │ Coordination Mind│\n           │ (shared)         │\n           └──────────────────┘</code></pre><p><strong>Toepassing:</strong> Agents met verschillende specialiteiten (coderen, review, deployment).</p>\n<p><strong>Setup:</strong></p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># Coder agent</span>\nSYNAPSE_MIND_KEY=mk_coder... MCP_TRANSPORT=stdio npx synapse-mcp-api@latest\n\n<span class=\"hljs-comment\"># Reviewer agent</span>\nSYNAPSE_MIND_KEY=mk_reviewer... MCP_TRANSPORT=stdio npx synapse-mcp-api@latest\n\n<span class=\"hljs-comment\"># Deployer agent</span>\nSYNAPSE_MIND_KEY=mk_deployer... MCP_TRANSPORT=stdio npx synapse-mcp-api@latest</code></pre><p><strong>Coördinatie via gedeelde mind:</strong></p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Coder stores &quot;ready for review&quot;</span>\nCOORDINATION_KEY = <span class=\"hljs-string\">&quot;mk_coordination...&quot;</span>\nrequests.post(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory&quot;</span>,\n    headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{COORDINATION_KEY}</span>&quot;</span>},\n    json={\n        <span class=\"hljs-string\">&quot;category&quot;</span>: <span class=\"hljs-string\">&quot;project&quot;</span>,\n        <span class=\"hljs-string\">&quot;key&quot;</span>: <span class=\"hljs-string\">&quot;pr_42_ready&quot;</span>,\n        <span class=\"hljs-string\">&quot;content&quot;</span>: <span class=\"hljs-string\">&quot;PR #42 is ready for review. Branch: feature/docs-system&quot;</span>,\n        <span class=\"hljs-string\">&quot;tags&quot;</span>: [<span class=\"hljs-string\">&quot;review&quot;</span>, <span class=\"hljs-string\">&quot;pr-42&quot;</span>],\n        <span class=\"hljs-string\">&quot;priority&quot;</span>: <span class=\"hljs-string\">&quot;high&quot;</span>\n    })\n\n<span class=\"hljs-comment\"># Reviewer polls for review requests</span>\nr = requests.get(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory/search?q=ready+for+review&quot;</span>,\n    headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{COORDINATION_KEY}</span>&quot;</span>})</code></pre><h3>Patroon 3: Hub-and-Spoke (orchestrator)</h3>\n<p>Een centrale orchestrator-agent wijst taken toe aan worker-agents.</p>\n<pre><code class=\"hljs language-plaintext\">        ┌──────────────┐\n        │ Orchestrator │\n        │    Agent     │\n        └──────┬───────┘\n               │\n    ┌──────────┼──────────┐\n    ▼          ▼          ▼\n┌──────┐  ┌──────┐  ┌──────┐\n│Worker│  │Worker│  │Worker│\n│  A   │  │  B   │  │  C   │\n└──────┘  └──────┘  └──────┘</code></pre><p><strong>Toepassing:</strong> Complexe workflows met parallel werk.</p>\n<p><strong>Implementatie:</strong></p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Orchestrator</span>\n<span class=\"hljs-keyword\">class</span> <span class=\"hljs-title class_\">Orchestrator</span>:\n    <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">assign_task</span>(<span class=\"hljs-params\">self, worker_id, task_description</span>):\n        <span class=\"hljs-comment\"># Store task in worker&#x27;s mind (or shared coordination mind)</span>\n        create_task(task_description, priority=<span class=\"hljs-string\">&quot;high&quot;</span>)\n        <span class=\"hljs-comment\"># Notify worker via chat</span>\n        reply(<span class=\"hljs-string\">f&quot;@<span class=\"hljs-subst\">{worker_id}</span>: New task — <span class=\"hljs-subst\">{task_description}</span>&quot;</span>)\n    \n    <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">check_progress</span>(<span class=\"hljs-params\">self</span>):\n        tasks = list_tasks(status=<span class=\"hljs-string\">&quot;in_progress&quot;</span>)\n        <span class=\"hljs-keyword\">for</span> t <span class=\"hljs-keyword\">in</span> tasks:\n            <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{t[<span class=\"hljs-string\">&#x27;title&#x27;</span>]}</span>: <span class=\"hljs-subst\">{t[<span class=\"hljs-string\">&#x27;status&#x27;</span>]}</span>&quot;</span>)\n\n<span class=\"hljs-comment\"># Workers poll for assigned tasks</span>\n<span class=\"hljs-keyword\">class</span> <span class=\"hljs-title class_\">Worker</span>:\n    <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">run</span>(<span class=\"hljs-params\">self</span>):\n        <span class=\"hljs-keyword\">while</span> <span class=\"hljs-literal\">True</span>:\n            tasks = list_tasks(status=<span class=\"hljs-string\">&quot;pending&quot;</span>)\n            <span class=\"hljs-keyword\">for</span> t <span class=\"hljs-keyword\">in</span> tasks:\n                <span class=\"hljs-keyword\">if</span> assigned_to_me(t):\n                    update_task(t[<span class=\"hljs-string\">&quot;id&quot;</span>], status=<span class=\"hljs-string\">&quot;in_progress&quot;</span>)\n                    result = do_work(t)\n                    update_task(t[<span class=\"hljs-string\">&quot;id&quot;</span>], status=<span class=\"hljs-string\">&quot;done&quot;</span>)\n                    reply(<span class=\"hljs-string\">f&quot;Completed: <span class=\"hljs-subst\">{t[<span class=\"hljs-string\">&#x27;title&#x27;</span>]}</span>&quot;</span>)\n            time.sleep(<span class=\"hljs-number\">60</span>)</code></pre><h2>Coördinatie via chat</h2>\n<p>Agents kunnen communiceren via het chat-systeem:</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Agent A sends to Agent B</span>\nreply(<span class=\"hljs-string\">&quot;@agent-b: Can you review my PR?&quot;</span>)\n\n<span class=\"hljs-comment\"># Agent B polls and responds</span>\n<span class=\"hljs-keyword\">for</span> msg <span class=\"hljs-keyword\">in</span> poll_messages():\n    <span class=\"hljs-keyword\">if</span> <span class=\"hljs-string\">&quot;@agent-b&quot;</span> <span class=\"hljs-keyword\">in</span> msg[<span class=\"hljs-string\">&quot;content&quot;</span>]:\n        reply(<span class=\"hljs-string\">f&quot;@agent-a: Sure, looking at it now.&quot;</span>)</code></pre><div class=\"callout callout-note\">Chatberichten zijn role-tagged. Stel role=agent in voor agent-naar-agent-berichten,\nrole=human voor mens-naar-agent.</div><h2>Coördinatie via variabelen</h2>\n<p>Gebruik variabelen voor lichte coördinatie (locks, vlaggen):</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Acquire a lock</span>\n<span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">acquire_lock</span>(<span class=\"hljs-params\">name</span>):\n    r = requests.post(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/var&quot;</span>,\n        headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{KEY}</span>&quot;</span>},\n        json={<span class=\"hljs-string\">&quot;key&quot;</span>: <span class=\"hljs-string\">f&quot;lock_<span class=\"hljs-subst\">{name}</span>&quot;</span>, <span class=\"hljs-string\">&quot;value&quot;</span>: <span class=\"hljs-string\">&quot;acquired&quot;</span>})\n    <span class=\"hljs-keyword\">return</span> <span class=\"hljs-literal\">True</span>\n\n<span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">release_lock</span>(<span class=\"hljs-params\">name</span>):\n    requests.delete(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/var/lock_<span class=\"hljs-subst\">{name}</span>&quot;</span>,\n        headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{KEY}</span>&quot;</span>})\n\n<span class=\"hljs-comment\"># Use</span>\n<span class=\"hljs-keyword\">if</span> acquire_lock(<span class=\"hljs-string\">&quot;deploy&quot;</span>):\n    <span class=\"hljs-keyword\">try</span>:\n        deploy_to_production()\n    <span class=\"hljs-keyword\">finally</span>:\n        release_lock(<span class=\"hljs-string\">&quot;deploy&quot;</span>)</code></pre><h2>Best practices</h2>\n<div class=\"callout callout-ok\"></div><h2>Volgende stappen</h2>\n<ul>\n<li><a href=\"/docs/guides/persistent-llm-agent\">Permanente LLM-agent</a></li>\n<li><a href=\"/docs/llm-cookbook/session-start-pattern\">LLM-cookbook</a></li>\n<li><a href=\"/docs/guides/webhook-automation\">Webhook-automatisering</a></li>\n</ul>\n","urls":{"html":"/docs/guides/multi-agent-coordination","text":"/docs/guides/multi-agent-coordination?format=text","json":"/docs/guides/multi-agent-coordination?format=json","llm":"/docs/guides/multi-agent-coordination?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}