Show budget spend and threshold in ucode usage - #261
Draft
andy-xu-db wants to merge 1 commit into
Draft
Conversation
`ucode usage` reported tokens only, with no dollar figure. Surface the caller's
live coding-agent budget spend against its alert threshold, from the AI Gateway
`coding-agent-configs:resolveCurrentBudgetSpend` endpoint.
Budget spend: $12.34 of $100.00 (12%)
[███░░░░░░░░░░░░░░░░░░░░░░░░░░░]
- databricks.py: `resolve_current_budget_spend` POSTs an empty body (caller and
workspace come from the bearer) and parses both amounts as `Decimal`. Absence
is the common case — the endpoint is behind a per-org SAFE flag (default off),
needs a coding-agent config, and returns both fields unset when no budget
matches — so all of it comes back as a reason string, never an exception. A
spend without a threshold counts as no spend, mirroring the server's
`BudgetSpend.fromProto`.
- ui.py: `format_usd` (half-up to cents) and `format_meter` (clamped to [0, 1];
a nonzero fraction fills at least one cell so a small real spend doesn't read
as an empty bar).
- usage.py: `render_budget_lines` + a `budget_spend` arg on
`render_usage_summary`. Unavailable spend omits the lines rather than failing
the report; a zero threshold shows the bare amount, since there is no whole to
be a fraction of.
Co-authored-by: Isaac
andy-xu-db
force-pushed
the
andy/update-ucode-usage
branch
from
August 3, 2026 22:32
55973b2 to
68d3b5b
Compare
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.
No description provided.