Route only explicit Codex and Claude invocations through smart routing - #502
Merged
lilly-luo merged 8 commits intoSep 8, 2026
Merged
Conversation
lilly-luo
force-pushed
the
stack/lilly/only-do-smart-routing-for-2-cases-codex
branch
from
September 4, 2026 22:58
6dd7576 to
dcda6c4
Compare
lilly-luo
force-pushed
the
stack/lilly/only-do-smart-routing-for-2-cases-codex
branch
from
September 4, 2026 23:10
dcda6c4 to
586eeef
Compare
codex / claude (no prompt) and codex -- '<>' and claude -- '<>' to smart router
lilly-luo
force-pushed
the
stack/lilly/only-do-smart-routing-for-2-cases-codex
branch
2 times, most recently
from
September 4, 2026 23:47
c5e15dc to
c8ec0f0
Compare
lilly-luo
marked this pull request as ready for review
September 4, 2026 23:54
lilly-luo
force-pushed
the
stack/lilly/only-do-smart-routing-for-2-cases-codex
branch
from
September 5, 2026 00:04
c8ec0f0 to
354c435
Compare
codex / claude (no prompt) and codex -- '<>' and claude -- '<>' to smart router
lilly-luo
commented
Sep 5, 2026
lilly-luo
force-pushed
the
stack/lilly/only-do-smart-routing-for-2-cases-codex
branch
3 times, most recently
from
September 5, 2026 00:17
245a4a5 to
28bcd18
Compare
lilly-luo
force-pushed
the
stack/lilly/only-do-smart-routing-for-2-cases-codex
branch
from
September 5, 2026 00:20
28bcd18 to
9cd4c7e
Compare
lilly-luo
commented
Sep 5, 2026
lilly-luo
commented
Sep 5, 2026
lilly-luo
commented
Sep 5, 2026
lilly-luo
requested review from
andy-xu-db,
david-siqi-liu and
rohita5l
and removed request for
david-siqi-liu and
rohita5l
September 5, 2026 01:52
Collaborator
|
Do we show some indication in the CLI that smart routing has been enabled, after an user launches a session? |
david-siqi-liu
approved these changes
Sep 8, 2026
Collaborator
Author
…s-codex # Conflicts: # src/ucode/agents/codex.py # tests/test_codex_smart_routing_v2.py
lilly-luo
enabled auto-merge (squash)
September 8, 2026 15:35
lilly-luo
disabled auto-merge
September 8, 2026 15:41
lilly-luo
deleted the
stack/lilly/only-do-smart-routing-for-2-cases-codex
branch
September 8, 2026 15:41
rohita5l
added a commit
that referenced
this pull request
Sep 11, 2026
Codex versions below 0.134.0 enter a configure/launch loop: configure writes `[profiles.ucode]` into `~/.codex/config.toml` and validation succeeds, but launch requires the newer `ucode.config.toml` file. This restores compatibility lost in #502 by using the same version check as configure and launching older Codex with `--profile ucode`. Older versions also receive a warning on stderr to upgrade to 0.134.0 or newer and verify the active installation with `codex --version`. Modern and unknown versions retain the existing `--config` behavior for runtime, utility, and server commands. ### Validation - 105 focused tests pass across `test_agent_codex.py`, `test_codex_config.py`, and `test_codex_smart_routing_v2.py`, covering legacy versions, stale profile files, the version boundary, unknown versions, and upgrade warnings. - Ruff lint, formatting, and `git diff --check` pass. - Tested the official Linux ARM64 Codex 0.129.0 binary in isolated containers against a local Responses API test server. With UG e7553f4, validation succeeds and both launch attempts fail with the reported missing-file error. With this patch, validation and both real `codex exec` launches exit 0, use the `ucode-databricks` provider, and show the upgrade warning. Gateway authentication and responses use local test equivalents.
8 tasks
lilly-luo
added a commit
that referenced
this pull request
Sep 11, 2026
only 2 cmds should invoke smart routing: - `ug codex` or `ug claude` which launches a tui that will smart route the first prompt - `ug codex -- <prompt>` or `ug claude -- <prompt>` which will launch a tui with prompt prepopulated and then smart route it. no other subcommands should trigger smart routing, even if the environment variable is set. this came up because `isaac codex app` which automatically has `enable_smart_routing_v2=1` set tried to invoke smart routing... this was missed in #502 because i didn't explicitly test `ug codex app` which apparently functions diff from `ug codex app-server` testing: - [x] `ENABLE_SMART_ROUTING_V2=1 uv run ug codex` -> invokes smart routing - [x] `ENABLE_SMART_ROUTING_V2=1 uv run ug claude` -> invokes smart routing - [x] `ENABLE_SMART_ROUTING_V2=1 uv run ug codex -- 'hi'` -> invokes smart routing - [x] `ENABLE_SMART_ROUTING_V2=1 uv run ug claude -- 'hi'` -> invokes smart routing - [x] `ENABLE_SMART_ROUTING_V2=1 uv run ug codex app` -> does NOT invoke smart routing - [x] `ENABLE_SMART_ROUTING_V2=1 uv run ug codex app-server` -> does NOT invoke smart routing - [x] `ENABLE_SMART_ROUTING_V2=1 uv run ug codex update` -> does NOT invoke smart routing - [x] `ENABLE_SMART_ROUTING_V2=1 uv run ug codex --model system.ai.glm-5-2` -> does NOT invoke smart routing
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.

https://databricks.atlassian.net/browse/AIGTWY-4551
explanation
currently, we are invoking smart routing for /every/ codex and claude command. in reality, we only want to invoke smart routing in 2 cases:
claude/codexempty - this opens a tui and we route on the first promptclaude -- 'hi'/codex -- 'hi'- this opens a tui with 'hi' as the first prompt.;claude --model xxorcodex --model yyshould not invoke smart routing.this PR makes 3 changes so that
ucode codex upgradeanducode codex app-serverwill work:ucode codex updateanducode codex app-servercontinue working without having to maintain a hardcoded subcommand list.ucode codex update. This is because we, by default, pass the ucode config as argument--profileto all codex commands. however, onlycodexandcodex mcptake --profile. instead, the other commands take --config. so i change codex to pass in --config insteaducode codex upgradewould return the error below. this is because when we pass --config instead of --profile to codex, we need to serialize the toml file. the serialization logic had to be updated as a result of tomlkit upgrading to 15.0.finally after 1, 2, and 3 -
ucode codex upgradeanducode codex app-serverwork.test
ENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode claudeENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode codexENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode claude -- 'hi'ENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode codex -- 'hi'ENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode claude --model system.ai.glm-5-2ENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode codex --model system.ai.glm-5-2ENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode codex updateENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode claude upgradeENABLE_SMART_ROUTING_V2=1 SMART_ROUTER_NAME=task_v2 uv run ucode codex app-serverthe below cmds should be unchanged, i tested to ensure no regression
ENABLE_SMART_ROUTING_V2=0 uv run ucode claudeENABLE_SMART_ROUTING_V2=0 uv run ucode codexENABLE_SMART_ROUTING_V2=0 uv run ucode claude --model system.ai.glm-5-2ENABLE_SMART_ROUTING_V2=0 uv run ucode codex --model system.ai.glm-5-2ENABLE_SMART_ROUTING_V2=0 uv run ucode claude -- 'hi'ENABLE_SMART_ROUTING_V2=0 uv run ucode codex -- 'hi'ENABLE_SMART_ROUTING_V2=0 uv run ucode codex updateENABLE_SMART_ROUTING_V2=0 uv run ucode claude upgradeENABLE_SMART_ROUTING_V2=0 uv run ucode codex app-serverbefore (confirming i repro'd the issue) :
after (it's fixed)