Repository navigation
fix(router): resolve route candidate ids through the router's own resolver - #40491
Conversation
…olver get_candidate_model_ids_for_route (added in #40280 for the encrypted-content affinity check) reconstructed the candidate pool by unioning the model_name and team indexes with pattern_router.route. That diverged from how the router actually resolves a route: it took a union instead of the first matching path, and pattern_router.route only matches the literal name, so a provider-qualified pattern (matched by get_deployments_by_pattern, which retries the {provider}/{model} form) was missed and the default deployment was ignored. For an affinity follow-up on a wildcard or team-public route, that mismatch could strip encrypted reasoning on a same-group cooldown, or return a 503 on a real cross-path switch. Delegate the non-model_name case to _try_early_resolve_deployments_for_model_not_in_names, the same resolver _common_checks_available_deployment uses, so candidate membership follows the router's real precedence. With include_team_models left off it stays read-only and does not raise. Behavior for concrete model groups and routing groups is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KAumQbhzk6jdWWHFLA8Jar
|
This is a follow-up to #40280 addressing the Cursor Bugbot candidate-resolution finding @greptileai can you reply here with a score and why that score? bugbot run |
|
Score: 5/5 The fix correctly delegates candidate discovery to the router’s existing resolution path instead of maintaining a second, potentially divergent union of indexes. It preserves alias and routing-group precedence, then uses the early resolver for team routes, provider-qualified wildcard patterns, team pattern routes, and the default deployment before falling back to the model-name indexes. The |
Greptile SummaryThis PR aligns route candidate ID discovery with the Router’s actual route-resolution precedence
Confidence Score: 5/5The PR appears safe to merge because candidate discovery now follows the same resolver and precedence as request routing No actionable failures remain; known model names retain precedence, helper return shapes are handled correctly, and the regression test detects the previous bare-name wildcard mismatch
|
| Filename | Overview |
|---|---|
| litellm/router.py | Replaces hand-built candidate unions with the Router’s existing ordered route resolver while safely normalizing its deployment shapes |
| tests/test_litellm/test_router.py | Adds focused coverage for provider-qualified wildcard resolution from an unprefixed model name |
Reviews (1): Last reviewed commit: "fix(router): resolve route candidate ids..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a developer replays a turn's encrypted reasoning against a bare model name that a wildcard deployment serves, and while that deployment is briefly rate-limited the gateway loses their reasoning or 503s as if the model did not exist
include: ["reasoning.encrypted_content"]and the prior turn's items,modelset to a bare name (for examplegpt-5-codex) that only a wildcard deployment likeopenai/*servesAfter: the same replay is recognized as the same model group, so it fails fast with a retriable signal and keeps the reasoning for the retry
Relevant issues
Follow-up to #40280, addressing a Cursor Bugbot finding on that PR ("Candidate IDs miss router resolution paths")
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreFinal Attestation
🤖 Generated with Claude Code
https://claude.ai/code/session_01KAumQbhzk6jdWWHFLA8Jar