Four AI agents. One brain. Zero downtime.
A terminal-based multi-agent orchestrator that wraps Claude, Codex, Gemini, Grok, and Antigravity CLIs (plus an optional Argon API reviewer) with automatic failover. When one agent hits its limit, the next one picks up seamlessly. All agents share context through a knowledge base server.
You type a message
|
v
[Orchestrator]
|
+---> Try Agent 1 (Claude) ---> Success? Return response
| |
| Failed/Down
| |
+---> Try Agent 2 (Codex) ---> Success? Return response
| |
| Failed/Down
| |
+---> Try Agent 3 (Gemini) --> Success? Return response
| |
| Failed/Down
| |
+---> Try Agent 4 (Grok) ----> Success? Return response
|
All failed? Show error + recovery options
Each message is routed through a role chain — an ordered list of agents to try. Roles include:
- orchestrator — planning, architecture, high-level reasoning (default: Claude > Codex > Gemini > Grok)
- implementation — code execution, build tasks (default: Codex > Claude > Gemini > Antigravity > Grok)
- uidocs — frontend, design, documentation (default: Gemini > Codex > Claude > Antigravity > Grok)
- review — code review, validation (default: Claude > Codex > Gemini > Antigravity > Argon > Grok; Argon only when a Gemini API key is set)
- intel — X/social signal and external research (default: Grok > Gemini > Claude > Codex)
Every role, chain order, and model is configurable.
- Next-man-up failover — if an agent is down, the next one in the chain takes over automatically
- Auto-downtime detection — detects rate limits, quota exhaustion, auth failures, and auto-disables agents with cooldown timers
- CLI wrapping — uses your existing Claude/Codex/Gemini/Grok CLI subscriptions, not per-token API billing
- Full-host unattended CLI defaults — Codex and Gemini can run headlessly with full permissions on trusted machines. Grok and Antigravity default to a sandbox instead (see "Grok and Antigravity: sandboxed by default")
- API mode available for supported providers — switch API-backed agents when you prefer keys over CLI auth
- Configurable name — call it whatever you want, not hardcoded
- Knowledge base integration — searches your KB server for relevant context before every response
- Colored output — each agent has its own color for easy identification
- Role-based routing —
impl:prefix routes to implementation chain,ui:to UI chain - Task management — switch between project contexts with
/task - Service management — manually disable/enable agents, set timed downtimes
- Smoke testing — test all agents with one command
- Directory whitelisting — control which directories agents can access
git clone https://github.com/willynikes2/agent-orchestrator.git
cd agent-orchestrator
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python3 daniel.py --setupThe setup wizard asks:
- What to name your orchestrator (default: "agent")
- Which mode for each agent (CLI or API)
- CLI permission mode for Codex and Gemini (
full-host-unattendedorsandboxed-auto) - API keys (optional in CLI mode)
- Model IDs
- Role chain preferences
Then just run:
python3 daniel.pyFor reliable one-shot scripted usage, use --prompt instead of piping lines into the REPL:
python3 daniel.py --prompt "@gemini review this component"
python3 daniel.py --task my-task --prompt "@codex implement the TODO in TASK.md"Or install globally:
ln -s $(pwd)/daniel.py ~/.local/bin/agent-orchestrator- Python 3.10+
- At least one AI CLI installed:
claude— Claude Code CLIcodex— OpenAI Codex CLIgemini— Google Gemini CLIgrok— xAI Grok Build CLIagy— Google Antigravity CLI
- Optional: a Gemini API key for the Argon reviewer
/help Show all commands
/setup Rerun setup wizard
/models Show current model configuration
/modes Show CLI/API modes and permission modes
/modes set <agent> <full-host-unattended|sandboxed-auto>
/permissions Alias for /modes
/permissions set <agent> <full-host-unattended|sandboxed-auto>
/chains Show role fallback chains
/task Show current task
/task list List known tasks
/task <id> Switch task context
/run Run orchestrator script for current task
/smoke Smoke test all enabled agents
/kb <query> Search the knowledge base
/service status Show agent status (up/down/unavailable)
/service down <agent> <minutes|manual> Disable an agent
/service up <agent> Re-enable an agent
/service recover Re-enable ALL disabled agents
/allow-dir list List approved directories
/allow-dir add <path> Approve a directory
/allow-dir rm <path> Remove an approved directory
/quit Exit
impl: <message> Route to implementation chain
ui: <message> Route to UI/docs chain
@claude <message> Send directly to Claude
@codex <message> Send directly to Codex
@gemini <message> Send directly to Gemini
@grok <message> Send directly to Grok
@antigravity <message> Send directly to Antigravity (agy)
intel: <message> Route to Grok-first intel/research chain
x: <message> Alias for intel
| Service | Monthly Cost | What You Get |
|---|---|---|
| Claude Pro | ~$20 | Claude Code CLI with Opus |
| OpenAI subscription | ~$20 | Codex CLI |
| Google subscription | ~$20 | Gemini CLI |
| xAI subscription/API | varies | Grok Build CLI |
| Total | varies | Four premium AI agents |
No per-token API billing. CLI wrapping uses your subscription tiers. When one agent hits its usage cap, the orchestrator automatically routes to the next available agent.
If you're running knowledge-base-server, the orchestrator automatically searches it for relevant context before each response.
# Search KB manually
/kb docker networking
# KB context is auto-injected when you have an active task
/task my-project
> How should I set up the reverse proxy?
# Agent receives KB results for "my-project" as contextSet kb_port in config if your KB server runs on a non-default port.
You can bypass the normal role/failover chain and talk to a specific agent directly:
@codex what do you think about this refactor?
@gemini review this UI copy
@claude review what Codex and Gemini saidDirect addressing keeps the response labeled by agent, but skips automatic routing to the other providers unless you ask them separately.
Config lives at ~/.config/agent-orchestrator/config.json:
{
"name": "agent",
"tasks_root": "~/tasks",
"kb_port": "3838",
"claude_mode": "cli",
"codex_mode": "cli",
"gemini_mode": "cli",
"grok_mode": "cli",
"codex_cli_permission_mode": "full-host-unattended",
"gemini_cli_permission_mode": "full-host-unattended",
"grok_cli_permission_mode": "sandboxed-auto",
"antigravity_mode": "cli",
"antigravity_cli_permission_mode": "sandboxed-auto",
"models": {
"claude": "claude-sonnet-4-5",
"codex": "gpt-5",
"gemini": "gemini-2.5-pro",
"grok": "grok-4.7",
"antigravity": "",
"argon": "gemini-4-argon"
},
"chains": {
"orchestrator": ["claude", "codex", "gemini", "grok"],
"implementation": ["codex", "claude", "gemini", "antigravity", "grok"],
"uidocs": ["gemini", "codex", "claude", "antigravity", "grok"],
"review": ["claude", "codex", "gemini", "antigravity", "argon", "grok"],
"intel": ["grok", "gemini", "claude", "codex"]
}
}Everything is configurable. Change the name, reorder chains, swap models, switch between CLI and API mode per agent.
At runtime, you can inspect or change Codex/Gemini/Grok/Antigravity CLI permission modes without rerunning setup:
/modes
/permissions set codex sandboxed-auto
/permissions set gemini full-host-unattendedfull-host-unattended is the default for Codex and Gemini CLI mode. On trusted machines, this means:
- Codex uses
--dangerously-bypass-approvals-and-sandbox - Gemini uses
--approval-mode yolo --sandbox=false
If you want sandboxed automatic execution instead, switch a permission mode to sandboxed-auto.
Grok and Antigravity run with real shell and file tools, so their default is the sandbox, not the host:
| Mode | Grok | Antigravity (agy) |
|---|---|---|
sandboxed-auto (default) |
--sandbox workspace --permission-mode acceptEdits |
--sandbox --mode accept-edits |
full-host-unattended (opt-in) |
--always-approve --permission-mode bypassPermissions --sandbox off |
--dangerously-skip-permissions |
- Any value other than exactly
full-host-unattended(including a typo in the setup wizard) falls back tosandboxed-auto. - Opt in only inside a container or VM:
/permissions set grok full-host-unattended,/permissions set antigravity full-host-unattended. An existingconfig.jsonwritten by an older version may already contain"grok_cli_permission_mode": "full-host-unattended"; run/permissions set grok sandboxed-autoto move it to the safe default. - Both CLIs get a minimal environment (
PATH,HOME,LANG/LC_*,TERM,TMPDIR,USER,LOGNAME, plusXAI_API_KEYfor Grok if set), not a copy of your shell environment. Other secrets in your shell are not visible to them. - Their working directory is the directory you started Daniel in if it is an approved directory (
/allow-dir), otherwise the tasks directory. Daniel refuses to run them with$HOMEitself as the working directory. - Timeouts default to 1800s (
DANIEL_GROK_TIMEOUT_SECS/DANIEL_ANTIGRAVITY_TIMEOUT_SECS, orgrok_timeout_secs/antigravity_timeout_secsin config). On timeout or Ctrl-C the whole process group is killed.
- Grok:
grok login --device-auth(or setXAI_API_KEY). - Antigravity: run
agyonce interactively and sign in with your Google account. Daniel treats~/.gemini/antigravity-cliexisting as "signed in" (agy has no non-interactive auth check); a sign-in failure at run time puts it down until/service up antigravity.
Argon (gemini-4-argon, Gemini Interactions API) is used only in the review chain, and only when a Gemini API key is configured (keys.gemini or GEMINI_API_KEY). It cannot be addressed with @, is skipped by /smoke, and is dropped from any non-review chain. It is a pay-per-token API and there is no spending cap: the intended setup is a prepaid account with no card, so when the money runs out, it runs out. Instead Daniel classifies out-of-credit, billing, 402, quota and 429/RESOURCE_EXHAUSTED errors and takes Argon out of rotation until you run /service up argon. A call is never retried, and Daniel never buys or tops up anything. Timeouts are plain errors and do not disable it.
pip install -r requirements-dev.txt
python -m pytest tests -qThe tests mock all subprocesses and network calls.
The Codex and Gemini default CLI permission mode assumes you trust the host machine and the projects you point the agents at (Grok and Antigravity default to a sandbox, see above). In full-host-unattended, Codex and Gemini can act without pausing for human approval. Use sandboxed-auto if you want lower-friction automation with sandbox boundaries still enforced.
The orchestrator automatically detects when agents are unavailable:
| Error Pattern | Action | Recovery |
|---|---|---|
| Claude usage cap exhausted | Disable until reset time | Auto-recovers at reset |
| Rate limit (any agent) | 5-minute cooldown | Auto-recovers |
| Auth failure | Manual disable | /service up <agent> |
| Antigravity/Argon quota or 429 | Antigravity: 5-minute cooldown. Argon: manual disable (out of credit) | Argon: /service up argon |
| Timeout | Plain error, next agent tries | none |
| Model not found | Manual disable | Fix model, /service up |
| CLI not found | Marked unavailable | Install CLI |
Use /service recover to re-enable all disabled agents at once.
daniel.py (single file, ~1100 lines)
|
+-- Config: ~/.config/agent-orchestrator/config.json
|
+-- Agent Calls:
| +-- _call_claude_cli() / _call_claude_api()
| +-- _call_codex_cli() / _call_codex_api()
| +-- _call_gemini_cli() / _call_gemini_api()
| +-- _call_grok_cli()
| +-- _call_antigravity_cli()
| +-- _call_argon() (review chain only)
|
+-- Failover: _role_chain() -> _chat_once() -> try each agent
|
+-- Auto-downtime: _apply_auto_downtime() detects errors
|
+-- Context: _shared_context() + _kb_search()
|
+-- Output: colored, per-agent formatting
Single-file design is intentional. Easy to understand, easy to modify, easy to deploy.
Want to add a new agent? Three steps:
- Add it to the
AGENTStuple - Write
_call_newagent_cli()and_call_newagent_api()functions - Add it to
_call_agent()dispatcher and default chains
See the existing agent functions for the pattern. Each is ~30 lines.
MIT
Built by Shawn Daniel — powered by the agents it orchestrates.