feat(auto): scenario-aware candidate selection at bind time (background/deferred vs interactive vs long-context)
- Dominant language
- Rust
- Stars
- 41k
- Forks
- 3.6k
- Avg merge
- 13h 59m
- Merged PRs (30d)
- 299
Description
## Problem
Once routing is sticky (#6252), the single bind-time decision carries all the weight — and today the bind-time choice is only the per-turn classifier or the big/cheap heuristic (`crates/tui/src/model_routing.rs:29,227-309`). The Engine already knows the *scenario* of the work before the first turn: interactive chat vs durable deferred/background job vs long-context or tool-heavy session. Routing by scenario at bind time is a rules table, not a classifier, and it is the cheapest correct decision for most sessions.
## Change
Add scenario-aware candidate selection to binding creation:
1. Extend `AutoConfig` (`crates/tui/src/config.rs:2591`) with scenario preferences, e.g. `[auto.scenarios] background = "cheapest"`, `interactive = "default"`, `long_context = "capable"`, resolved against the same `ModelInventory` candidate set (`crates/tui/src/model_inventory.rs:77`).
2. `plan_turn_route` passes the session scenario (interactive turn, deferred/durable job, goal-mode run) into binding creation; the scenario picks the candidate tier, then the normal route resolution freezes it.
3. Scenario rules choose the *tier*; provider/credential policy still comes from `ModelInventory` readiness and the bind-time `cross_provider` scope.
4. Long-context/tool-heavy detection uses signals the Engine already has (declared context size, tool catalog), not a model call.
## Acceptance
- A deferred/background job on `auto` binds to the cheapest runnable candidate without a classifier call.
- An interactive session binds to the default tier; a session whose context exceeds a candidate's ceiling never binds to it.
- Every scenario-based binding is receipted with its scenario and tier (fields from #6253).
- Users can pin any scenario to a specific model in config; the pin wins over the tier rule.
Contributor guide
Research direction
Read crates/tui/src/model_routing.rs, especially plan_turn_route and the current bind-time decision, then inspect AutoConfig in crates/tui/src/config.rs and ModelInventory in crates/tui/src/model_inventory.rs. Trace how session scenarios, context size, and tool catalogs reach binding creation. Done means scenario tiers and pins resolve at bind time, respect readiness and context ceilings, avoid classifier calls where specified, and receipt scenario and tier fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- ai, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100