Repository navigation
Conversation
JJ27
marked this pull request as ready for review
September 29, 2026 23:28
lilly-luo
reviewed
Oct 1, 2026
JJ27
added a commit
that referenced
this pull request
Oct 6, 2026
Carries PR #850's statusline, pricing, and endpoint-rates client onto the Claude mods stack. Conflicts with the mods branch are resolved by keeping both sides; ENABLE_SMART_ROUTING_SAVINGS stays in v2 since the routing flags moved to ucode.constants. Co-authored-by: Isaac <no-reply@databricks.com>
JJ27
force-pushed
the
josh-joseph/smart-routing-savings-statusline
branch
from
October 6, 2026 05:20
e547da8 to
6f8dc9c
Compare
The launch-scoped ug-smart-router mod now draws a dim row above the prompt with the estimated savings from subagent smart routing and, when Smart Router Orchestrator is active, the skill's version from SKILL.claude.md. The mod sums each turn request's tokens by served and baseline model and runs a stdlib-only pricer against cached endpoint rates, which each routed launch refreshes in the background. The pricer, usage file and version reach the mod as plugin options. ENABLE_SMART_ROUTING_SAVINGS=0 opts a launch out. Co-authored-by: Isaac <no-reply@databricks.com>
JJ27
force-pushed
the
josh-joseph/smart-routing-savings-statusline
branch
from
October 12, 2026 20:22
63aa3f9 to
da5c0b9
Compare
lilly-luo
reviewed
Oct 13, 2026
lilly-luo
left a comment
Collaborator
There was a problem hiding this comment.
can you add ENABLE_SMART_ROUTING_SAVINGS to config.py
# Conflicts: # src/ucode/agents/claude_mods/register.ts # src/ucode/smart_routing/v2.py # tests/README.md # tests/test_claude_mod.py
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Label the version as Unity Gateway Smart Router, show the amount in a green (saved) or yellow (cost more) pill, and render the row after the other AbovePrompt handlers so it sits under the band in either order. The pricer now prints the estimate's parts instead of preformatted text. Co-authored-by: Isaac <no-reply@databricks.com>
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.
Summary
Adds a smart-routing savings estimate to ug's Claude Code mod. The estimate appears in a dim row above the prompt, alongside the Smart Router Orchestrator skill version. It's on by default;
ENABLE_SMART_ROUTING_SAVINGS=0opts a launch out.skills/smart-router-orchestrator/SKILL.claude.md(metadata.version), and is shown only whenENABLE_SMART_ROUTER_ORCHESTRATOR=1.This replaces the earlier transcript-statusline approach. The PR is rebuilt on
main, on top of the native orchestrator skill and the mods scaffolding from #1062, and the statusline is gone.Screenshots
Pending. A laptop run will add them. Prod
endpoint-ratescurrently returns 404, so the screenshots will use seeded list-price rates, not live endpoint rates.How it works
savings.ts): on eachturn.step, for the main agent and subagents, the mod adds the request's token usage to totals grouped by agent, baseline, served model, and whether the request ran before a user model switch.ucode.smart_routing.savings): a hooks module has no Node APIs, and the price table lives in Python. So after each turn the mod writes its totals to a per-launch usage file and runs the pricer command on it. The pricer returns the row text as one JSON line. It computes:saved = Σ tokens × price(baseline) − Σ tokens × price(served), per token class: input, output, cache read, and 5-minute and 1-hour cache writes./model, requests are priced against their own baseline.pluginConfigsoptions. These are declared with defaults in the generated plugin'suserConfig. The pricer is amultiple: truelist, so paths with spaces and unicode reach the mod intact.Price source
Each routed launch refreshes prices on a background thread from
GET /api/ai-gateway/v2/endpoint-rates:batchGet, with repeateddatabricks_hosted_model_servicesparams covering the router's and main agent's model services. Results are cached per workspace at~/.ucode/model-prices-<host hash>.json.USDcost group: per-million-token rates for input, output, cache reads, and 5m/1h cache writes.system.ainames. This covers Bedrock-style ids,-colo-on-*deployments, and dotted versions.Testing
tests/test_smart_routing_savings.pycovers baselines, user switches, net cost increases, cache-write splits, first-prompt start-model pricing, voiding on unpriced or malformed entries, the row wording, and the pricer subprocess (one UTF-8 JSON line under an ASCII locale; never fails).tests/test_smart_routing_pricing.pyandtests/test_databricks.pycover rate mapping and the endpoint request.tests/test_skills.pycovers the skill version.tests/test_claude_mod.pyandtests/test_claude_smart_routing_v2.pycover the plugin contents, option defaults, launch options for both routing modes, the opt-out, and the background price refresh.tests/native_claude/test_mod.py):pluginConfigsand stay launch-local;turn.stepevents, and rendering of the row above the prompt. Those will be checked in the laptop run above.test_e2e_user_agenttests that also fail on cleanmain;ruffandtyclean.Also in this PR: tracing CI fix
The Claude and Codex tracing journeys were timing out (
SQL statement did not finish within 180 seconds).tests/integration/utils/sql.pypicked the first warehouse when none was running, then counted warehouse startup against the query's 180s budget. The fix:PENDINGbefore the 180s execution limit starts;This can move to its own PR if reviewers prefer.
This pull request and its description were written by Isaac.