Files
Alessandro Frau 618c982678 Delegate to Claude Code as an official harness
Run Claude Code through a new a0-harness helper that the orchestrator skill copies into the workspace. The helper checks sign-in through Claude Code's own status command, removes model-provider API keys in subscription mode, refuses to run on a billing-mode mismatch, allows one delegation at a time by default, and stops on a rejected usage limit without retrying.

The skill now opens with account rules: Agent Zero never signs in, never touches credential stores, never calls a model vendor itself, and never switches accounts. The Claude Code adapter no longer inspects or deletes the credentials file, and the default permission mode is acceptEdits instead of bypassPermissions. Other adapters are unchanged.

With consent, the helper registers as Claude Code's status line command and caches the 5-hour and 7-day plan windows. The Welcome account card shows them as a reading reported by Claude Code. The README gains a quick start.

27 orchestrator tests pass, including 13 helper tests against a fake claude binary. A real delegation succeeded against Claude Code 2.1.337 in API-key mode. The host route through the Launcher gateway, a run on a Claude plan, and the rendered Welcome card are not yet verified.
2026-12-05 02:47:56 +01:00
..
2026-07-09 13:18:44 +02:00
2026-07-09 13:18:44 +02:00

Orchestrator

Load-on-demand guidance for orchestrating external terminal coding agents from Agent Zero without keeping a large delegation tool in every agent prompt.

Quick Start

There is nothing to click. Ask Agent Zero in chat, naming the coding agent:

  • "Use my local Claude Code to refactor the parser in ~/code/app and run its tests."
  • "Consult Codex CLI on this migration plan before writing any code."
  • "Ask Claude Code and Codex for a second opinion on this diff, then compare their answers."

Agent Zero loads the orchestrator skill, asks once whether to use the agent on your computer or one inside its container, hands over a self-contained brief, and reviews the result before reporting back. For your own computer, open the Instance in A0 Launcher with Host access and Code execution on, or connect A0 CLI and press F4.

The plugin provides:

  • an orchestrator skill that tells Agent Zero how to use external CLIs through the user's A0 CLI host bridge or the normal container shell;
  • a Settings > External Services status screen for configured binaries and detected auth state;
  • adapter metadata for Agent Zero headless, OpenAI Codex CLI, Claude Code, Cursor CLI, Gemini CLI, Grok Build, Hermes Agent, OpenCode, and future terminal agents.

There is intentionally no terminal_agent tool and no settings-screen install button. When the user explicitly asks for a terminal agent, the skill first decides whether to use the user's own host CLI through A0 CLI or a pal agent inside the Agent Zero container.

Host CLI is the primary everyday flow: the user's Claude Code, Codex, Cursor CLI, and other coding agents stay installed and logged in on their own computer. Container agents remain useful when the user explicitly wants the Docker runtime.

Supported Agents

Agent CLI Login
Agent Zero (headless) a0 Instance /login session; A0_USERNAME/A0_PASSWORD in the shell for protected hosts
OpenAI Codex codex ChatGPT device login from settings or external CLI login
Claude Code claude Your own claude auth login; Agent Zero never signs in for you
Cursor CLI agent CURSOR_API_KEY, NO_OPEN_BROWSER=1 agent login, or cached Cursor login
Gemini CLI gemini Cached Google login, GEMINI_API_KEY, or Vertex AI credentials
Grok Build grok XAI_API_KEY, grok login --device-auth, or cached Grok login
Hermes Agent hermes External Hermes/provider setup, ~/.hermes/.env, ~/.hermes/auth.json, or provider env vars
OpenCode opencode External opencode auth login, provider env vars, or ~/.local/share/opencode/auth.json

The a0 adapter targets the local Agent Zero instance (http://localhost:80 inside the container) when no host/AGENT_ZERO_HOST is configured, or another Agent Zero instance when you set a host. This lets A0 delegate to another runtime, and also lets the same runtime ask itself a focused question as a secondary use case. A0 is the setup exception: if the user did not specify a target, Agent Zero should ask whether to use the same instance or another/spun-up instance instead of running a generic login flow. The skill tells the target A0 instance to answer directly and not delegate back through terminal agents.

Skill Usage

Ask Agent Zero to load/use the orchestrator skill before delegating coding work to one of these CLIs. The skill keeps the global setup loop in skills/orchestrator/SKILL.md and reads one per-agent reference from skills/orchestrator/references/ before acting.

If the user does not specify host versus container, Agent Zero asks and saves a per-agent preference with memory action=save. Local/host mode uses the connector's code_execution_tool with destination: host tool and may load host-code-execution; container mode uses code_execution_tool.

For local/host coding agents, the user should run A0 CLI on their own machine:

# macOS / Linux
curl -LsSf https://cli.agent-zero.ai/install.sh | sh
# Windows PowerShell
irm https://cli.agent-zero.ai/install.ps1 | iex

If A0 CLI is installed but not running, open a terminal and run a0, connect it to the Agent Zero instance, choose the chat/session or enter the remote/VPS URL, then press F4 for Remote Code Execution. Press F3 too when host file writes are needed. After that, asking Agent Zero to use local Claude Code/Codex/etc. will run commands on the host machine instead of inside Docker.

The skill must not use Computer Use to drive coding-agent terminals or TUIs. It uses headless CLI commands. The ACP community plugin can be a separate path when explicitly requested or when direct CLI automation is unsuitable.

The reference files contain the copy-ready commands, for example Codex:

cd "$WORKDIR"
codex exec --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox "$TASK"

Claude Code

Claude Code is delegated to as an official harness: Agent Zero starts your own installed, unmodified claude binary in its documented headless mode and reads its events. Claude Code keeps the agent loop, its tools and permissions, its login and its billing. Agent Zero decides what to delegate and reviews the answer.

The skill runs it through a small helper, a0_harness.py, which the agent copies into .a0-harness/ in the workspace:

python3 .a0-harness/a0_harness.py preflight
python3 .a0-harness/a0_harness.py run --workdir "$WORKDIR" --task-file task.md

The helper prints the exact claude command it runs and writes JSON lines on stdout. In code, not just in instructions, it:

  • removes every model-provider API key from Claude Code's environment in subscription mode, so your plan is billed rather than an API account;
  • refuses to run when Claude Code reports a billing mode other than the one you selected, so you are never moved between plan and API billing silently;
  • allows one delegation at a time by default;
  • stops on a rejected usage limit, reports the reset time, and never retries.

What Agent Zero does not do: install or update Claude Code, sign in for you, open Claude Code's credential files or tokens, call Anthropic itself, or switch accounts. If Claude Code is signed out, you get the command to run (claude auth login) and Agent Zero waits. The helper cannot stop an agent with a shell from reading files, so credential protection ultimately relies on the skill's instructions; neither the Launcher gateway nor the container can deny those paths to the shell today.

Settings > External Services > Orchestrator > Claude Code holds the billing mode (your Claude plan, or an Anthropic API key), the parallel-delegation limit, the unattended-runs opt-in, and the permission mode. The default permission mode is Claude Code's acceptEdits; skipping permissions is available but never the default. Extra usage and overage are controlled in your Claude account, not here.

This design follows Anthropic's published rules for Claude Code as read in December 2026. It is not an approval from Anthropic.

Usage on the Welcome screen

With your consent, the helper registers itself as Claude Code's status line command. Claude Code then hands it your 5-hour and 7-day plan usage, which the Welcome screen shows as remaining percentages with the time of the reading.

  • It is a cached reading reported by Claude Code, not a live meter and not an official Anthropic figure.
  • It refreshes only while you have an interactive Claude Code session open; headless delegations do not update it.
  • statusline-install shows the exact change to ~/.claude/settings.json and writes only with --yes. An existing status line keeps rendering. statusline-uninstall restores the previous setting.
  • The rows are hidden in API-key mode, and show "no reading" when host code execution is turned off in the Launcher.

If another non-A0 CLI is missing or asks for login/browser confirmation, Agent Zero can install the requested CLI, start its setup/login command, relay the exact human step, wait for the user to confirm, then retry a smoke prompt before running the real task. If setup shows provider/menu choices, Agent Zero should show those options in chat and ask which one to select, not send the user to a Docker shell just to choose from a menu. It should not ask the user to paste secrets into chat unless there is no safer path.

Login And Status

Open Settings > External Services > Orchestrator to see registered adapters, binary paths, installed status, and detected auth source. The screen can refresh status and disconnect credentials only when an adapter can safely remove a known credential store.

Codex still supports plugin-owned device-code login from the settings screen. Those tokens are stored under the plugin data directory (data/codex/auth.json, mode 600), and the skill can point Codex at that home when needed. If you have already logged in with codex login, the status screen detects the external credentials too.

Tokens are password-equivalent credentials. Never share one rotating refresh-token auth file between two clients; plugin-owned Codex credentials stay separate from other tools.

Configuration (default_config.yaml)

a0:
  binary: a0          # falls back to /usr/local/bin/a0 in Agent Zero Docker
  host: ""           # empty = AGENT_ZERO_HOST env, else local instance
codex:
  binary: codex
  model: ""
  bypass_sandbox: true
claude:
  binary: claude
  model: ""
  auth_mode: subscription
  max_concurrency: 1
  allow_unattended: false
  permission_mode: acceptEdits
  allowed_tools: ""
cursor:
  binary: agent
  output_format: text
  force: true
gemini:
  binary: gemini
  model: ""
grok:
  binary: grok
  model: ""
  output_format: json
  always_approve: true
  no_auto_update: true
hermes:
  binary: hermes
  model: ""
  provider: ""
  toolsets: ""
  yolo: true
opencode:
  binary: opencode
  model: ""
  agent: ""
  auto: true

Adding A New Agent

  1. Create helpers/adapters/<name>.py subclassing TerminalAgentAdapter (helpers/adapters/base.py) and implement auth_status(). Add optional safe disconnect or device-login support only when the credential store is known.
  2. Register an instance in helpers/registry.py.
  3. Add a config block in default_config.yaml.
  4. Add concise command guidance to skills/orchestrator/references/<name>.md.
  5. Add the reference to skills/orchestrator/SKILL.md and update generic skill guidance only when the global orchestration loop changes.

The status API and settings UI pick registered adapters up automatically.