Repository navigation
feat(cli): route new runs, missions, delegated children and cron runs (#586 part 2) - #652
Merged
Merged
Conversation
tole_core::router: a Router returns a Route (tier light/standard/heavy, source, reason), never a model name, budget, allow list or secret. RuleRouter takes every matching rule, picks the cheapest tier (ties go cheaper; the first rule of that tier names the route), narrows to an allowed-tier set, and keeps the configured model when nothing matches. check() refuses a rule whose tier is not declared where it resolves or an unknown profile, naming the remedy. Route::record redacts with the process secrets before it caps. Platform-agnostic, no new dependency.
…part 1b) [router] is off unless the user config says enabled = true. Tiers ([router.tiers], profiles.<name>.models) and rules come from the user config only; a project config can only set enabled = false or narrow allow_tiers, and anything else is ignored with a warning. An unknown tier, kind or risk, an undeclared tier or an unknown profile is a load error naming the remedy, never a fallback to another model. tole route prints the tier, model and reason a run would get without calling a provider, redacted; tole doctor and config check show names only.
…#586 part 2) With [router] enabled in the user config, a new run, chat, TUI session, mission, delegated child (TOLE_AGENT_DEPTH >= 1, routed as delegate) and cron agent run is routed once, before its first provider call; resumed sessions keep their model. An explicit model wins: a session that already has fact/model and a cron job with a --model pin are not routed. The routed model is stored as fact/model and the decision, redacted then capped, as fact/route. Budgets, allow lists, plan mode and secrets are untouched. A broken router stops the run before its session file exists (a cron run fails with the remedy).
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 2 of #586: the RuleRouter wired into the places a model is chosen today, behind config and off by default. Merging this PR closes #586.
Depends on: #650 (part 1a,
tole_core::router) and #651 (part 1b,[router],tole route, doctor), both merged. This branch has the latestdevelopmerged in (a merge commit) and now targetsdevelop.Why
Parts 1a and 1b made routing declarable and checkable, but nothing used it. This applies a route to the run it was made for, once per run and never per turn, so the prompt cache survives. Nothing but the model changes.
Changes
routing::route_new_session, the single entry point:[router] enabled = true;fact/modelis left alone (an explicit choice wins);fact/model(when a rule matched) and the decision asfact/route(Route::record: redacted, then capped);routing::mission_kind: a mission withTOLE_AGENT_DEPTH≥ 1 (a delegated child) routes asdelegate.tole_core::tool::ToolRegistry::max_riskfeeds the brief's tool risk.Call sites, each after the session exists and before the provider is built:
run_command,chat_command(fresh only),tui_command(fresh only, quiet), all throughHostConfig::route;mission::run_mission(fresh only), through a closure that carries the mission's budget tier;cron::agent::run_agent: a new run of a job without a--modelpin, on the job's own prompt (never the webhook context), with the job name, profile and token budget.Owner decisions (2026-11-13), as documented in feat(cli): [router] config, tole route dry run and doctor lines (#586 part 1b) #651:
TOLE_MODEL, the config'smodelor a profile's default; only a session's own model and a cron job's--modelpin are never routed;profilesapplies only to runs without a profile.tole routekeeps feat(cli): [router] config, tole route dry run and doctor lines (#586 part 1b) #651's wording, which shows the configured model and its source.No stray session files:
run,chat, the TUI andmissioncheck the router before their session file exists, so a broken router leaves nothing behind. A cron run fails with the remedy.Unchanged: budgets, allow lists, plan mode and secrets are built exactly as before, and the e2e test compares the tools sent with and without a route.
tole serve/ ACP sessions and the TUI's/neware not routed.Docs: CHANGELOG, design A9.3 "as implemented, part 2", the threat-model row, the README status line and config row, and
docs/epics.md, all per AGENTS.md §7.Testing
cargo fmt --allcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspacecargo test -p tole-core --no-default-featurescargo check -p tole-cli --no-default-featurescargo clippy -p tole-cli --no-default-features --features shell-tools -- -D warningscargo test -p tole-cli --no-default-featuresdevelop.cora review --no-llm --staged: no issues (on the part 2 commit; the merge only resolved conflicts with feat(cli): [router] config, tole route dry run and doctor lines (#586 part 1b) #651's text).routing_tests.rs;tests/router_wiring_e2e.rs: 4 tests on the real binary with a mock provider. They cover:mission, and asdelegateat depth 1;