dynamic-task-router
by Jacklee504
README.md
# 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-models` moves profiles to new model versions
as they ship, adds new and free models provisionally, and grades every model
from real outcomes.
## Quick start
DTR needs Node.js 22.12 or later.
```bash
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:
```bash
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](docs/mcp.md) 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](docs/evals.md#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.
```bash
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](docs/orchestrator.md) and
[routing guide](docs/routing.md). DTR ships with a model inventory and
read-only defaults; change them in your [personal configuration](docs/user-config.md),
and never put credentials there. See [providers](docs/providers.md),
[free cloud options](docs/free-cloud.md), [privacy](docs/privacy.md), and [cost routing](docs/cost-routing.md) before
enabling a remote provider.
Use [`dtr start`](docs/prompt-policy.md#two-step-compact-dispatch) 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](docs/prompt-policy.md) 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](docs/tui.md).
## 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](core/model-routing-policy.md) 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](docs/providers.md) 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](docs/opencode.md).
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](core/routing-contract.md):
1. The parent/lead owns the objective and final decision.
2. Each routed target gets a bounded outcome, non-overlapping write boundary,
and only the paths/symbols needed to do its work.
3. Returned evidence—not activity or optimism—drives integration.
4. A fresh, read-only reviewer checks the integrated result.
5. 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](https://github.com/Jacklee504/dynamic-task-router/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](LICENSE). It may not be used to build a
product that competes with DTR.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues