Repository navigation
Conversation
claude_routing.request_routing_decision and route_pre_tool_use offered a fixed two model Claude menu, but no ug code calls them: Claude subagent and first prompt routing go through smart_routing.v2. Keep the spawn tool detector, notice config, and artifact helpers, and move the decision log, task field, Task alias, and legacy notice checks onto the v2 path. Co-authored-by: Isaac <no-reply@databricks.com>
AI Gateway now canonicalizes route option models itself (the system.ai. prefix, Anthropic gateway aliases, the [1m] hint, case, and . vs - spellings), drops models it does not support, collapses duplicate spellings, and returns the option the caller sent. So ug offers each workspace model id as is and accepts only a pick it offered, instead of normalizing names on the way out and mapping the router's canonical name back. This removes the Claude router id normalizer, the Codex GPT respelling (resolving its TODO), and the unused resolve_routed_model. Co-authored-by: Isaac <no-reply@databricks.com>
xsh310
commented
Oct 24, 2026
| ROUTER_NAME_ENV_VAR = "SMART_ROUTER_NAME" | ||
| ROUTING_PATH = "/ai-gateway/routing/v1/routes:select" | ||
| REQUEST_TIMEOUT_S = 30.0 | ||
| # The remote Smart Router rejects a request with more distinct model services. |
Collaborator
Author
There was a problem hiding this comment.
Let's not worry about this for now
xsh310
commented
Oct 24, 2026
| @@ -185,10 +185,10 @@ | |||
|
|
|||
|
|
|||
| def normalize_model(model: str) -> str: | |||
Collaborator
Author
There was a problem hiding this comment.
Is this function still needed?
xsh310
commented
Oct 24, 2026
| return tail.lower() | ||
|
|
||
|
|
||
| def unwrap_anthropic_gateway_model(model: str) -> str: |
Collaborator
Author
There was a problem hiding this comment.
Is this still needed?
raw_model held the router's own name for its pick, which differed from the workspace id only because ug sent normalized names. It now always equals model, so the decision log's router_model reads model directly. skip_arms, the only other reader, matched on that router name and has had no caller since databricks#273. Co-authored-by: Isaac <no-reply@databricks.com>
Routing no longer normalizes model names. The one remaining use is the readable part of the routed Claude agent slug, so the helper moves into v2.py. Its Codex use, _parse_gpt, only fed _model_strength, which has had no caller since it was added in databricks#251, so both are removed. Co-authored-by: Isaac <no-reply@databricks.com>
xsh310
force-pushed
the
raw-route-options
branch
from
October 24, 2026 05:16
22301e0 to
9b56b29
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What did you change, and why?
Change: ug now sends each workspace model id to
routes:selectexactly as the workspace lists it (for examplesystem.ai.gpt-5-6-soloranthropic-aigw-73ea02b2-system.ai.glm-5-2) and accepts only a pick it offered. It no longer rewrites ids into bare router names on the way out, and no longer maps the router's name back.Why: AI Gateway now does this itself, so the rules live in one place for every client. On both routing paths it unwraps Anthropic gateway aliases, drops the
[1m]hint, removessystem.ai., lowercases, treats.and-as the same, drops models outside its canonical model list, keeps the first of duplicate spellings, and returns the option the caller sent.Request, main vs this PR
gpt-5-6-solsystem.ai.gpt-5-6-solglm-5-2anthropic-aigw-73ea02b2-system.ai.glm-5-2gpt-5.6-solandsystem.ai.gpt-5-6-solboth listedThe model ug launches, the routing notices, and
requested_modelin the decision log are unchanged, because they already used the workspace id.route_optionsandrouter_modelin the decision log now hold workspace ids.Commits
claude_routing.request_routing_decisionandroute_pre_tool_use(the fixedclaude-opus-4-8andclaude-sonnet-5menu) have no callers, since Claude routing goes throughsmart_routing.v2. Their tests that still cover live behavior (decision log, task field,Taskalias, legacy hook notice) move to the v2 path.select_routedrops itsresolvecallback and rejects a pick it did not offer. This removesv2._claude_router_model_id, the Codex GPT respelling_normalize_route_model(resolving its TODO), and the unusedresolve_routed_model.routing.route_options_forbuilds both menus.RoutingDecision.raw_modeland the unusedskip_arms.raw_modelheld the router's own name for its pick, so it now always equalsmodel, and the decision log'srouter_modelreadsmodel.skip_armsmatched on that name and has had no caller since Remove the GLM restriction for Codex subagents #273.normalize_modelnext to its only caller. Its one remaining use is the readable part of the routed Claude agent slug, so it moves fromrouting.pyintov2.py. Its Codex use,_parse_gpt, only fed_model_strength, which nothing has called since it was added in Add opt-in Codex intelligent routing #251, so both are removed.What stays, and why
v2._canonical_claude_model_iddatabricks-claude-*tosystem.ai.claude-*before routing. The gateway does not stripdatabricks-, so without it those models would be dropped as unlisted.routing.unwrap_anthropic_gateway_model/modelswitch on the first prompt (#546), and shortens the model in the legacy hook notice.v2._normalize_modelcodex_routing.codex_model_idgpt-5.6-sol) for the launch.Depends on
Keep this in draft until these ship to every region:
restoreOriginalRouteOptionsandenforceCanonicalModelList, making today's PROD-ALL behavior permanent. While the flag exists, turningrestoreOriginalRouteOptionsoff would make the local routers return canonical names, which this PR treats as a pick it did not offer (routing fails open and the session keeps its model).Notes
system.ai.services, so menus are expected to stay within that.How do you know it works?
tests/test_codex_routing.py: the request body carries thesystem.ai.ids; a pick that was not offered (a canonical name, as an older gateway returns) fails open; the decision log records the workspace id asrouter_model.tests/test_codex_smart_routing_v2.py: ids pass through as given, and exact duplicates are sent once.tests/test_claude_smart_routing_v2.py: gateway alias ids, anddatabricks-claude-*ids (rewritten tosystem.ai.as before), are offered unchanged; the decision log keeps the exact menu and router name; the legacy hook notice still shows the unwrapped model.tests/test_claude_routing.py: the spawn tool detector, canary, and decision reconciliation tests that remain for that module.9b56b29c: 5558 passed, 7 skipped, 4 failed. The 4 failures aretests/test_agents_init.py::TestInstallToolBinary::test_required_update_*, which fail the same way on clean main (ad128219) on my devbox. I left outtests/test_e2e_user_agent.py, which launches the localclaudebinary and also fails on clean main here. ruff and ty pass.tests/e2e_cuj/test_cuj4_smart_routing.pycompares offered and selected models throughcanonical_model, which accepts raw ids, so it needs no change.anthropic-aigw-ids, and one stale id, one forbidden id, and one service with several destinations.This pull request and its description were written by Isaac.