Skip to content

Keep Claude subagent routing with an explicit model; allow the orchestrator under Isaac omni - #1268

Open
xsh310 wants to merge 6 commits into
mainfrom
smart-routing-explicit-model-subagents
Open

xsh310 wants to merge 6 commits into
mainfrom
smart-routing-explicit-model-subagents

Conversation

@xsh310

@xsh310 xsh310 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

What did you change, and why?

Change: two changes so ug can route Claude subagents when the main model is pinned, as in every Omnigent session.

  1. --model keeps Claude subagent routing. A Claude launch with --model still routes subagents, as long as first prompt routing is off. The main session stays on the chosen model. With first prompt routing on, or for Codex, --model still turns routing off, as on main: routing the first prompt would replace the pinned model, and Codex's routed launch drops it.
  2. The orchestrator works under isaac omni. Smart Router Orchestrator no longer turns itself off when ISAAC_LAUNCH_MODE=omni.

Why: Omnigent always passes --model when it starts Claude, so today ug never routes Omnigent sessions. This is the first step of moving Omnigent's smart routing into ug.

Behavior

Claude launch with --model X main This PR
Subagent only routing (a version, --enable-smart-routing, or a workspace config) no routing subagents routed, main session on X
First prompt routing no routing no routing
--disable-smart-routing no routing no routing

Codex is unchanged. Launches without --model route as on main, except that under isaac omni the orchestrator now also runs when the routing version turns it on (change 2).

This PR is part 2 of the following change diagram:
Screenshot 2026-10-27 at 9 15 39 AM

Worth knowing

  • This covers every routed Claude launch with --model, not only Omnigent's, headless -p included. Launches with a subagent routing version, --enable-smart-routing, or a workspace config that turns smart routing on now get routed subagents, plus the orchestrator when the version turns it on, where --model used to turn routing off. The main model stays pinned.
  • Before Isaac's ug pin picks this up, Isaac must stop setting the routing env vars for omni users who shouldn't be routed. That doesn't override a workspace config with smart routing enabled: in such a workspace those users still get routed subagents, as they already do outside Omnigent.
  • The orchestrator's omni check came in with Integrate opt-in Smart Router Orchestrator #996 without a stated reason. Please confirm removing it is fine.

How do you know it works?

Testing:

  • New unit tests in test_cli.py cover both ways to pass the model, both routing modes, headless -p, and Codex. A CLI test uses Omnigent's launch shape (claude -- --model system.ai.claude-opus-5-5) with either a subagent routing version or a workspace config that turns smart routing on, and checks that --disable-smart-routing and a first prompt version both turn routing off.
  • A test_claude_smart_routing_v2.py test checks that a routed launch passes the forwarded --model to Claude exactly once, without first prompt routing.
  • The --model rows in test_claude_options_allow_smart_routing_except_model now run with first prompt routing on, where --model still skips routing. The shared Claude and Codex policy test drops its two --model rows, since the agents now differ there; the new tests cover both.
  • test_skills.py runs the orchestrator test with and without ISAAC_LAUNCH_MODE=omni.
  • Full unit suite: 5792 passed, 40 skipped. ruff and ty pass.
  • No integration test yet, so the user journey check will likely fail. A headless test with --model under a subagent routing version that shows a routed subagent is still needed.

Manual end to end test with Isaac (2026-10-27):

Setup:

  • Built ug at the version Isaac pins (0.1.0+77638b6) with an earlier revision of this PR's --model change, and installed it in place of the stock ug. That revision keeps Claude subagent routing with --model whenever first prompt routing is off, the same rule as the current head.
  • Launched Claude through Isaac's Omnigent gate (https://github.com/databricks-eng/universe/pull/2899257) the way an Omnigent pane does: ISAAC_LAUNCH_MODE=omni ... isaac --model opus, as a user with the subagent_orch_v0_claude_only preset.
  • Compared against the stock ug Isaac pins today, with the Isaac gate on (ENABLE_SMART_ROUTING_OMNI=1) and off.
  • "Routed session" means ug set UCODE_SESSION_ENV_FILE, which it does only when it starts a smart routed session. In the routed run, a subagent was spawned and checked in ug's decision log.
ug Isaac gate ug started a routed session Result
Stock on no ✅ no routing (stock ug skips routing with --model)
This change on yes ✅ routing: the subagent was sent to claude-haiku-5-5 by r9296-quality-20261008
This change off no ✅ no routing
This change on, Omnigent toggle off no ✅ no routing

What this doesn't cover: the build was that earlier revision on top of Isaac's pinned ug, not this branch's head. The routing rule is the same.

This pull request and its description were written by Isaac.

@xsh310 xsh310 changed the title Keep Claude subagent routing with an explicit model; allow the orchestrator under Isaac omni Keep Claude subagent routing in Omnigent sessions; allow the orchestrator under Isaac omni Oct 27, 2026
@xsh310
xsh310 marked this pull request as ready for review October 27, 2026 16:21
@xsh310
xsh310 requested a review from lilly-luo October 27, 2026 16:21
xsh310 and others added 2 commits October 27, 2026 16:30
…trator under Isaac omni

A Claude launch with an explicit --model now keeps subagent routing when
first prompt routing is off, so Omnigent sessions started through Isaac
and ug get routed subagents while the main session stays on the chosen
model. Explicit models still skip routing for Codex and in first prompt
mode. Smart Router Orchestrator no longer turns itself off under
ISAAC_LAUNCH_MODE=omni.

Co-authored-by: Isaac <no-reply@databricks.com>
An explicit --model now keeps Claude subagent routing only when the
Omnigent runner's OMNIGENT=1 session marker is set and first prompt
routing is off. Every other launch with an explicit model skips routing
again, as on main.

Co-authored-by: Isaac <no-reply@databricks.com>
@xsh310
xsh310 force-pushed the smart-routing-explicit-model-subagents branch from db39106 to 7c8f026 Compare October 27, 2026 16:37
xsh310 and others added 3 commits October 27, 2026 17:48
…unches

Adds an Omnigent row with a workspace managed config instead of a preset,
a headless -p variant of the explicit model unit test, and a routed Claude
launch test that checks a forwarded --model reaches Claude exactly once
with no first prompt routing.

Co-authored-by: Isaac <no-reply@databricks.com>
Moves the nested double negative in _should_launch_smart_routing into
_omnigent_keeps_subagent_routing, and separates OMNIGENT_SESSION_ENV_VAR
from the routing env keys it is not part of. No behavior change.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Comment thread src/ucode/cli.py Outdated
Comment on lines +3200 to +3206
def _omnigent_keeps_subagent_routing(tool: str) -> bool:
"""Omnigent always pins the root model, so its Claude sessions still route subagents."""
return (
tool == "claude"
and env_bool(OMNIGENT_SESSION_ENV_VAR)
and not smart_routing_v2.first_prompt_routing_enabled(agent=tool)
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can just do this for all sessions, not just omnigent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a520485. I dropped the OMNIGENT check, so an explicit --model now keeps Claude subagent routing in any session with first prompt routing off. Two cases still skip routing with --model: first prompt routing, since it would replace the pinned model, and Codex, since its routed launch drops the pinned model.

One side effect to confirm: headless ug claude -p ... --model X under a subagent routing version now routes subagents too, and gets the orchestrator when the version turns it on. Fine with that, or should print mode stay out?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes let's keep subagent routing for headless mode too. if users don't want it, they can do ug claude -p ... --model X --disable-smart-routing. we should have the cost savings for headless mode as well and also reduces the branching logic for simplification

An explicit --model now keeps Claude subagent routing whenever first
prompt routing is off, not only under Omnigent's OMNIGENT=1 marker.
First prompt routing and Codex still skip routing with an explicit
model: the first would replace the pinned model, and Codex's routed
launch drops it. Removes OMNIGENT_SESSION_ENV_VAR and its test cleanup.

Co-authored-by: Isaac <no-reply@databricks.com>
@xsh310 xsh310 changed the title Keep Claude subagent routing in Omnigent sessions; allow the orchestrator under Isaac omni Keep Claude subagent routing with an explicit model; allow the orchestrator under Isaac omni Oct 27, 2026
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.

2 participants