fix(router): let [router] model rules reach daemon-dispatched items - #577
Conversation
resolve_agent's explicit branch and route()'s assigned_agent short-circuit both used to return model: None unconditionally, so a rule's model field was unreachable for any item with an already-fixed agent -- which is every normal daemon dispatch. Add model_for_task() to look up a matching rule's model independent of agent selection, and call it from both short-circuits while leaving the already-fixed agent untouched. Agentflare-Agent: claude-code Agentflare-Branch: task/162-feature-make-router-model-rules-actually Agentflare-Item: 162
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughThe router now exposes configured model lookup for task contexts. Explicit agent resolution preserves the selected agent while applying a matching rule’s model. Automatic routing reuses the shared task-context construction. Tests cover both behaviors. ChangesRouting model resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change allows configured router model mappings to reach daemon-dispatched items without changing explicit agent selection or override precedence; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
87b4ba8 to
d5fc407
Compare
Summary
Two stacked short-circuits in
resolve_agent()(src/cli/work.rs) androute()(crates/agent-registry/src/router.rs) both returnedmodel: Noneunconditionally whenever the agent was already fixed — true for every normal daemon dispatch (the daemon always passes an explicit agent). This meant a[router]rule'smodelfield, and therefore the Claude→ClinePass model mapping (clinepass_model_for_claude, already built and unit-tested), never actually reached a real dispatch.Fix
Added
agent_registry::model_for_task(), which does the same first-match rule lookup asroute()but returns only the matched rule'smodel, independent of agent selection. Both short-circuits (resolve_agent'sexplicitbranch, androute()'sassigned_agentbranch) now call it while leaving the already-fixed agent untouched.metadata.model/--modeloverrides still win over a[router]rule, unchanged.Closes #162.
Test plan
cargo build --workspace— cleancargo test -p agentflare-agent-registry— 55/55 passcargo test --bin agentflare resolve_agent— 15/15 passbash scripts/loc-gate.sh— passes on all touched files (3 unrelated pre-existing failures confirmed present on master with this diff stashed out)explicit_assignment_still_picks_up_a_matching_rules_model(router.rs),resolve_agent_explicit_flag_still_picks_up_a_matching_rules_model(work_model_routing_tests.rs)mcp_prompts::tests::optimize_review_returns_full_skill_body) reproduces identically without this change — not caused by this fixSummary by CodeRabbit
Bug Fixes
Tests