Catalog PyPI
PACKAGE EXPLORERView in registry

agent-delegate

PyPI

Universal cheap-subagent CLI — route low-reasoning tasks from Claude Code / Codex to Ollama, LM Studio, OpenRouter, Anthropic Haiku, and other backends.

aiclaudecodexdelegatellmlmstudioollamaopenroutersubagent
Versions collected1
Direct dependencies2From release 0.2.0
Last observed20 Oct, 21:47 UTC

README

Version 0.2.0 documentation

agent-delegate — universal cheap-subagent CLI for AI coding tools

agent-delegate

Route low-reasoning work from Claude Code, Codex, Cursor, and other AI coding agents to a cheap or local LLM — Ollama, LM Studio, OpenRouter, Anthropic Haiku, vLLM, llama.cpp, Groq, or Cerebras.

PyPI Python CI License: MIT Stars

Claude Code and Codex burn upstream tokens — and weekly subscription quota — on tasks a local Ollama model handles fine: bulk file reads, boilerplate generation, log summarization, fact extraction. agent-delegate is a tiny, zero-dependency CLI that any AI coding tool can shell out to. The cheap model does the busywork; your reasoning-grade context stays clean.

┌─────────────────────┐    delegate ask/write/summarize    ┌──────────────────────┐
│ Claude Code, Codex, │ ────────────────────────────────►  │ Ollama / LM Studio / │
│ Cursor, Aider, etc. │ ◄────────────────────────────────  │ OpenRouter / Haiku   │
└─────────────────────┘            JSON result             └──────────────────────┘
                  ▲                                                  │
                  │       optional JSONL usage log                   │
                  └──────────────────────────────────────────────────┘

Main feature: high-reasoning manager, cheap coding workers

agent-delegate is designed for a specific operating model:

  1. Your expensive reasoning model plans the work, designs the architecture, writes precise specs, reviews output, and explains the result.
  2. A cheap/local worker model does bounded execution: bulk reading, boilerplate, tests, scaffolds, summaries, and fact extraction.
  3. The manager reports what was delegated, which profile/model handled it, and roughly how much implementation work was delegated.

Check the active worker model before delegating:

agent-delegate status
agent-delegate profiles show ollama

Typical local default:

default profile: ollama
default backend: openai-compat
default model:   qwen3-coder:480b-cloud
default host:    http://localhost:11434/v1

For machine-readable manager/worker handoffs, prefer --json:

agent-delegate ask --json --paths src tests --question "which modules need tests?"
agent-delegate write --json --context src tests --spec "draft tests for profile errors" --target tests/test_profiles.py --target-root .

After delegating, inspect the worker ledger:

agent-delegate ledger
agent-delegate ledger --json

The ledger reads the usage log and shows each delegated worker call with timestamp, command, profile, backend, model, tokens, duration, target when available, and session id when the parent tool provides one. Use it to support final summaries like:

Delegated implementation: ~70%
Worker model: profile=ollama backend=openai-compat model=qwen3-coder:480b-cloud
Worker calls: ask=1, write=2

The installed rule snippets also tell Codex/Claude to show a short visible note when delegation happens:

Delegating to agent-delegate worker: profile=ollama model=qwen3-coder:480b-cloud task="draft profile tests"

The manager / delegator pattern

agent-delegate splits work between two model tiers — the same way a senior engineer splits work between themselves and a junior:

RoleModelWhat it does
Manager (your AI coding tool)Claude Opus / Sonnet, GPT-5 / GPT-5-Codex, large reasoning modelPlans architecture. Decides what to build and why. Designs APIs and data models. Reads diffs and reviews delegated output. Catches security gaps. Debugs root causes. Owns the final code.
Delegator (agent-delegate)Ollama qwen3-coder, kimi-k2.6, Llama 3.3, Anthropic Haiku, Llama on Groq, anything cheapExecutes precise specs the manager wrote. Reads bulk files. Generates boilerplate. Summarizes long output. Extracts facts. Never makes decisions.

The manager stays in your reasoning-grade tool (Claude Code, Codex, Cursor). Its context window holds only what matters: your intent, the design, and reviewed outputs. The delegator is a one-shot CLI call — fresh context each time, results piped back, no pollution.

What the manager keeps for itself

  • Architectural decisions — module layout, dependency choices, API surfaces, data models
  • Security-sensitive code — auth flows, crypto, secret handling, input validation at trust boundaries
  • Root-cause debugging — anything needing tight iteration on live signal
  • Migrations and destructive state changes — anything where rollback is hard
  • Code review — manager always reviews delegate output before integrating
  • One-line surgical edits — round-trip cost > benefit
  • The narrative — explaining decisions to the user

What the manager delegates

  • Reading 3+ files to answer a focused question (agent-delegate ask)
  • Generating boilerplate — tests, types, scaffolding, configs, CRUD endpoints, glue code (agent-delegate write)
  • Summarizing long output — logs, transcripts, build output, diffs (agent-delegate summarize)
  • Extracting facts — pulling specific values, identifiers, structure from a corpus (agent-delegate ask)

The bundled rule snippets (agent-delegate install) inject this split into the manager's system prompt, so Claude Code / Codex automatically know when to shell out.


Why

Without agent-delegateWith agent-delegate
Claude/Codex reads 8 files just to scaffold one test → ~40k upstream tokensLocal qwen3-coder reads those 8 files, returns the test → ~0 upstream tokens
Long log summarization eats your 5-hour capCheap model summarizes, only the summary enters upstream context
Boilerplate generation burns weekly quotaFree local model writes it; you review
Locked to one provider's "weak model" mode (aider, cursor)Any OpenAI-compatible endpoint, switchable per call

Install

pipx install agent-delegate
# or
pip install --user agent-delegate

Zero runtime dependencies. Python 3.11+. Works on macOS, Linux, Windows.


Quickstart

# Answer a question from a corpus of files
agent-delegate ask --paths src/auth.py src/db.py --question "where is the session created?"
agent-delegate ask --paths "src/**/*.py" README.md --question "summarize the public API"
agent-delegate ask --paths src tests --question "which tests cover auth?"
agent-delegate ask --json --paths src --question "which modules define the CLI?"

# Generate a draft file from context + spec
agent-delegate write --context tests/test_users.py \
                     --spec "draft a parallel test suite for the orders table" \
                     --target tests/test_orders.py
agent-delegate write --stdout --context src/agent_delegate/cli.py \
                     --spec "draft argparse help text for the write command"
agent-delegate write --context src tests \
                     --spec "draft tests for profile errors" \
                     --target tests/test_profiles.py \
                     --target-root .

# Summarize anything piped in
tail -n 500 server.log | agent-delegate summarize

# Override profile / model per call
agent-delegate --profile haiku ask --paths README.md --question "..."
agent-delegate --profile openrouter --model meta-llama/llama-3.3-70b-instruct summarize < diff.txt

# Short alias
ad ask --paths README.md --question "what does this CLI do?"

One-time setup for AI coding tools

agent-delegate install

Idempotently injects a "delegation policy" rule block into:

ToolTarget
Claude Code (CLI)~/.claude/CLAUDE.md
Codex CLI~/.codex/AGENTS.md
Claude desktop appprinted snippet for the Project instructions UI
Codex web appprinted snippet for the Project instructions UI

Each block is bounded by <!-- agent-delegate:begin vX.Y.Z --> ... <!-- agent-delegate:end --> markers, so re-running install upgrades cleanly and uninstall strips the block while preserving everything else.

Preview before writing:

agent-delegate install --dry-run
agent-delegate install --print claude-desktop   # just dump the snippet

Backends

BackendProfileBase URLAuth
Ollama (local + cloud)ollamahttp://localhost:11434/v1none
LM Studiolmstudiohttp://localhost:1234/v1none
OpenRouteropenrouterhttps://openrouter.ai/api/v1OPENROUTER_API_KEY
Anthropic Haikuhaikuhttps://api.anthropic.com/v1ANTHROPIC_API_KEY
vLLM(custom)configurableoptional
llama.cpp server(custom)http://localhost:8080/v1none
OpenAI / Groq / Cerebras / Together / Fireworks / Hyperbolic(custom)their hosttheir API key

Any OpenAI-compatible endpoint works — drop your own profile into ~/.agent-delegate/profiles.toml. Anthropic native API has its own adapter (backend = "anthropic").


Profiles

agent-delegate reads ~/.agent-delegate/profiles.toml. Write a starter file with the bundled defaults:

agent-delegate profiles init

Example:

default_profile = "ollama"

[profiles.ollama]
backend = "openai-compat"
base_url = "http://localhost:11434/v1"
default_model = "qwen3-coder:480b-cloud"

[profiles.lmstudio]
backend = "openai-compat"
base_url = "http://localhost:1234/v1"
default_model = "qwen2.5-coder-32b-instruct"

[profiles.openrouter]
backend = "openai-compat"
base_url = "https://openrouter.ai/api/v1"
api_key_env = "OPENROUTER_API_KEY"
default_model = "meta-llama/llama-3.3-70b-instruct"

[profiles.haiku]
backend = "anthropic"
api_key_env = "ANTHROPIC_API_KEY"
default_model = "claude-haiku-4-5"

[profiles.groq]
backend = "openai-compat"
base_url = "https://api.groq.com/openai/v1"
api_key_env = "GROQ_API_KEY"
default_model = "llama-3.3-70b-versatile"

Inspect:

agent-delegate profiles list
agent-delegate profiles show ollama
agent-delegate doctor          # ping each profile + check API keys

CLI reference

CommandWhat it does
askAnswer a question using one or more files as context
writeDraft a boilerplate file from context + spec; supports --stdout, --target-root, --diff, and fence stripping
summarizeCondense stdin (logs, transcripts, diffs)
installIdempotently inject delegation rules into AI tool configs
uninstallStrip injected rule blocks
statusShow install state + active profile + version
doctorProbe each profile for reachability + auth
ledgerShow recent delegated worker calls and aggregate counts by command/profile/model
profiles list / profiles show / profiles initManage profiles

Run agent-delegate <command> --help for full flags.

Use --json with ask, write, or summarize when another agent will parse the result. JSON success envelopes include ok, command, profile, model, content, and usage metadata when available. Error envelopes include ok: false plus structured error details.

Example success envelope:

{
  "ok": true,
  "command": "ask",
  "profile": "ollama",
  "model": "qwen3-coder:480b-cloud",
  "content": "The CLI entrypoint is src/agent_delegate/cli.py.",
  "usage": {
    "prompt_tokens": 1200,
    "completion_tokens": 80,
    "cached_tokens": 0,
    "reasoning_tokens": 0,
    "total_duration_ms": 1840
  }
}

Example error envelope:

{
  "ok": false,
  "command": "write",
  "profile": "ollama",
  "model": "qwen3-coder:480b-cloud",
  "target": "tests/test_profiles.py",
  "error": {
    "type": "target_exists",
    "message": "target exists, pass --force to overwrite: tests/test_profiles.py"
  }
}

ask --paths and write --context accept files, directories, and glob patterns. Directory and glob inputs are expanded in deterministic path order, deduplicated, and skip .git, node_modules, dist, build, and .next by default. AGENT_DELEGATE_MAX_FILE_BYTES limits each file, and AGENT_DELEGATE_MAX_CORPUS_BYTES limits the total expanded corpus.


What to delegate — and what NOT to

Good fits:

  • Reading 3+ files to answer a focused question
  • Generating boilerplate (tests, types, scaffolding, configs, CRUD endpoints)
  • Summarizing long logs, transcripts, build output, diffs
  • Extracting facts or identifiers from a corpus

Bad fits — keep these in your reasoning model:

  • Secrets, credentials, customer data, PII
  • Security decisions, auth flows, crypto
  • Root-cause debugging that needs tight iteration
  • Database migrations, anything that mutates production
  • One-line surgical edits (round-trip cost > benefit)

The bundled rule snippets enforce this split inside Claude Code / Codex.


Optional usage tracking

Set AGENT_DELEGATE_LOG_DIR=/path/to/dir to log every delegate call as JSONL. Each record includes timestamp, profile, backend, model, prompt/completion tokens, cwd, and parent process ID. Format is compatible with token-meter — the companion dashboard for tracking Claude / Codex / delegate token usage.


How it compares

ToolWhat it doesWhy agent-delegate is different
aider --weak-modelAider's cheap-model modeAider-only; not callable from Claude Code, Codex, Cursor
cursor delegate (hypothetical)Editor-bundled subagentIDE-locked, single provider
litellm proxyMulti-provider proxyDifferent layer — agent-delegate is the CLI verb your agent calls
agent-delegateUniversal CLI verbAny AI tool can shell out; any OpenAI-compatible endpoint or Anthropic; zero deps

Contributing

PRs welcome. Local dev:

git clone https://github.com/aliaihub/agent-delegate.git
cd agent-delegate
pip install -e ".[dev]"
pytest
ruff check src tests

Keep the package zero-dep (stdlib only) and Python 3.11+ compatible. See CONTRIBUTING.md.

Security disclosures: see SECURITY.md. Bug reports and feature requests via issues.


License

MIT © 2026 — see LICENSE for full text.


Keywords: ollama CLI, claude code subagent, codex delegate, claude haiku cheap, openrouter cli, llm router, ai coding agent, cost reduction, token budget, quota tracker, LM Studio CLI, vLLM, llama.cpp, prompt cache, multi-backend LLM, local LLM, openai-compatible CLI, claude code rules, codex AGENTS.md, AI tool delegation, agent SDK companion.

Downloads & popularity

2downloads
1-day window · source-reported counts20 Oct 2026
840
2026-07-23: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-07-23–2026-07-232026-07-24: 4 · observed 2026-10-21T10:22:39.7484634Z · period 2026-07-24–2026-07-242026-07-25: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-07-25–2026-07-252026-07-27: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-07-27–2026-07-272026-08-02: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-02–2026-08-022026-08-04: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-04–2026-08-042026-08-07: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-07–2026-08-072026-08-09: 3 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-09–2026-08-092026-08-14: 6 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-14–2026-08-142026-08-17: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-17–2026-08-172026-08-23: 3 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-23–2026-08-232026-08-24: 7 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-24–2026-08-242026-08-26: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-26–2026-08-262026-08-28: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-28–2026-08-282026-08-29: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-29–2026-08-292026-08-31: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-08-31–2026-08-312026-09-01: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-01–2026-09-012026-09-03: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-03–2026-09-032026-09-06: 6 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-06–2026-09-062026-09-07: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-07–2026-09-072026-09-08: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-08–2026-09-082026-09-12: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-12–2026-09-122026-09-13: 4 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-13–2026-09-132026-09-14: 4 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-14–2026-09-142026-09-16: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-16–2026-09-162026-09-17: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-17–2026-09-172026-09-19: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-19–2026-09-192026-09-20: 6 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-20–2026-09-202026-09-22: 3 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-22–2026-09-222026-09-23: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-23–2026-09-232026-09-26: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-26–2026-09-262026-09-27: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-27–2026-09-272026-09-28: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-28–2026-09-282026-09-29: 3 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-29–2026-09-292026-09-30: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-09-30–2026-09-302026-10-02: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-02–2026-10-022026-10-06: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-06–2026-10-062026-10-08: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-08–2026-10-082026-10-09: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-09–2026-10-092026-10-10: 4 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-10–2026-10-102026-10-11: 4 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-11–2026-10-112026-10-12: 3 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-12–2026-10-122026-10-13: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-13–2026-10-132026-10-14: 5 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-14–2026-10-142026-10-15: 6 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-15–2026-10-152026-10-16: 1 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-16–2026-10-162026-10-17: 8 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-17–2026-10-172026-10-18: 3 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-18–2026-10-182026-10-20: 2 · observed 2026-10-21T10:22:39.7484634Z · period 2026-10-20–2026-10-20
23 Jul20 Oct

pypistats · 49 observations shown. Missing days are unknown. Source category: overall: without mirrors.

View observed values
Date / source periodValueObserved at
2026-10-20 – 2026-10-2022026-10-21T10:22:39.7484634Z
2026-10-18 – 2026-10-1832026-10-21T10:22:39.7484634Z
2026-10-17 – 2026-10-1782026-10-21T10:22:39.7484634Z
2026-10-16 – 2026-10-1612026-10-21T10:22:39.7484634Z
2026-10-15 – 2026-10-1562026-10-21T10:22:39.7484634Z
2026-10-14 – 2026-10-1452026-10-21T10:22:39.7484634Z
2026-10-13 – 2026-10-1322026-10-21T10:22:39.7484634Z
2026-10-12 – 2026-10-1232026-10-21T10:22:39.7484634Z
2026-10-11 – 2026-10-1142026-10-21T10:22:39.7484634Z
2026-10-10 – 2026-10-1042026-10-21T10:22:39.7484634Z
2026-10-09 – 2026-10-0922026-10-21T10:22:39.7484634Z
2026-10-08 – 2026-10-0822026-10-21T10:22:39.7484634Z
2026-10-06 – 2026-10-0622026-10-21T10:22:39.7484634Z
2026-10-02 – 2026-10-0212026-10-21T10:22:39.7484634Z
2026-09-30 – 2026-09-3012026-10-21T10:22:39.7484634Z
2026-09-29 – 2026-09-2932026-10-21T10:22:39.7484634Z
2026-09-28 – 2026-09-2812026-10-21T10:22:39.7484634Z
2026-09-27 – 2026-09-2712026-10-21T10:22:39.7484634Z
2026-09-26 – 2026-09-2612026-10-21T10:22:39.7484634Z
2026-09-23 – 2026-09-2312026-10-21T10:22:39.7484634Z
2026-09-22 – 2026-09-2232026-10-21T10:22:39.7484634Z
2026-09-20 – 2026-09-2062026-10-21T10:22:39.7484634Z
2026-09-19 – 2026-09-1912026-10-21T10:22:39.7484634Z
2026-09-17 – 2026-09-1712026-10-21T10:22:39.7484634Z
2026-09-16 – 2026-09-1612026-10-21T10:22:39.7484634Z
2026-09-14 – 2026-09-1442026-10-21T10:22:39.7484634Z
2026-09-13 – 2026-09-1342026-10-21T10:22:39.7484634Z
2026-09-12 – 2026-09-1212026-10-21T10:22:39.7484634Z
2026-09-08 – 2026-09-0812026-10-21T10:22:39.7484634Z
2026-09-07 – 2026-09-0712026-10-21T10:22:39.7484634Z
2026-09-06 – 2026-09-0662026-10-21T10:22:39.7484634Z
2026-09-03 – 2026-09-0312026-10-21T10:22:39.7484634Z
2026-09-01 – 2026-09-0112026-10-21T10:22:39.7484634Z
2026-08-31 – 2026-08-3122026-10-21T10:22:39.7484634Z
2026-08-29 – 2026-08-2912026-10-21T10:22:39.7484634Z
2026-08-28 – 2026-08-2812026-10-21T10:22:39.7484634Z
2026-08-26 – 2026-08-2612026-10-21T10:22:39.7484634Z
2026-08-24 – 2026-08-2472026-10-21T10:22:39.7484634Z
2026-08-23 – 2026-08-2332026-10-21T10:22:39.7484634Z
2026-08-17 – 2026-08-1722026-10-21T10:22:39.7484634Z
2026-08-14 – 2026-08-1462026-10-21T10:22:39.7484634Z
2026-08-09 – 2026-08-0932026-10-21T10:22:39.7484634Z
2026-08-07 – 2026-08-0722026-10-21T10:22:39.7484634Z
2026-08-04 – 2026-08-0422026-10-21T10:22:39.7484634Z
2026-08-02 – 2026-08-0212026-10-21T10:22:39.7484634Z
2026-07-27 – 2026-07-2722026-10-21T10:22:39.7484634Z
2026-07-25 – 2026-07-2512026-10-21T10:22:39.7484634Z
2026-07-24 – 2026-07-2442026-10-21T10:22:39.7484634Z
2026-07-23 – 2026-07-2312026-10-21T10:22:39.7484634Z

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.2.016 May 20262

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
aliaihub/agent-delegate

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:47 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:281a63d6325bffe23c466564c9fb6bfbb2855b64471e4b7089b4a304cc8dad64