From 6b72c91330cbd5dcbca9a3120b3297afdacef51e Mon Sep 17 00:00:00 2001 From: jwbron <8340608+jwbron@users.noreply.github.com> Date: Fri, 13 Mar 2026 02:12:01 +0000 Subject: [PATCH 1/2] docs: update orchestrator and structure docs for coordinator agent Add coordinator agent documentation to orchestrator architecture and project structure docs: - Document coordinator role in Multi-Agent Roles section - Add coordinator REST API endpoints to API reference - Add MCP server endpoints (optional, EGG_MCP_SERVER_ENABLED) - Add coordinator_executor.py, mcp_server.py, mcp_tools.py, and routes/coordinator.py to the Orchestrator Structure listing Triggered by: Add coordinator agent for dynamic pipeline orchestration (#1028) (#1043) Authored-by: egg --- docs/architecture/orchestrator.md | 23 +++++++++++++++++++++++ docs/development/STRUCTURE.md | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/docs/architecture/orchestrator.md b/docs/architecture/orchestrator.md index 150c8904d5..626bd78334 100644 --- a/docs/architecture/orchestrator.md +++ b/docs/architecture/orchestrator.md @@ -184,6 +184,18 @@ See `orchestrator/routes/pipelines.py:WORKTREE_BASE_DIR` and `gateway/worktree_m The orchestrator coordinates specialized agent roles across pipeline phases. Each role runs in its own sandbox container with scoped permissions enforced by the gateway. +### Coordinator Role + +When `coordinator_enabled: true` is set on a pipeline, a single **coordinator** agent runs instead of the fixed-phase dispatcher. The coordinator analyzes the task, spawns agents on demand, and manages phase transitions dynamically via the coordinator REST API. + +| Role | Responsibility | +|------|----------------| +| **Coordinator** | Analyze task requirements, spawn appropriate agents, manage phase transitions, escalate HITL decisions | + +**Execution model**: The coordinator container runs first and drives the entire pipeline. It communicates with the orchestrator via `egg-orch coordinator` CLI commands or the coordinator REST API. Guardrails (max agents, max retries per role, max respawns) prevent runaway behavior and are enforced by the orchestrator. + +See the [Coordinator Guide](../guides/coordinator.md) for operational details. + ### Refine Phase Roles | Role | Responsibility | @@ -392,11 +404,22 @@ Fixed IPs: - `GET|POST /pipelines/{id}/messages` - Inter-agent message bus (send/poll; concurrent mode) - `GET /pipelines/{id}/messages/status` - Message bus statistics (concurrent mode) - `GET /pipelines/{id}/decisions` - HITL decision queue +- `POST /pipelines/{id}/coordinator/spawn` - Spawn an agent via coordinator (requires `coordinator_enabled`) +- `GET /pipelines/{id}/coordinator/state` - Get coordinator state (agents, phases, guardrails) +- `POST /pipelines/{id}/coordinator/phase` - Advance or skip to a target phase +- `POST /pipelines/{id}/coordinator/escalate` - Create a HITL escalation from the coordinator +- `DELETE /pipelines/{id}/coordinator/agents/{role}` - Cancel a running agent by role - `POST /pipelines/{id}/deployment-check/start` - Start devserver for deployment validation - `GET /pipelines/{id}/deployment-check/status` - Poll devserver status - `POST /pipelines/{id}/deployment-check/teardown` - Tear down devserver - `GET /pipelines/{id}/health` - On-demand pipeline health check (all tiers) +**MCP Server (`/mcp/`)** *(optional, requires `EGG_MCP_SERVER_ENABLED=true`)* +- `GET /health` - MCP server health check +- `GET /mcp/v1/tools` - List available coordinator tools +- `POST /mcp/v1/tools/call` - Execute a coordinator tool call +- `GET /mcp/v1/sse` - SSE stream for MCP protocol events (tool listing + heartbeats) + **CLI Access:** The `egg-orch` CLI (`sandbox/bin/egg-orch`) provides command-line access to all orchestrator API endpoints. Available in sandbox containers for agent use, or can be run from the host with appropriate environment variables. See the [README CLI Reference](../../README.md#egg-orch-cli) for command details. diff --git a/docs/development/STRUCTURE.md b/docs/development/STRUCTURE.md index 9247ef3db4..61b1c17a23 100644 --- a/docs/development/STRUCTURE.md +++ b/docs/development/STRUCTURE.md @@ -114,9 +114,13 @@ orchestrator/ │ │ └── state_consistency.py # Cross-reference orchestrator state vs Docker vs contract │ └── tier2/ # Semantic checks (LLM-powered) │ └── agent_inspector.py # Claude-powered agent progress analysis +├── coordinator_executor.py # Coordinator agent lifecycle management (spawn, crash recovery) +├── mcp_server.py # MCP server sidecar for coordinator integration with Claude Code (port 9850) +├── mcp_tools.py # MCP tool definitions and handlers for coordinator operations ├── routes/ # API route handlers │ ├── checks.py # Deployment validation check endpoints │ ├── containers.py # Container management endpoints +│ ├── coordinator.py # Coordinator REST API endpoints (spawn, state, phase, escalate) │ ├── decisions.py # HITL decision endpoints │ ├── health.py # Health check endpoints │ ├── messages.py # Inter-agent message bus endpoints (concurrent mode) From e7d64c81e883726380ba55f0c7dd214fa20ceee0 Mon Sep 17 00:00:00 2001 From: "egg-reviewer[bot]" <261018737+egg-reviewer[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 02:24:04 +0000 Subject: [PATCH 2/2] Address review: fix STRUCTURE.md file ordering and coordinator.py description --- docs/development/STRUCTURE.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/development/STRUCTURE.md b/docs/development/STRUCTURE.md index 61b1c17a23..2fd032d586 100644 --- a/docs/development/STRUCTURE.md +++ b/docs/development/STRUCTURE.md @@ -83,6 +83,7 @@ orchestrator/ ├── container_monitor.py # Container health monitoring ├── concurrent_executor.py # Concurrent phase executor (spawns all agents simultaneously) ├── consensus.py # Consensus protocol for concurrent phase completion +├── coordinator_executor.py # Coordinator agent lifecycle management (spawn, crash recovery) ├── dag_visualizer.py # ASCII DAG visualization for pipeline status (incl. Tier 3 sub-phase rendering) ├── decision_queue.py # HITL decision queue ├── devserver.py # Devserver lifecycle manager for deployment validation (DinD) @@ -91,6 +92,8 @@ orchestrator/ ├── events.py # Event bus for pipeline events ├── gateway_client.py # Gateway API client (sessions, worktrees, config) ├── handoffs.py # Agent handoff data management +├── mcp_server.py # MCP server sidecar for coordinator integration with Claude Code (port 9850) +├── mcp_tools.py # MCP tool definitions and handlers for coordinator operations ├── message_store.py # In-memory inter-agent message store (concurrent mode) ├── metrics.py # Pipeline metrics and telemetry ├── models.py # Pydantic models for pipelines @@ -114,13 +117,10 @@ orchestrator/ │ │ └── state_consistency.py # Cross-reference orchestrator state vs Docker vs contract │ └── tier2/ # Semantic checks (LLM-powered) │ └── agent_inspector.py # Claude-powered agent progress analysis -├── coordinator_executor.py # Coordinator agent lifecycle management (spawn, crash recovery) -├── mcp_server.py # MCP server sidecar for coordinator integration with Claude Code (port 9850) -├── mcp_tools.py # MCP tool definitions and handlers for coordinator operations ├── routes/ # API route handlers │ ├── checks.py # Deployment validation check endpoints │ ├── containers.py # Container management endpoints -│ ├── coordinator.py # Coordinator REST API endpoints (spawn, state, phase, escalate) +│ ├── coordinator.py # Coordinator REST API endpoints (spawn, cancel, state, phase, escalate) │ ├── decisions.py # HITL decision endpoints │ ├── health.py # Health check endpoints │ ├── messages.py # Inter-agent message bus endpoints (concurrent mode)