A reliable delegation broker for AI CLIs (Claude, Codex, Antigravity) on Windows, Linux, and macOS.
Note on Guarantees: Relay-agent validates the execution and delivery contract (result-file creation, encoding, schema, artifact paths, and process completion). It does not verify the factual accuracy or reasoning quality of the AI-generated content.
Note on Cross-platform: The test suite runs on Windows, macOS, and Linux across Python 3.11β3.13 on every commit. All three providers have passed a deep audit against their real CLIs on Windows 11 β Claude Code 2.1.218, Codex CLI 0.144.3, and Antigravity 1.1.5 (see
docs/KNOWN_LIMITATIONS.md). Real provider CLIs have not yet been field-validated on Linux or macOS, where CI exercises mocks only. Validate each worker you intend to use withrelay doctor --worker <worker> --deep, and run it again whenever the underlying CLI is upgraded.
- β¨ Key Features
- π¦ System Requirements
- π Installation & Verification
- π‘ Usage & Task Files
- π€ OpenClaw / Hermes AI & Multi-Worker Delegation
- π Model Discovery & Limitations
- π JSON Result Contract
- β Adding New Workers (
relay add-agent) - βοΈ Configuration & Security
- π§Ή Cleanup and Retention
- π Documentation
Relay-agent is a reliable task broker designed to connect your always-on AI agents with powerful coding CLIs.
- π€ Supports Three Built-in CLIs: Natively supports task delegation to
Claude Code,Codex CLI, andAntigravity. - β Extensible via
add-agent: Register any external AI CLI that follows the standard worker contract (relay add-agent <id>). - π€ Designed for Agent Delegation: Always-on AI agents (like Hermes or OpenClaw) can hand off complex, long-running tasks to Relay-agent and retrieve the final results asynchronously.
- π Dedicated Workspaces: Each job runs from a separate Relay-agent managed workspace. This reduces accidental file collisions but is not a complete OS sandbox. Unattended use requires a dedicated low-privilege OS account.
- ποΈ Persistent History: Every delegated job's metadata, errors, and output paths are recorded in a local SQLite database.
- β Validated Delivery Contract: Relay-agent checks result-file creation, encoding, JSON/TXT structure, artifact paths, and process completion before publishing outputs.
- Windows 11, Linux, or macOS
- Python 3.11+
- At least one installed and logged-in worker CLI:
claudecodexagyβ optional, requires additional security verification
- For Hermes Unattended Execution: A dedicated low-privilege OS account is strictly required.
git clone https://github.com/miter37/Relay-agent.git
cd Relay-agentrelay.pyz is a build artifact and is not stored in the repository, so the
installer builds it on first run. This needs no network access and takes a
second. To build it yourself instead:
python build_release.pyPrefer not to build? Download
relay.pyzandSHA256SUMS.txtfrom the latest release, verify the checksum, and placerelay.pyzin this directory before running the installer.
Windows (PowerShell):
Set-ExecutionPolicy -Scope Process Bypass
.\scripts\install_windows.ps1Linux / macOS:
chmod +x scripts/install_unix.sh
./scripts/install_unix.shrelay init
relay doctor --worker claude --deep
relay doctor --worker codex --deepBecause Antigravity has strong permission bypass capabilities, it requires explicit opt-in after you have verified your OS-level isolation:
relay doctor --worker antigravity --deep
# ONLY run these if you have configured OS-level isolation:
relay config set workers.antigravity.security_verified true
relay config enable-worker antigravityUse direct task arguments for simple, short requests:
relay "Investigate today's major AI semiconductor news" --worker codexNote on fallback: --worker codex means "Try Codex first, but fallback if it fails." If you want only Codex, use --worker codex --no-fallback.
For long or structured tasks (recommended for agents), use a UTF-8 Markdown task file:
Windows (PowerShell):
relay run `
--task-file "D:\RelayInput\request.md" `
--worker claude `
--format json `
--machineLinux / macOS:
relay run \
--task-file "/home/relay/input/request.md" \
--worker claude \
--format json \
--machineRelay-agent can pass files along with the prompt (must be inside permitted input directories for Hermes):
relay run `
--task-file "D:\RelayInput\analyze.md" `
--attach "D:\RelayInput\report.pdf" `
--attach "D:\RelayInput\data.xlsx" `
--worker claude `
--format jsonBy registering the skill skills/hermes-relay/SKILL.md (Skill name: use_relay_agent) in your AI environment, OpenClaw or Hermes AI can use Relay-agent to delegate complex tasks and aggregate results.
Example: "Ask Claude, Codex, and Antigravity to propose an architecture for a cross-platform job queue, then compare their trade-offs."
To achieve this without falling back to a different worker on failure, the agent submits 3 separate asynchronous jobs with --no-fallback and --caller hermes.
β οΈ Important on--request-id: The request ID is an idempotency key. It must uniquely identify one logical request (e.g.,<conversation-id>-<task-id>-<worker>). Reusing the same ID returns the existing cached job, even if the task file has changed.
relay submit \
--task-file "task.md" \
--worker claude \
--format json \
--request-id "jobqueue-arch-claude" \
--caller hermes \
--no-fallback \
--machine
relay submit \
--task-file "task.md" \
--worker codex \
--format json \
--request-id "jobqueue-arch-codex" \
--caller hermes \
--no-fallback \
--machine
relay submit \
--task-file "task.md" \
--worker antigravity \
--format json \
--request-id "jobqueue-arch-agy" \
--caller hermes \
--no-fallback \
--machine(Note: If you omit --no-fallback, a failure in Claude might silently trigger a Codex retry, muddling which AI actually answered.)
Asynchronous Flow:
- Parse the
job_idfrom thesubmitJSON receipt. - Wait for completion:
relay wait <job_id> --machine - Get final receipt:
relay result <job_id> --machine - Read the actual output file from the
result_pathprovided in the receipt.
Relay-agent discovers models using worker-specific methods. Codex and Antigravity can provide account-aware catalogs when supported. Claude Code does not expose a complete non-interactive model-list API, so its results may include configured or known model candidates rather than a definitive account-level list.
relay models
relay models --worker codex --refreshChecking Model Availability (model-check):
Check whether a model is listed or can be minimally verified. Claude uses a small inference probe, while Codex and Antigravity currently check catalog membership.
relay model-check --worker claude --model sonnet --machine
β οΈ Warning on Claude Probe: A failed Claude model check (ok: false) does not strictly mean the model name is invalid. Authentication expiration, quota exhaustion, rate limits, or network timeouts will currently all returnfalse.
When requesting --format json, the file written to your --out path will follow this structure:
{
"schema_version": "1.0",
"status": "complete",
"answer": "The requested analysis...",
"sources": ["https://example.com"],
"uncertainties": ["Market volatility makes this unpredictable"],
"missing_items": [],
"artifacts": [
{
"name": "chart.csv",
"relative_path": "path/to/chart.csv",
"description": "Generated comparison chart"
}
]
}Important: The Relay-agent receipt status (e.g., completed) indicates successful CLI execution. The internal JSON status (e.g., complete or partial) indicates the AI's self-reported success on the actual task logic.
The three built-in workers (claude, codex, antigravity) cover most users, but any external AI CLI that follows the standard Relay worker contract can be registered interactively:
relay add-agent opencodeThe wizard prompts for:
- Worker ID (used as the
relay.tomlkey, e.g.opencode,grok-build) - Display name
- Executable path or name on
PATH - Command template using placeholders such as
{cli},{request_file},{result_file},{artifact_dir},{model} - Default model
- Optional advanced settings (max turns, extra args, env vars, timeout)
- Whether to enable the worker after registration
Once all inputs are collected, Relay runs doctor --deep as a health check. If the check fails, nothing is written to relay.toml β fix the issue and retry, or pass --skip-health-check to persist the registration anyway.
# Verify after registration
relay doctor --worker opencode --deep
relay run --worker opencode "Hello"
# Non-interactive registration (e.g. from a setup script)
RELAY_ADD_AGENT_ID=opencode \
RELAY_ADD_AGENT_COMMAND=opencode \
RELAY_ADD_AGENT_COMMAND_TEMPLATE='{cli} exec --prompt {request_file} --output {result_file}' \
relay add-agent --yesSee relay add-agent --help for all options and the full list of RELAY_ADD_AGENT_* environment variables.
Security & Unattended Execution:
To use --caller hermes, the operator must configure a low-privilege account and ACL isolation. After securing the host, acknowledge it:
relay security --machine
relay config set service_isolation_acknowledged trueSet default workers and fallbacks:
relay config set default_worker claude
relay config set fallback_order codex,antigravityRelay-agent automatically deletes expired internal staging and workspace directories according to job status:
- Completed: 7 days
- Partial: 14 days
- Failed: 30 days
- Cancelled: 14 days
- Orphan workspaces: 7 days
Note: Automated cleanup applies to Relay-agent's internal workspaces. Final result files and artifacts delivered to the configured --out and --artifacts destinations are not automatically deleted.
relay cleanup --statusFor deeper details, consult the docs/ folder: