Agent Conductor
README.md
# Agent Conductor
[](LICENSE)
[](pyproject.toml)
English | [简体中文](README.zh-CN.md)
A **cross-vendor multi-agent orchestrator and Agent Skill** built for **seamless interoperability between Codex CLI and Antigravity** (bridging OpenAI GPT with Anthropic Claude & Google Gemini in one deterministic workflow) — and extensible to additional OpenAI-compatible gateways via **`cc-switch`** or custom Codex profiles + `~/.agent-conductor/routes.json`.
**Core philosophy**: Keep the primary session as the **single lead coordinator**, pairing role-based model routing across 14 SDLC roles with persistent ACP / Codex App-Server pools, isolated Git worktrees, protected verification gates, cross-vendor blind code review, and resumable SQLite DAG workflows.
---
## Key Features
- **Codex ↔ Antigravity Interoperability & Blind Review**
- Seamlessly bridges **Antigravity** (`agy acp`: Gemini / Claude models) and **Codex CLI** (OpenAI GPT models), and can optionally plug in any **OpenAI-compatible multi-upstream gateway** via tools like **`cc-switch`**, custom Codex profiles, and `~/.agent-conductor/routes.json`.
- Enforces **author/reviewer vendor separation** by default in `run_verified_pipeline` (e.g., code written by OpenAI/DeepSeek/Qwen is reviewed by Anthropic/Google) to eliminate single-model blind spots.
- **Persistent Dual-Backend Connection Pools (Zero Cold-Start + KV-Cache Reuse)**
- Maintains warm `agy acp --stdio --sandbox` processes using the official [`agent-client-protocol`](https://github.com/agentclientprotocol/python-sdk) SDK;
- Drives `codex app-server` over bidirectional JSON-RPC 2.0;
- Isolates pools by `(codex_profile, windows_sandbox, context_only)`, supports `fork_parallel` for prefix KV-cache sharing, live `steer_turn` mid-turn steering, and a `120s` silent-stall watchdog.
- **Role-Based Routing & Automatic `429` Cooldowns**
- [routes.json](routes.json) defines 14 engineering roles with fallback chains, overridable at `~/.agent-conductor/routes.json` or via `AGENT_CONDUCTOR_ROUTES_PATH` (see [routes.example.json](routes.example.json) for custom gateway setups).
- Validates `effort` against local Codex catalogs before dispatch and applies exponential backoff (`60s -> 180s -> 600s`) on `429`/rate-limit failures.
- **Isolated Worktrees, Protected Verification Gates & Multi-Patch Merging**
- Runs edits in detached Git worktrees, executes `--verify-cmd` in a clean snapshot checkout that rejects changes to `--verify-trusted` paths, supports `--verify-link` / `verify_readonly_links` for mounting `node_modules` or `.venv`, and triggers bounded self-repair with duplicate-error circuit breaking.
- `merge_and_verify` automatically merges multiple parallel `.patch` artifacts, optionally arbitrates conflicts, and re-runs regression verification.
- **SQLite-Persisted Parallel DAG + RepoMap Context Packing**
- `pack_context` builds a budget-capped context packet with directory tree, Python AST / polyglot **Symbol RepoMap**, and numbered source lines.
- `run_dag` persists node state in SQLite (`~/.agent-conductor/dags/`), supporting parallel fan-out/fan-in and lossless resume on failure.
- **Zero-Dependency Stdlib Fallback**
- [delegate.py](scripts/delegate.py) and [consult_server.py](scripts/consult_server.py) work with pure Python `3.10+` stdlib without installing `.venv` packages.
---
## Architecture
```mermaid
flowchart TD
User["User Request"] --> Lead["Lead Session (Single Coordinator / SKILL.md)"]
Lead -->|"MCP Stdio (13 Tools)"| Server["orchestrator_server.py (MCPServer)"]
Server --> Router["pool_router.py + routing.py (Role Routing / 429 Cooldowns)"]
Router -->|"Reads Config"| Routes["routes.json + Local Model Catalogs"]
Router -->|"Persistent ACP Pool"| ACP["acp_pool.py (agy acp)"]
Router -->|"Persistent JSON-RPC Pool"| Codex["codex_pool.py (codex app-server)"]
Router -->|"Safe CLI Fallback"| CLI["workers.py (Single-Shot CLI)"]
Router -->|"Isolation & Merging"| WT["worktree.py (Git Worktree / merge_and_verify)"]
WT -->|"Protected Gate & Repair"| Gate["delegate.py (Snapshot Gate / Readonly Links)"]
Server -->|"Parallel Orchestration"| DAG["dag_engine.py (SQLite Resumable DAG)"]
Server -->|"Budgeted Extraction"| Pack["context_packer.py (RepoMap + Context Pack)"]
```
---
## Quick Start
### 1. Install as an Agent Skill
Install directly with the Agent Skills CLI (`skills.sh` / `agentskills.io`):
```bash
npx skills add onlinewithjun/agent-conductor
```
Or clone manually into your agent's skills directory:
```bash
git clone https://github.com/onlinewithjun/agent-conductor.git
cd agent-conductor
```
### 2. Prerequisites & Virtual Environment
- **Requirements**: Python `3.10+`, `git`, and authenticated `agy` and/or `codex` CLI tools.
- **Install MCP & ACP dependencies (recommended)**:
```bash
# macOS / Linux
python3 -m venv .venv
./.venv/bin/python -m pip install -e .
```
```powershell
# Windows
py -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .
```
### 3. Doctor Check & One-Click MCP Registration
Use the zero-dependency bootstrapper [scripts/install_mcp.py](scripts/install_mcp.py) (creates `.bak` backups before modifying any config):
```bash
# macOS / Linux
python3 scripts/install_mcp.py doctor
python3 scripts/install_mcp.py install --dry-run
python3 scripts/install_mcp.py install
# Uninstall if needed:
python3 scripts/install_mcp.py uninstall
```
```powershell
# Windows
py scripts/install_mcp.py doctor
py scripts/install_mcp.py install --dry-run
py scripts/install_mcp.py install
# Uninstall if needed:
py scripts/install_mcp.py uninstall
```
> Pass `--scope project --project-root <dir>` for project-local registration, or `--server consult` to register the zero-dependency [consult_server.py](scripts/consult_server.py) fallback.
---
## 14-Role Routing & Customization
Configuration precedence (highest to lowest):
1. Explicit `provider` + `model` arguments
2. `AGENT_CONDUCTOR_ROUTES_PATH` environment variable (legacy `COORD_ROUTES_PATH` also supported)
3. User override file at `~/.agent-conductor/routes.json` (partial overrides merge cleanly over defaults)
4. Built-in [routes.json](routes.json)
See [routes.example.json](routes.example.json) for attaching custom Codex profiles or external gateways (such as via `cc-switch`), and [references/model-routing.md](references/model-routing.md) for full details on all 14 SDLC roles (`architecture`, `ui_design`, `orchestrator`, `frontend_impl`, `backend_impl`, `multilingual_repo`, `algorithm`, `data_analytics`, `devops_ci`, `gui_vision`, `unit_test`, `security_audit`, `code_review`, `long_context`).
### Multi-Pool Gateway Demo (`cc-switch` / Custom Profiles)
Want a complete real-world blueprint showing how to combine **Antigravity** (planning & UI design), **Codex direct** (hard algorithms & blind review), and a **multi-upstream gateway via `cc-switch`** (e.g., `volcengine/`, `tencent/`, `dashscope/`, `baidu/`, `zhipu/`, `moonshot/` with 4-upstream `429` rotation)?
- Walk-through & 14-role division rationale: [examples/multi-pool-routing-demo.md](examples/multi-pool-routing-demo.md)
- Ready-to-copy 14-role template: [routes.example.json](routes.example.json)
```bash
mkdir -p ~/.agent-conductor
cp routes.example.json ~/.agent-conductor/routes.json
# Replace "ccs-gateway/" with your actual gateway prefix (or set "codex_profile"), then validate:
python3 scripts/install_mcp.py doctor
```
---
## 13 MCP Tools Reference
Exposed by [scripts/orchestrator_server.py](scripts/orchestrator_server.py):
| Tool | Purpose | Highlights |
| :--- | :--- | :--- |
| `consult` | Codex context-only analysis | `codex_profile`, up to 256K chars, multi-turn `session_id` reuse |
| `consult_antigravity` | Antigravity context-only analysis | Persistent ACP pool, strict read-only policy isolation, `session_id` reuse |
| `route_consult` | Role-based auto-routed consultation | Selects candidate by `role`, auto-cools down on `429` and fails over |
| `dispatch_workspace` | Workspace read/write dispatch | Explicit model or `routing_role`, `auto_worktree`, protected gate, `resume` |
| `run_verified_pipeline` | End-to-end code -> gate -> review | `coder_role` / `reviewer_role`, vendor separation, `auto_fix_on_review` |
| `fork_parallel` | Native session fork fan-out | Forks `N` parallel branches from `base_session_id` sharing prefix KV-cache |
| `steer_turn` | Live mid-turn steering | Sends `turn/steer` instructions to an active Codex App-Server turn |
| `pack_context` | Budget-capped repo context packer | Directory tree + Symbol RepoMap + line-numbered files, binary/symlink safe |
| `merge_and_verify` | Multi-patch merge & verification | Applies parallel `.patch` files in a worktree, resolves conflicts, runs gate |
| `run_dag` | Durable parallel DAG engine | Concurrent nodes, `${nodes.<id>.<field>}` wiring, SQLite checkpoint resume |
| `worktree_manage` | Worktree & session lifecycle | `diff_stat`, `apply_check`, `merge_check`, `remove`, `gc` |
| `pool_status` | Pool & cooldown observability | Shows active ACP/Codex pools, active cooldowns, and `recycle=True` |
| `get_ledger` | Model division & token ledger | Returns call `entries`, formatted `markdown` summary, and `cache_hit_ratio` |
---
## Workflow Examples
### 1. Zero-Dependency CLI Dispatch
```bash
python3 scripts/delegate.py codex gpt-6.2-sol task.md \
--root /path/to/repo --write --auto-worktree --effort medium \
--verify-cmd '["python3","-m","unittest"]' --verify-trusted tests \
--verify-link .venv --verify-repair-feedback --max-repairs 2 --progress
```
### 2. Role-Based `run_verified_pipeline`
Pass roles instead of hardcoding models:
- `coder_role="backend_impl"` (picks from `routes.json`, automatically fails over cleanly on `429`)
- `reviewer_role="code_review"` (automatically excludes the coder's vendor for blind review)
- `verify_cmd=["python3", "-m", "unittest"]`, `verify_trusted=["tests"]`
### 3. Resumable Parallel `run_dag`
```json
[
{"id": "pack", "kind": "pack_context", "config": {"root": "/path/to/repo", "focus_paths": ["src"]}},
{"id": "api", "kind": "workspace", "deps": ["pack"], "config": {"routing_role": "backend_impl", "root": "/path/to/repo", "write": true, "auto_worktree": true, "task": "Implement API\n${nodes.pack.repomap}"}},
{"id": "ui", "kind": "workspace", "deps": ["pack"], "config": {"routing_role": "frontend_impl", "root": "/path/to/repo", "write": true, "auto_worktree": true, "task": "Implement UI\n${nodes.pack.repomap}"}},
{"id": "review", "kind": "role_consult", "deps": ["api", "ui"], "config": {"role": "code_review", "material": "API: ${nodes.api.diff_stat}\nUI: ${nodes.ui.diff_stat}"}}
]
```
> Re-running `run_dag` with the same `run_id` automatically skips completed nodes and resumes from the failed step.
---
## Directory Layout
```text
agent-conductor/
├── SKILL.md # Agent Skill entry specification (single-lead rules & tools)
├── README.md # Project documentation (English)
├── README.zh-CN.md # Project documentation (简体中文)
├── LICENSE # MIT License
├── pyproject.toml # Python metadata and mcp / acp dependencies
├── routes.json # Default 14-role routing table
├── routes.example.json # Complete 14-role multi-pool & gateway demo template
├── examples/
│ └── multi-pool-routing-demo.md # Three-pool division & cc-switch gateway guide
├── references/
│ ├── model-routing.md # 14-role SDLC routing, effort checks & cooldown rules
│ └── consultation.md # MCP setup and context-only consultation details
├── scripts/
│ ├── orchestrator_server.py # Unified MCP server (13 tools)
│ ├── pool_router.py # Pool coordinator, verified pipeline, merge-and-verify
│ ├── routing.py # Route loader, catalog validation, 429 exponential cooldowns
│ ├── catalog.py # Codex catalog parser, vendor classifier & call ledger
│ ├── acp_pool.py # Persistent Antigravity ACP pool + stall watchdog
│ ├── codex_pool.py # Persistent Codex App-Server pool (steer + fork + watchdog)
│ ├── agent_process.py # Cross-platform subprocess timeouts & Windows Job Object cleanup
│ ├── worktree.py # Detached Git worktrees, binary patches, merge checks & GC
│ ├── delegate.py # Zero-dependency CLI dispatcher & snapshot verification gate
│ ├── context_packer.py # Budget-aware repo packer with polyglot Symbol RepoMap
│ ├── dag_engine.py # SQLite-persisted parallel DAG engine
│ ├── install_mcp.py # Zero-dependency doctor & MCP installer/uninstaller
│ ├── workers.py # Single-shot CLI adapters & structured output validation
│ ├── consult_server.py # Zero-dependency stdlib consultation MCP fallback
│ └── agy_trajectory.py # Read-only Antigravity SQLite trajectory diagnostic
└── tests/
├── test_coordination.py # Pure stdlib core contract tests
├── test_phase2_orchestrator.py # Persistent pool & MCP orchestration tests
├── test_phase3_features.py # Routing cooldowns, watchdog, RepoPacker & DAG tests
└── test_phase4_upgrades.py # Route overrides, installer, RepoMap & merge-verify tests
```
---
## Security Boundaries
1. **Recursion Guard**: Child processes receive `AGENT_ROLE=worker` (plus `[ROLE: DELEGATED_WORKER]`); `delegate.py`, `consult_server.py`, and `orchestrator_server.py` refuse to launch if invoked by a worker.
2. **Strict Read-Only Consultation**: `context_only` runs inside an isolated temp directory with Codex `shell_tool`/`web_search` disabled and Antigravity `--gemini-dir` permission denials + tool-event abort.
3. **Tamper-Proof Verification Gate**: Edits touching `--verify-trusted` paths are rejected; verification runs in a clean snapshot checkout with stripped credentials.
4. **Clean Process & Junction Teardown**: Worker processes attach to Windows Job Objects (`KILL_ON_JOB_CLOSE`), and `--verify-link` verifies reparse-point identity before unlinking.
---
## Running Tests
```bash
# 1. Pure stdlib contract tests (no third-party packages required)
python3 -m unittest discover -s tests -p "test_coordination.py" -v
# 2. Full test suite (inside .venv)
./.venv/bin/python -m unittest discover -s tests -v
```
```powershell
# Windows (inside .venv)
py -m unittest discover -s tests -p "test_coordination.py" -v
.\.venv\Scripts\python.exe -m unittest discover -s tests -v
```
---
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues