Skip to content

quality strategy tiebreaker favors expensive models, contradicting balanced strategy's "cheapest wins" #116

Description

@xiaomingwo

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions