Skip to content

fix: translate bare GPT slugs in codex_model_id to fix smart-routing race - #721

Open
lilly-luo wants to merge 1 commit into
databricks:mainfrom
lilly-luo:fix/smart-routing-catalog-model-id-race
Open

lilly-luo wants to merge 1 commit into
databricks:mainfrom
lilly-luo:fix/smart-routing-catalog-model-id-race

Conversation

@lilly-luo

Copy link
Copy Markdown
Collaborator

Problem

Some users on the same workspace and same ucode version get gpt-5-6-luna (broken, gateway can't resolve) while others get gpt-5.6-luna (working). The difference is nondeterministic across users.

Root cause

When smart routing builds available_models, it uses one of two sources:

available_models = custom_catalog_models() or _cached_routing_models(state)
  • Catalog present (per-workspace MPS catalog): returns bare hyphenated slugs, e.g. gpt-5-6-luna
  • Catalog absent (fallback to cached state): returns system.ai.-prefixed ids, e.g. system.ai.gpt-5-6-luna

The router side handles both dialects fine (_normalize_route_model canonicalizes them). But after routing, the chosen model is passed through codex_model_id to produce the dotted alias the gateway resolves (gpt-5.6-luna). codex_model_id only translated system.ai./databricks- prefixed ids — bare slugs hit else: return model and passed through unchanged.

So whether the catalog file was present at launch time decided whether the user got the working alias or the broken one. Which branch a user lands on varies with their local config state (configure history, managed settings rollout, catalog cleanup), making it look like a race.

Fix

One-line change in codex_model_id (codex_routing.py:185): else: bare = tail instead of else: return model. This makes codex_model_id translate bare GPT slugs too, so both dialects converge to the dotted alias.

  • Idempotent on already-dotted forms (gpt-5.6-lunagpt-5.6-luna)
  • Major-only slugs unchanged (gpt-6-astragpt-6-astra)
  • Non-GPT slugs unchanged (glm-5-2glm-5-2)
  • Special cases preserved (databricks-gpt-5-2-codex, databricks-gpt-5-4-nano)

Testing

  • Added test_codex_model_id_translates_bare_hyphenated_gpt_slugs — unit test for bare slug translation
  • Added test_routing_with_bare_catalog_slugs_produces_dotted_alias — full routing path with bare catalog slugs (the reproducer)
  • Added scripts/repro_routing_race.py — standalone script demonstrating both branches converge
  • All existing routing, catalog, and v2 tests verified to pass

…race

When smart routing builds available_models, it uses either custom catalog
slugs (bare hyphenated, e.g. gpt-5-6-luna) or cached discovery ids
(system.ai.-prefixed, e.g. system.ai.gpt-5-6-luna) depending on whether the
per-workspace catalog file is present. codex_model_id only translated the
prefixed form, so users on the catalog path got the unresolvable bare slug
while fallback users got the working dotted alias (gpt-5.6-luna).

Make codex_model_id translate bare GPT slugs too so both dialects converge
to the dotted alias the gateway resolves. Add a reproducer script and
tests covering bare-slug translation and the full routing path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant