Delegate tasks between coding agents
Hand a task to Claude Code, Codex or opencode headlessly from the terminal, all through one AnyRouter key.
anyr delegate hands a task to another coding agent with the same AnyRouter key.
anyr delegate --to codex "add unit tests for src/utils/slug.ts"
anyr delegate --to claude "explain this stack trace" --model deepseek/deepseek-v3
anyr delegate --to opencode "fix the lint errors in packages/ui" --yesThe CLI starts the target's non-interactive mode (claude -p, codex exec, opencode run) with your stored key, base URL and model, streams its output, and exits with the agent's exit code. The target must be installed; if not, the CLI prints the install command.
| Flag | Meaning |
|---|---|
--to <agent> | Target: claude, codex, or opencode (required) |
--model <id> | Model for the run (default: your profile's default model) |
--yes | Skip the confirm prompt (required without a terminal) |
--dry-run | Show the exact command and environment (secrets redacted) |
--profile <name> | Use a named account |
Guardrails
- One hop. A delegated agent cannot delegate again, so agents cannot ping-pong tasks and spend.
- Confirmation. Terminal runs confirm first; non-interactive runs need
--yes. - Same key, same logs. Delegated runs appear in your request logs.
A session on the deprecated @anyr/agent runtime exposes the same thing as a model-callable tool, delegate_task(tool, task, model?), capped at 10 minutes. For new setups use anyr delegate.
For a lighter plan-then-execute pipeline without spawning an agent, see anyr task.
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer