Dynamic Task Router
v0.5.0Routes coding tasks to the cheapest model that handles them safely, using your signed-in CLIs.
Send each coding task to the cheapest model that can handle it safely, without leaving the chat you are working in. DTR sits between your coding assistant (Claude Code, Codex, or any MCP client) and the models you already have. It sizes each delegated task by role, difficulty and risk, picks a model and reasoning effort for it, runs it read-only, and hands back a short, structured answer instead of a whole transcript. Two real routes in a small repository. A trivial lookup goes to a fast model at low effort; a high-risk security review gets a stronger model at high effort.
Summary extracted from the README.
Dynamic Task Router
Send each coding task to the cheapest model that can handle it safely, without leaving the chat you are working in.
DTR sits between your coding assistant (Claude Code, Codex, or any MCP client) and the models you already have. It sizes each delegated task by role, difficulty and risk, picks a model and reasoning effort for it, runs it read-only, and hands back a short, structured answer instead of a whole transcript.
- Spend less. Routine reviews go to fast models; only difficult or high-risk tasks reach the strongest ones. In a small benchmark (3 cases, one run each), routed tasks matched always using the strongest model, 3 of 3, at 80% lower cost.
- Keep your chat's context small. The worker reads the files and your chat gets back a compact handoff. In benchmark runs, 81–91% of the tokens stayed out of the calling chat.
- Use what you already pay for. DTR reuses your signed-in Claude Code, Codex, Antigravity and OpenCode CLIs, so those need no API keys. Free OpenCode and OpenRouter models and local Ollama models work too.
- Safe by default. Routes are read-only. Writes need an explicit scope and run in an isolated git worktree. If a CLI lacks a safety flag DTR relies on, DTR refuses to run it.
- Stays current.
dtr update-modelsmoves profiles to new model versions as they ship, adds new and free models provisionally, and grades every model from real outcomes.
Example
Two real routes in a small repository. A trivial lookup goes to a fast model at low effort; a high-risk security review gets a stronger model at high effort. Each returns a short handoff, not a transcript.
$ dtr route --complexity trivial --task "Which function in src/format.ts formats currency?" --files src/format.ts
dtr: selected claude-haiku (claude/haiku, low)
dtr: worker route started for researcher
dtr: worker route completed
STATUS: done – `formatMoney(value, currency = "USD")` at `src/format.ts:5` formats currency, using `Intl.NumberFormat` with `en-US` and `style: "currency"`.
PATHS: inspected `src/format.ts`. Nothing was changed.
CHECK: not run. This was a read-only lookup.
RISK: none
$ dtr route --role reviewer --risk high --task "Security review of src/users.py. Report the worst issue and the fix." --files src/users.py
dtr: selected claude-sonnet (claude/sonnet, high)
dtr: worker route started for reviewer
dtr: worker route completed
STATUS: done. Worst issue: SQL injection at `src/users.py:3`. `find_user` concatenates `email` into the query, so crafted input can alter the lookup or expose other database data. This is critical if callers pass untrusted input.
Fix (not applied):
`cur.execute("SELECT id, name FROM users WHERE email = ?", (email,))`
Use `?` for sqlite3; psycopg and common MySQL drivers use `%s`. Keep the parameter tuple.
PATHS: inspected `src/users.py`
CHECK: not run; static read-only review (plan mode).
RISK: Database driver and callers uninspected; confirm placeholder style and add an injection regression test. No plan file written; no changes made.
Quick start
DTR needs Node.js 22.12 or later.
npm install -g dynamic-task-router # installs the `dtr` and `dtr-mcp` commands
cd /path/to/your-repository
dtr health # which of your providers DTR can use
dtr route --task "Review src/auth.ts for correctness bugs and name the focused test." --files "src/auth.ts"
dtr # or open the interactive terminal UI
To call DTR from your assistant, register it as an MCP server:
claude mcp add -s user dynamic-task-router -- dtr-mcp # Claude Code, all projects
codex mcp add dynamic-task-router -- dtr-mcp # Codex
See MCP for other clients. When a newer version is published,
dtr prints a one-line notice (checked at most once a day; set
DTR_NO_UPDATE_CHECK=1 to turn it off). Update with
npm install -g dynamic-task-router. Model profiles update separately and
automatically through dtr update-models. To check whether routing pays off with your own models,
run dtr benchmark --dry-run, then dtr benchmark --free to try it at no
cost; see benchmark.
How it works
DTR is a read-only runtime by default. It uses your existing Claude Code, Codex, Google Antigravity and OpenCode CLI sign-ins, never API keys for those account-backed routes, and can run local Ollama models through Codex OSS mode. It selects a model and internal effort independently, can fan out read-only analysis to independent model families, and supports optional OpenRouter and Featherless API adapters. Writing to a repository stays opt-in and isolated.
dtr health
dtr models
dtr opencode-models
dtr usage --cwd /path/to/repository
dtr models refresh
dtr select --role reviewer --complexity difficult --risk high
dtr start
dtr route --task "Find why valid signals never reach order submission; identify the failing handoff and check its focused test." --files "src/signals.ts,src/orders.ts,test/orders.test.ts"
dtr run --allow-raw-prompt --provider codex --model codex-terra --effort high --role reviewer --cwd /path/to/repo --prompt "Review the execution pipeline. Do not modify anything."
--cwd chooses the repository to inspect or run against; DTR does not create
.dtr/ files there. Optional run metadata and isolated worktrees live under
an operating-system temporary directory instead.
See the orchestrator guide and routing guide. DTR ships with a model inventory and read-only defaults; change them in your personal configuration, and never put credentials there. See providers, free cloud options, privacy, and cost routing before enabling a remote provider.
Use dtr start before a
normal CLI route. It gives a caller the compact dispatch contract; dtr route
then enforces its 100-word task limit and accepts file paths only. Use the
prompt policy only for small, token-budgeted
provider-specific instructions.
Choose an interface
Use DTR in one of three ways: an interactive terminal UI (dtr or dtr tui
from a TTY), the scriptable CLI (dtr route ...), or its local STDIO MCP
server. All three use the same application/routing layer; the terminal UI does
not call provider CLIs or APIs directly. See TUI guide.
Host plugins
Plugins that teach Codex (visible subchats), Claude Code (subagents) and Qwen Code (subagents) to route through DTR on their own are in development and not yet distributed. Until then, connect your assistant through the MCP server.
Dynamic model routing
When a routing run begins, the parent classifies each candidate task, assumes
medium routing level unless specified otherwise, and selects the smallest
permitted tier that can safely complete it: fast, standard, deep, or critical.
low may select one cheaper eligible tier; high may select one stronger tier.
The host adapter maps that tier to its native subchat or subagent controls. See the shared
model routing policy for the decision rules and
host mappings.
Codex at medium routing level
Medium is the default routing level; it preserves the task-class baseline rather than forcing every subchat onto one model. Select the model's internal effort separately from the role and risk. In Codex, that means:
| Task shape | Codex selection |
|---|---|
| Narrow read-only triage | Luna / low effort |
| Tightly bounded implementation or review | Luna / high effort |
| Ordinary isolated task | Terra / effort by role |
| Core or cross-cutting task | Terra / normally high effort |
| Critical task or review | Sol / normally high effort |
When Antigravity is available, the same tiers map to its account-visible
catalogue: Flash Low, Flash Medium, Flash High, then Gemini Pro High. Its
Claude models remain deep/critical alternatives rather than defaults. DTR
discovers the models the signed-in account can actually use with agy models.
See providers for the isolation boundary and setup.
OpenCode is a separate configured-model catalog. DTR can discover it without reading credentials, but each model needs an explicit DTR quality/role profile before automatic routing can select it. See the OpenCode guide.
Use low only when a cheaper tier remains safe, and high when a stronger tier
is justified by ambiguity or dependency analysis. Those routing labels do not
set internal effort: a low-level route can use Luna/high for a bounded code
change. Critical tasks never reduce below Sol.
Shared contract
Every adapter follows the routing contract:
- The parent/lead owns the objective and final decision.
- Each routed target gets a bounded outcome, non-overlapping write boundary, and only the paths/symbols needed to do its work.
- Returned evidence—not activity or optimism—drives integration.
- A fresh, read-only reviewer checks the integrated result.
- Stop and restart actions are honest about what the host actually did.
Why separate adapters?
The workflow is portable, but host controls are not. Codex uses app-owned subchats; Claude Code uses subagents and, when explicitly enabled, agent teams; Qwen Code uses extension commands and subagents. Keeping their instructions separate lets each be concise, accurate, and safe.
Feedback
Bug reports and feature requests are welcome in
GitHub Issues.
Please include dtr --version and, for a failed route, the output of
dtr doctor. Code contributions are not accepted at the moment.
License
DTR is free to use, including at work, under the PolyForm Shield License 1.0.0. It may not be used to build a product that competes with DTR.