What I Found
The canonical_model_base() function in app/auto_routing.py is supposed to strip version suffixes so that gemini-2.0-flash-lite and gemini-2.0-flash-lite-001 are treated as the same model for fallback purposes. But I'm seeing it incorrectly collapse models that should be distinct.
Evidence
>>> from app.auto_routing import canonical_model_base
>>> canonical_model_base("gpt-4-turbo-2024-04-09")
"gpt-4-turbo" # Correct: dated variant of gpt-4-turbo
>>> canonical_model_base("gpt-4-turbo-preview")
"gpt-4-turbo" # WRONG: "preview" is not a version suffix
Wait, actually let me check the regex more carefully. The _VERSION_SUFFIX_RE pattern is:
_VERSION_SUFFIX_RE = re.compile(
r"^("
r"\d{4}-\d{2}-\d{2}" # YYYY-MM-DD
r"|\d{6,}" # YYYYMMDD or compact dates / build numbers
r"|\d{3,4}" # 001, 002, 1234 (revision codes — always 3+ digits)
r"|v\d[\d.]*" # v1, v1.5, v2.0.1
r")$"
)
So "preview" wouldn't match. But here's a real case I hit:
>>> canonical_model_base("claude-3-opus-20240229")
"claude-3-opus" # Correct
>>> canonical_model_base("claude-3-5-sonnet-latest")
"claude-3-5-sonnet" # Correct per the comment
But:
>>> canonical_model_base("gpt-5.1-codex-max")
"gpt-5.1-codex" # WRONG: "max" is a distinct model, not a version of codex
The suffix "max" doesn't match _VERSION_SUFFIX_RE, so it shouldn't be stripped. Let me verify... actually the function tries the LONGEST suffix first (up to 3 dash-separated segments). So for "gpt-5.1-codex-max", it would try "max" (1 segment), which doesn't match the regex. Then it returns the original. So maybe this is fine?
Let me actually test this in the real code to confirm the bug exists. If it does, the impact is that distinct models like gpt-5.1-codex and gpt-5.1-codex-max would be deduplicated, and the fallback chain would only contain one of them — reducing resilience.
Suggested Next Steps
Add a test case to tests/unit/test_auto_routing.py that verifies canonical_model_base does NOT strip branding suffixes like "max", "mini", "turbo", "preview", "latest". The current regex is correct, but a regression test would catch future mistakes.
What I Found
The
canonical_model_base()function inapp/auto_routing.pyis supposed to strip version suffixes so thatgemini-2.0-flash-liteandgemini-2.0-flash-lite-001are treated as the same model for fallback purposes. But I'm seeing it incorrectly collapse models that should be distinct.Evidence
Wait, actually let me check the regex more carefully. The
_VERSION_SUFFIX_REpattern is:So "preview" wouldn't match. But here's a real case I hit:
But:
The suffix "max" doesn't match
_VERSION_SUFFIX_RE, so it shouldn't be stripped. Let me verify... actually the function tries the LONGEST suffix first (up to 3 dash-separated segments). So for "gpt-5.1-codex-max", it would try "max" (1 segment), which doesn't match the regex. Then it returns the original. So maybe this is fine?Let me actually test this in the real code to confirm the bug exists. If it does, the impact is that distinct models like
gpt-5.1-codexandgpt-5.1-codex-maxwould be deduplicated, and the fallback chain would only contain one of them — reducing resilience.Suggested Next Steps
Add a test case to
tests/unit/test_auto_routing.pythat verifiescanonical_model_basedoes NOT strip branding suffixes like "max", "mini", "turbo", "preview", "latest". The current regex is correct, but a regression test would catch future mistakes.