Skip to content

fix: show account limits in desktop and TUI /usage - #58339

Open
whzy1314 wants to merge 1 commit into
NousResearch:mainfrom
whzy1314:fix-usage-account-limits-desktop-tui
Open

fix: show account limits in desktop and TUI /usage#58339
whzy1314 wants to merge 1 commit into
NousResearch:mainfrom
whzy1314:fix-usage-account-limits-desktop-tui

Conversation

@whzy1314

@whzy1314 whzy1314 commented Jul 4, 2026

Copy link
Copy Markdown

Summary

  • show provider account limits and available rate-limit lines in Desktop and Ink TUI /usage
  • resolve provider identity from the live agent or compute-host metadata/profile context, including OpenAI Codex credential-pool fallback
  • keep account-usage reads bounded, fail-open, and off the gateway RPC reader
  • intercept only bare /usage, preserving /usage reset [--force] and invalid-subcommand handling through the CLI worker
  • retain the current Nous balance model and session-token presentation

Verification

  • uv run pytest tests/tui_gateway/test_protocol.py -q — 46 passed
  • npm --workspace ui-tui run check — 1,530 passed, 1 skipped; typecheck/build/lint passed (one unrelated pre-existing hook warning)
  • uv run ruff check tui_gateway/server.py tui_gateway/methods_session.py tests/tui_gateway/test_protocol.py
  • uv run python -m py_compile tui_gateway/server.py tui_gateway/methods_session.py
  • git diff --check
  • live OpenAI Codex credential-pool smoke test confirmed Desktop output contains session usage and account limits

Closes #45713

@alt-glitch alt-glitch added type/feature New feature or request comp/tui Terminal UI (ui-tui/ + tui_gateway/) area/billing Account usage, credit usage, billing (cross-cutting) P3 Low — cosmetic, nice to have labels Jul 4, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tracing the split between the live TUI session and the slash-worker agent; current tui_gateway/server.py:6519-6542 confirms that account and rate-limit lines are still absent from the TUI /usage payload.

Problems

  • The new unconditional slash.exec /usage branch would consume /usage reset [--force] and arbitrary /usage arguments as plain usage output. Current main explicitly implements reset and unknown-subcommand handling in cli.py:9676-9691, added by 89bd0fba903b after this PR's 426174a64e81 commit.
  • session.usage is dispatched inline because it is absent from _LONG_HANDLERS (tui_gateway/server.py:178-232, 1277-1279). The proposed ten-second account-usage wait would therefore block that fast RPC path.

Suggested changes

  • Preserve the current /usage reset [--force] and invalid-subcommand contract when routing live-session usage, and cover both through slash.exec.
  • Keep provider account retrieval out of the inline session.usage path, or explicitly offload/cache it and test responsiveness.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@whzy1314
whzy1314 force-pushed the fix-usage-account-limits-desktop-tui branch from 426174a to 8c57b4a Compare July 15, 2026 17:20
@whzy1314

Copy link
Copy Markdown
Author

Addressed in 8c57b4a33.

  • Rebased the PR onto current main.
  • Limited the live-session shortcut to bare /usage; /usage reset [--force] and invalid subcommands continue through HermesCLI, preserving the existing reset/error contract.
  • Added session.usage to _LONG_HANDLERS, so provider account retrieval is offloaded from the inline RPC path.
  • Added regression coverage for reset/invalid-subcommand routing and for session.usage not blocking fast RPC handlers.

Verification:

  • scripts/run_tests.sh tests/tui_gateway/test_protocol.py -v --tb=short — 88 passed
  • npm --workspace ui-tui run typecheck — passed
  • npm --workspace ui-tui run build — passed
  • python -m py_compile tui_gateway/server.py — passed

@teknium1 teknium1 added the area/usage-cost Token accounting, usage reporting, billing, cost tracking label Jul 19, 2026
@whzy1314
whzy1314 force-pushed the fix-usage-account-limits-desktop-tui branch from 8c57b4a to 0e2cada Compare August 3, 2026 22:25
@whzy1314

whzy1314 commented Aug 3, 2026

Copy link
Copy Markdown
Author

Refreshed onto current main in 0e2cada88.

  • adapted the implementation to the split methods_session.py / methods_tools.py architecture
  • Desktop bare /usage now appends provider account limits and available rate-limit lines
  • TUI session.usage returns and renders the same data without regressing the current balance view
  • /usage reset [--force] and invalid subcommands continue through the CLI worker
  • provider fetches are bounded, fail-open, profile-scoped, and off the RPC reader

Verification: 46 gateway protocol tests passed; the full Ink TUI check passed with 1,530 tests passed and 1 skipped; Ruff, Python compile, and diff checks passed; a live OpenAI Codex credential-pool smoke test confirmed the Desktop output path.

@whzy1314
whzy1314 force-pushed the fix-usage-account-limits-desktop-tui branch from 0e2cada to e181acc Compare August 9, 2026 20:34
@whzy1314

whzy1314 commented Aug 9, 2026

Copy link
Copy Markdown
Author

Rebased onto current main in e181acc and resolved the tests/tui_gateway/test_protocol.py conflict while preserving the current gateway/TUI contracts.

Verification:

  • scripts/run_tests.sh tests/tui_gateway/test_protocol.py -v --tb=short — 48 passed
  • npm --workspace ui-tui run check — 1,545 passed, 1 skipped; typecheck passed; lint passed with one pre-existing warning
  • Ruff, Python compile, Windows-footgun, and diff checks passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing Account usage, credit usage, billing (cross-cutting) area/usage-cost Token accounting, usage reporting, billing, cost tracking comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

3 participants