Context
The quality strategy and the balanced strategy both use cost as a tiebreaker when two models have the same primary score, but they disagree on direction.
Problem
In app/auto_routing.py:choose_auto_model, the quality strategy sorts with:
eligible.sort(
key=lambda m: (-(_lookup_score(quality_scores, m.id) or 0.0), -_blended_cost(m), m.id)
)
The -_blended_cost(m) term means that among models with the same quality score, the most expensive one ranks first.
Compare this to the balanced strategy (same function, ~20 lines later):
scored_models.sort(key=lambda m: (
-_bal_score(m),
_blended_cost(m), # tiebreak 1: cheapest wins
m.id, # tiebreak 2: stable
))
Here _blended_cost(m) (no negation) means the cheapest model wins the tiebreaker. The inline comment confirms this is intentional: "cheapest wins".
Evidence
This is observable when AA assigns identical intelligence_index scores to sibling models. For example, in packages/litellm_adapter/quality_scores_static.py:
gpt-5 and gpt-5-codex both have quality score 44.6
claude-opus-4 and claude-4-opus-20250514 both have quality score 39.0
Under the quality strategy with these models deployable, the more expensive variant of each pair would rank first — silently preferring gpt-5-codex over gpt-5 even though they score identically on intelligence. Under balanced, the cheaper one wins.
Impact
Low-to-medium. The sibling dedup in canonical_model_base collapses most of these cases before the tiebreaker fires. But for models that are genuinely distinct (different canonical base) yet happen to share an AA score, the operator's quality strategy is secretly spending more than necessary with no indication in the dashboard.
Suggested Fix
Align the quality tiebreaker with balanced by removing the negation:
eligible.sort(
key=lambda m: (-(_lookup_score(quality_scores, m.id) or 0.0), _blended_cost(m), m.id)
)
If the current behavior (prefer expensive among equal-quality) was intentional, it should be documented — the balanced strategy's comment explicitly says "cheapest wins" but the quality strategy has no equivalent note.
Environment
- OrcaRouter Lite
main branch
- Python 3.12.7, Docker on Ubuntu 24.04
- Strategy:
quality with AA key configured
Context
The
qualitystrategy and thebalancedstrategy both use cost as a tiebreaker when two models have the same primary score, but they disagree on direction.Problem
In
app/auto_routing.py:choose_auto_model, thequalitystrategy sorts with:The
-_blended_cost(m)term means that among models with the same quality score, the most expensive one ranks first.Compare this to the
balancedstrategy (same function, ~20 lines later):Here
_blended_cost(m)(no negation) means the cheapest model wins the tiebreaker. The inline comment confirms this is intentional: "cheapest wins".Evidence
This is observable when AA assigns identical intelligence_index scores to sibling models. For example, in
packages/litellm_adapter/quality_scores_static.py:gpt-5andgpt-5-codexboth have quality score 44.6claude-opus-4andclaude-4-opus-20250514both have quality score 39.0Under the
qualitystrategy with these models deployable, the more expensive variant of each pair would rank first — silently preferringgpt-5-codexovergpt-5even though they score identically on intelligence. Underbalanced, the cheaper one wins.Impact
Low-to-medium. The sibling dedup in
canonical_model_basecollapses most of these cases before the tiebreaker fires. But for models that are genuinely distinct (different canonical base) yet happen to share an AA score, the operator'squalitystrategy is secretly spending more than necessary with no indication in the dashboard.Suggested Fix
Align the
qualitytiebreaker withbalancedby removing the negation:If the current behavior (prefer expensive among equal-quality) was intentional, it should be documented — the
balancedstrategy's comment explicitly says "cheapest wins" but thequalitystrategy has no equivalent note.Environment
mainbranchqualitywith AA key configured