Skip to content

Show budget spend and threshold in ucode usage - #261

Draft
andy-xu-db wants to merge 1 commit into
mainfrom
andy/update-ucode-usage
Draft

Show budget spend and threshold in ucode usage#261
andy-xu-db wants to merge 1 commit into
mainfrom
andy/update-ucode-usage

Conversation

@andy-xu-db

Copy link
Copy Markdown
Collaborator

No description provided.

`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
andy-xu-db force-pushed the andy/update-ucode-usage branch from 55973b2 to 68d3b5b Compare August 3, 2026 22:32
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.

1 participant