Files
synapbus/examples/goal-coordinator
Algis DumbrisandClaude Opus 4.6 f319290ef9 feat(goal-coordinator): native MCP tool surface via Gemini session
The coordinator now reaches SynapBus's MCP endpoint directly from
inside the Gemini session. wrapper.sh's coordinator branch is a pure
pass-through — no more JSON-plan parsing. When the coordinator runs,
Gemini connects to /mcp with the coordinator's own Bearer API key and
calls `create_goal`, `propose_task_tree`, and `send_message` as native
tools. Goal rows, task trees, and DMs all land in the DB in one
in-session flow.

- start.sh mints a fresh API key for goal-coordinator via
  `agent revoke-key` and substitutes it into configs/coordinator.json
  (plus the port) at apply_config time.
- coordinator.json declares the synapbus MCP server in mcp_servers;
  the subprocess harness already writes .gemini/settings.json from
  that array, so gemini picks it up automatically.
- GEMINI.md rewritten to instruct the model to call MCP tools
  instead of emitting a JSON action blob. Stdout is explicitly
  discarded; every reply goes through send_message.
- wrapper.sh coordinator branch is ~15 lines: invoke gemini, log,
  exit. Inspector + critic keep the legacy JSON-plan pattern since
  they're workers with fixed contracts.
- SYNAPBUS_KEEP_WORKDIR=1 preserves per-run workdirs for debugging
  MCP traces, gemini output, and materialized configs.
- Reactor checkPendingWork now fires after subprocess run completion
  (previously only K8s poller hit this path). The synthetic
  coalesced trigger uses a `__coalesced__` sentinel instead of
  `system` so it bypasses the FromAgent=="system" dispatch guard.

Verified e2e (with rate-limit-induced retries):
- TRIVIAL: "what is 2+2?" → coordinator send_message(algis, "4")
- INFEASIBLE: "Transfer \$50…" → coordinator
  send_message(algis, "CANNOT: …")
- SINGLE-STEP: 3-node task tree materialized in goal_tasks,
  TASK JSON forwarded to generic-inspector → critic-auditor chain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:00:12 +03:00
..

goal-coordinator — universal triage + delegation demo

A 3-agent multi-agent system where a coordinator triages arbitrary goals into one of four outcomes:

Triage Action
TRIVIAL Coordinator answers directly. No delegation. (2+2 → 4)
INFEASIBLE Coordinator refuses with a concrete reason. (transfer $50 from my bank → CANNOT: no banking credentials)
SINGLE-STEP Coordinator delegates to generic-inspector + critic-auditor.
MULTI-STEP Coordinator plans multi-phase execution (rare).

Unlike the doc-gardener example, which hardcodes a 3-task tree for a single domain, this coordinator is goal-agnostic: you DM it any natural-language brief and it decides what to do.

Architecture

algis ──DM──▶ goal-coordinator (Gemini Pro)
                   │
                   ├── reply     → algis                          (TRIVIAL)
                   ├── refuse    → algis (CANNOT: ...)            (INFEASIBLE)
                   └── delegate  → generic-inspector (Gemini Flash)
                                       │
                                       └── artifact → critic-auditor (Gemini Flash)
                                                         │
                                                         ├── FINAL:   → algis
                                                         └── REVISE:  → generic-inspector

Key design decisions:

  • Critic is a separate agent. It has its own config_hash, independent reputation, and reads only the inspector's output — not its reasoning trace. Prevents the critic from rationalizing the worker's mistakes.
  • Inspector is one agent, not three. Scan + verify + report all happen in one pass because they share context (the finding list). Splitting them forces synchronization for no gain.
  • Coordinator uses a smart model; workers use a fast model. SYNAPBUS_COORDINATOR_MODEL=gemini-3.1-pro-preview (default) vs SYNAPBUS_WORKER_MODEL=gemini-2.5-flash (default). Override either.
  • Harness-agnostic. Every agent goes through the subprocess harness calling wrapper.sh. Swap the gemini invocation in wrapper.sh for claude, codex, or any other CLI — nothing else in SynapBus needs to change.
  • Universal system prompts. configs/coordinator.json contains the triage rules; they work for any goal, not just mcpproxy.

Running

./start.sh                    # provisions user, agents, harness configs
./run_task.sh "what is 2+2?"  # TRIVIAL path
./run_task.sh "Check what Go version is installed and whether it's >= 1.23"
                              # SINGLE-STEP path (delegates to inspector+critic)
./run_task.sh "Transfer \$50 from my bank account to Bob"
                              # INFEASIBLE path (refusal)
./stop.sh

Web UI at http://localhost:18090 (login algis / algis-demo-pw) — see each delegation flow in /runs, the captured prompts + responses in run detail, and the goal tree + cost rollup under /goals.

Why this matters

The doc-gardener demo proved spec-018's primitives work. This example shows what you get when you let an LLM drive them: a coordinator that reasons about each goal before delegating, answers trivial things directly, refuses infeasible things clearly, and only spawns workers when real work is needed. The step from doc-gardener (fixed template) to goal-coordinator (LLM-driven triage) is what makes the system "agentic" instead of a task-runner.

Next evolution

The coordinator currently emits a plan JSON which wrapper.sh parses and dispatches via the admin socket. The next step is to give the Gemini session direct access to the SynapBus MCP tools (create_goal, propose_task_tree, propose_agent, claim_task, request_resource, list_resources — all registered at startup; see internal/mcp/goals_tools.go). Then the coordinator calls them directly in-session, wrapper.sh becomes a 20-line pass-through, and the whole flow is driven by MCP tool calls end-to-end.