Repository navigation
Render subagent routing using claude code mod - #979
Merged
Merged
Conversation
Introduce the ENABLE_CLAUDE_CODE_MODS environment variable, a shared
TRUTHY_ENV_VALUES set ("1"/"true", case-insensitive), and a general
claude_code_mods_enabled() reader in constants. Harness-general and not tied
to smart routing; nothing is gated on it in this change.
Co-authored-by: Isaac <no-reply@databricks.com>
Introduce ucode.mods: a reusable home for shipping Claude Code mods outside smart routing. Each mod's source is real TypeScript under typescript/claude-mods/ (shipped with the wheel). Claude Code loads one hooks module per plugin, so a mod is a register.ts entry that imports its concern modules; a ClaudeMod( source="register.ts", extra=(...)) plus write_mod(plugin_dir, mod) copies the entry and the files it imports into a launch-scoped plugin's hooks/. The mods-wide Claude version floor (2.1.287) lives here too. The first mod draws a band above the prompt (AbovePrompt) via register.ts -> smart-routing-status.ts, showing whether smart routing is on and which prompts it routes; the "on" pill uses a bright background with black text so it reads in both light and dark terminals. Visualization only; ug's Python hooks still route, and state is read via the mods API (env + the live session-env file), mirroring v2.smart_routing_enabled / first_prompt_routing_enabled and accepting "true" as well as "1". Co-authored-by: Isaac <no-reply@databricks.com>
lilly-luo
force-pushed
the
claude-mods-subagent-routing
branch
2 times, most recently
from
October 3, 2026 19:47
1810b77 to
4c88828
Compare
lilly-luo
added this pull request to stack #978
October 3, 2026 20:00
…notice
Add the subagent-routing concern to the smart-routing UI mod: register.ts now
also composes subagent-routing.ts, which renders a compact line under each Agent
row showing where it was routed, e.g.
↳ claude-sonnet-5 ●○○ low · an explicit target, localized scope
The routed model comes off the Agent row's result (resolvedModel); the tier and
reason come from the router rationale ("Routed to Low because …", regex-parsed).
Model text uses Claude Code's built-in `primary` theme color.
Under ENABLE_CLAUDE_CODE_MODS, the Python subagent hook now:
- drops its plain-text ASCII routing notice (no systemMessage / reason) — the mod
renders instead — while keeping the model rewrite;
- writes the model + rationale, keyed by task, to a per-session mod-routing.json
next to the session env file for the mod to read; and
- the launch propagates ENABLE_CLAUDE_CODE_MODS into the hook environment and
omits the "Routing subagent model" spinner label (the mod is the feedback).
Without the flag, the plain-text notice and spinner are unchanged.
Co-authored-by: Isaac <no-reply@databricks.com>
lilly-luo
force-pushed
the
claude-mods-subagent-routing
branch
from
October 3, 2026 20:08
4c88828 to
7d23b05
Compare
lilly-luo
removed this pull request from stack #978
October 13, 2026 23:40
lilly-luo
added this pull request to stack #1123
October 14, 2026 02:50
Co-authored-by: Isaac <no-reply@databricks.com>
Hooks that earlier UG versions persisted still call route-subagent and expect a PreToolUse response. Return main's full response for that event, including the notice naming the dispatched agent, while route-subagent-mod keeps the mod's plain routing details. Co-authored-by: Isaac <no-reply@databricks.com>
Prefix each routed Agent row's routing line with a lightning bolt so it reads as Smart Router's, omit ug-smart-router agent names that only repeat the model, and keep [orchestrator on] as its own suffix after the model. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
…nt rows Each routed Agent row now always shows the selected model in the status band's green, with the reason aligned beneath it. While the router answers, the row shows a spinner with the elapsed seconds, then notes how long routing took. Both timers use $.clock and are omitted when it is unavailable, so they never block routing. The orchestrator tag and the unused orchestrator field in the mod's routing reply are removed; the legacy hook notice keeps its tag. Co-authored-by: Isaac <no-reply@databricks.com>
The parent model writes the Agent row's description, so the task marker may appear only in the prompt. Match a Selected Model row after the tagged prompt and before the next one instead of requiring the marker above the row. Co-authored-by: Isaac <no-reply@databricks.com>
…gent routing Drop the leftover truthy routing-flag parsing (flags take only 0 and 1), the Codex comment churn, a test that repeated the plugin file check, four redundant assertions, and doc paragraphs that restated each other. Share one helper for the routing timer's elapsed seconds. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
… branch Derive the routing spinner frame from the clock so parallel subagents no longer speed it up. Split route_claude_subagent's two reply shapes into the mod's function and a route_claude_pre_tool_use wrapper for persisted legacy hooks, sharing one routing helper. routing_hook_argv now adds router options only for the mod event, since nothing builds a Claude route-subagent argv. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
xsh310
approved these changes
Oct 16, 2026
nachill-databricks
pushed a commit
to nachill-databricks/ucode
that referenced
this pull request
Oct 17, 2026
## What did you change, and why? Translate existing task profiles into short routing explanations, addressing [this review feedback](databricks#979 (review)). For example, `Routed to Low because its task-only profile is low: ...` becomes `This task has a clear target and limited scope.` Preserve availability and fallback explanations, custom gateway notices, and unrecognized responses. Diagnostic records keep the displayed explanation in `rationale` and the original gateway text in `raw_rationale`. ## How do you know it works? Two direct formatter tests cover readable wording and preservation of unknown responses. All 217 focused routing and integration-contract tests pass. A direct filesystem check verifies both diagnostic fields for summarized, unchanged, and empty reasons. Ruff lint, formatting, and type checks pass. The live integration checks will rerun in CI.
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.
make a more user-friendly render of smart routing of subagents

before
https://github.com/user-attachments/assets/4250abd4-6dc9-4930-8f35-6727f4657ef6
after

https://github.com/user-attachments/assets/139585c4-6f2b-4593-8ae3-25e5a645eca0