Skip to content

feat(smart-routing): keep first prompt routing with a pinned model under isaac omni - #1887

Closed
xsh310 wants to merge 1 commit into
automation-first-prompt-orch-presetfrom
omni-pinned-model-first-prompt-routing
Closed

xsh310 wants to merge 1 commit into
automation-first-prompt-orch-presetfrom
omni-pinned-model-first-prompt-routing

Conversation

@xsh310

@xsh310 xsh310 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Under ISAAC_LAUNCH_MODE=omni, an explicit --model no longer turns smart routing off when the version routes the first prompt. The pinned model becomes the starting model: Claude starts on it, and the first prompt hold may switch to the routed model.

Today (#1268) an explicit model allows only subagent only routing, since first prompt routing would replace it. Omnigent passes --model on every Claude launch, so a first prompt version such as first_prompt_and_subagent_orch_v0 (#1848) can never route an Omnigent session. Omnigent automation runs need it: they launch with the owner's model or a default, and should route from the first prompt (Isaac companion: https://1.gitspoke.cloud.databricks.com/databricks-eng-ghes/universe/pull/10011231).

Stacked on #1848; #1860 sits on top of this PR (stack: #1848, #1887, #1860).

Behavior

Launch with --model X (forwarded or ug's own) and a first prompt version:

main This PR
Outside isaac omni no routing no routing (unchanged)
ISAAC_LAUNCH_MODE=omni, interactive no routing routed: starts on X, the first prompt may route to another model, subagents routed
ISAAC_LAUNCH_MODE=omni, headless -p no routing subagents routed, stays on X
--disable-smart-routing no routing no routing

Subagent only versions keep today's behavior everywhere: routed, with the main session on X.

Codex follows the same rule. Omnigent's Codex launch passes the model as -c model=…, which isn't a pin, so it is unaffected; only a Codex launch with --model under omni would now route its first turn.

Worth knowing

Tests

  • tests/test_cli.py:
    • test_isaac_omni_explicit_model_keeps_first_prompt_routing: for every pinned launch shape (forwarded --model, headless -p, ug --model, Codex), first prompt routing launches routed under omni and stays off under direct. The shapes are shared with test_explicit_model_keeps_only_subagent_routing, which is otherwise unchanged.
    • test_isaac_omni_forwarded_model_keeps_first_prompt_routing: Omnigent's launch shape (<tool> -- --model X) with first_prompt_and_subagent_orch_v0 under omni is routed for Claude and Codex, and --disable-smart-routing still turns it off.
  • tests/test_claude_smart_routing_v2.py:
    • test_first_prompt_launch_starts_on_a_pinned_model: with a forwarded or ug --model, the first prompt launch runs the PTY path, passes the model once, and installs the first prompt hook.
    • test_explicit_model_skips_routing is renamed test_explicit_model_keeps_the_model_and_routes_only_subagents and now also checks that headless -p keeps subagent routing on.
  • With the cli.py change reverted, the 6 omni cases fail.
  • Routing, CLI and skills test files (14 files): 2903 passed. With ISAAC_LAUNCH_MODE=omni set in the shell, the CLI, routing and skills files still pass (1722).
  • ruff check src/ tests/ and ruff format --check src/ tests/ pass. ty check src/ reports only the 8 OpenTelemetry import errors of my local venv, the same as on main.
  • Not run here: the live integration suite (/integration-test) and a live Omnigent run.

Checklist before requesting review

  • Comment /ug-review and address the comments.
  • Comment /integration-test and address any failures.

This pull request and its description were written by Isaac.

@xsh310
xsh310 marked this pull request as ready for review November 25, 2026 00:37
@xsh310
xsh310 requested a review from lilly-luo November 25, 2026 00:38
Comment thread src/ucode/cli.py
if (
pinned
and smart_routing_v2.first_prompt_routing_enabled(agent=tool)
and os.environ.get(ISAAC_LAUNCH_MODE_ENV_VAR) != "omni"

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.

@lilly-luo , let me know if you prefer to use OMNIGENT =1 env var instead if we don't want to add isaac specific env var check here.

Comment thread src/ucode/cli.py
if (
pinned
and smart_routing_v2.first_prompt_routing_enabled(agent=tool)
and os.environ.get(ISAAC_LAUNCH_MODE_ENV_VAR) != "omni"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maintainability · low
this is now the third python check of ISAAC_LAUNCH_MODE == "omni" (also cli.py:3860, feedback.py:26). can we add an is_isaac_omni_launch() helper in constants/feedback so the contract string can't drift?

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.

this seems legit

[(["--model", "system.ai.claude-opus-5-5"], None), ([], "system.ai.claude-opus-5-5")],
ids=["forwarded-model", "ug-model"],
)
def test_first_prompt_launch_starts_on_a_pinned_model(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

test · low
can we name or set this for isaac omni? only omni launches with a pinned model reach the first-prompt hook (cli.py gates the rest), but this test reads like it's true for every pinned launch.

Comment on lines 2497 to +2498
assert launched["argv"].count("--model") == 1
assert launched["settings"]["env"][v2.ENABLE_SUBAGENT_ROUTING_ENV_VAR] == "1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

test · low
can we assert the --model value is still opus? the name says "keeps the model", but the count check still passes if routing swaps in the routed model.

Suggestion:

Suggested change
assert launched["argv"].count("--model") == 1
assert launched["settings"]["env"][v2.ENABLE_SUBAGENT_ROUTING_ENV_VAR] == "1"
argv = launched["argv"]
assert argv.count("--model") == 1
assert argv[argv.index("--model") + 1] == "opus"
assert launched["settings"]["env"][v2.ENABLE_SUBAGENT_ROUTING_ENV_VAR] == "1"

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

UG review recommendation

RECOMMENDATION: APPROVE

Reasons:

  • The review completed with no findings on the changed lines.

Complete review of 4 files; no findings.

Advisory only: this recommendation never approves or merges the pull request. The ready-to-approve label tracks it.

@github-actions github-actions Bot added the ready-to-approve Ready for maintainer approval label Nov 25, 2026
@xsh310

xsh310 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

/ug-review

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 4 selected item(s).

@github-actions

Copy link
Copy Markdown
Contributor

Polly AI Review

Blocking issues

None confirmed in the changed code.

Security vulnerabilities

None identified.

Non-blocking notes

  • can we drop the ug-model case, already covered by test_restores_model_captured_immediately_before_switch? (tests/test_claude_smart_routing_v2.py:1188)

Approach

The approach is sound: change the existing launch-policy gate and reuse Claude’s first-prompt hook and Codex’s interposer. A separate routing mechanism is unnecessary. The tradeoff is intentional: under omni, an explicit model becomes a starting model rather than a permanent pin.

Summary

Diff size (computed): 6 files; +130 / -15 lines (145 changed text lines); 0 binary files.

Category Files Added Deleted Share of changed text lines
Tests and test support 4 117 11 88.3%
Documentation 1 4 1 3.4%
Dependencies and lockfiles 0 0 0 0.0%
Implementation / other 1 9 3 8.3%

Shares use additions + deletions, including generated text and lockfiles. Binary files have no line count. Tests include fixtures/helpers under test paths and colocated test/spec files; categories are path-based, not coverage measurements.

Changes

Allows first-prompt routing with an explicit model when ISAAC_LAUNCH_MODE=omni. Other launch modes retain the previous pin behavior. The diff also updates documentation, strengthens launch assertions, shares existing test inputs, and isolates the inherited launch-mode environment variable. No dependencies or generated assets change.

The size is proportional to the outcome. The concrete reduction opportunity is the overlapping ug-model case identified above.

Tests

Test-by-test assessment

Static assessment only; no tests or lint were executed. The author-reported results are not independently verified. Both trusted policy files were read in full, and the saved diff’s checksum matches. Neither supplied revision exists in the trusted checkout, so surrounding-code checks use default-branch context rather than an exact-head checkout.

Test / case Behavior protected Layer Needed? Action / rationale
tests/test_cli.py::_PINNED_MODEL_LAUNCHES Shared forwarded, headless, UG-model, and Codex launch inputs Test support keep Reuses the existing matrix without adding setup or losing cases.
tests/test_cli.py::test_explicit_model_keeps_only_subagent_routing Explicit pins retain previous behavior outside omni Unit keep Shared inputs preserve existing cases and assertions.
tests/test_cli.py::test_isaac_omni_explicit_model_keeps_first_prompt_routing Four pin shapes permit routing under omni, but not direct Unit keep Directly protects the changed predicate and exact environment-value boundary. Headless eligibility does not imply main-prompt routing.
tests/test_cli.py::test_isaac_omni_forwarded_model_keeps_first_prompt_routing Claude/Codex forwarded pins work with preset expansion; explicit disable wins CLI component keep Covers parsing and override precedence beyond the predicate test.
tests/test_claude_smart_routing_v2.py::test_first_prompt_launch_starts_on_a_pinned_model[forwarded-model] Forwarded model appears once, uses the PTY path, and registers the first-prompt hook Launcher component keep Protects forwarded-argument handling and hook registration without requiring live inference.
tests/test_claude_smart_routing_v2.py::test_first_prompt_launch_starts_on_a_pinned_model[ug-model] UG launch model and first-prompt hook coexist Launcher component consolidate Existing test_restores_model_captured_immediately_before_switch covers this launch path, model argument, hook, and routing callback. Retain the distinct forwarded-model case.
tests/test_claude_smart_routing_v2.py::test_explicit_model_keeps_the_model_and_routes_only_subagents Headless explicit pin skips main routing while enabling subagent routing Component keep Rename preserves prior assertions; the added assertion protects the headless contract.
tests/conftest.py::_isolate_ucode_state Inherited ISAAC_LAUNCH_MODE cannot change unrelated expectations Fixture keep Extends existing environment isolation; monkeypatch restores the caller’s environment.
tests/README.md Coverage catalog describes the omni exception and launch checks Documentation keep Documents the changed coverage without adding test machinery.

Existing Claude restoration/fallback and Codex interposer tests cover downstream routing boundaries; another broad failure matrix is unnecessary. The new tests establish launch eligibility, arguments, and hook registration—not a completed native model switch. Live omni inference, routing request/response evidence, and downstream telemetry remain unverified.

For manual verification on an authorized exact-head installation: select the first-prompt preset, launch with ISAAC_LAUNCH_MODE=omni and --model X, and confirm a completed response uses the routed selection. Repeat outside omni and with --disable-smart-routing; both should preserve X. Claude -p should also preserve X.

Scope

All changes support the stated omni-pinned first-prompt routing outcome. No unrelated changes or unresolved scope questions were found in the frozen diff.


Automated review by Polly · workflow run

…der isaac omni

An explicit --model turns smart routing off when the version routes the
first prompt, since that routing would replace the pinned model. Isaac's
Omnigent launches (ISAAC_LAUNCH_MODE=omni) always pin the model, so a
first-prompt version could never route them. Under omni the pinned model
is now the starting model: Claude starts on it and the first prompt may
route to another. Outside omni nothing changes, --disable-smart-routing
still wins, and headless -p keeps the model and routes only subagents.

The test isolation clears ISAAC_LAUNCH_MODE so a suite run from an
Omnigent pane matches CI.

Co-authored-by: Isaac <no-reply@databricks.com>
@xsh310
xsh310 force-pushed the omni-pinned-model-first-prompt-routing branch from aae00c4 to da0422e Compare November 25, 2026 18:52
@xsh310
xsh310 removed this pull request from stack #1909 November 25, 2026 19:26
@xsh310

xsh310 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this: the design changed so that Isaac drops --model for an automation run once its gate passes, so ug's pinned model rule from #1268 stays as is. Thanks for the reviews.

@xsh310 xsh310 closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-approve Ready for maintainer approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants