t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Grok usage shows No limits reported when creditUsagePercent is omitted (0% used)

Open claudiobdlv opened this issue 1 month ago • 3 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Sign in to Grok CLI (OIDC / SuperGrok account, ~/.grok/auth.json).
  2. Be at 0% usage for the current weekly period (e.g. right after the weekly reset, no Grok usage yet).
  3. Open Usage > Limits.

Expected behavior

Grok shows a Weekly window at 0% used (100% left), resetting at currentPeriod.end. The Grok CLI's own /usage > "Usage limit" tab shows "Weekly limit (SuperGrok) 0%, Resets: October 11".

Actual behavior

Usage page shows the warning Grok: No limits reported.

Cause: grokUsageResponseToLimits (grokUsageLimits.ts) returns windows: [] when config.creditUsagePercent is undefined. The GET https://cli-chat-proxy.grok.com/v1/billing?format=credits response omits creditUsagePercent when it is 0 (proto3-style default omission), even though currentPeriod is present:

{"config":{"currentPeriod":{"type":"USAGE_PERIOD_TYPE_WEEKLY","start":"2026-10-04T03:32:07.369992+00:00","end":"2026-10-11T03:32:07.369992+00:00"},"onDemandCap":{"val":0},"onDemandUsed":{"val":0},"isUnifiedBillingUser":true,"prepaidBalance":{"val":0},"topUpMethod":"TOP_UP_METHOD_SAVED_PAYMENT_METHOD","billingPeriodStart":"2026-10-04T03:32:07.369992+00:00","billingPeriodEnd":"2026-10-11T03:32:07.369992+00:00"}}

Suggested fix: when creditUsagePercent is undefined but currentPeriod is present, treat it as 0 instead of returning an empty window list. For example, const usedPercent = response.config?.creditUsagePercent ?? (response.config?.currentPeriod ? 0 : undefined).

Impact

Cosmetic issue

Version or commit

0.0.46-nightly.20261004.2657

Environment

Ubuntu 26.04 (elitedesk) and a Windows laptop, T3 nightly, Grok CLI 1.0.46, SuperGrok (unified billing user).

Workaround

Use Grok until usage is non-zero (the field then appears), or check the Grok CLI /usage view. Not yet confirmed: a tiny test prompt did not make the field appear.

claudiobdlv avatar Oct 05 '26 03:10 claudiobdlv

I want to work on this, but I think it needs a maintainer decision first.

The current behavior is intentional. #12799 handled this exact payload (currentPeriod present, no creditUsagePercent). It chose to report no windows, so the account stays listed and shows "No limits reported." The test does not invent allowance or reset dates when billing omits them in apps/server/src/provider/Layers/GrokProvider.test.ts locks this in. The reason given in #12799 is that xAI omits the field until metered usage registers.

This issue proposes a 0% weekly window when currentPeriod is present and the field is missing. That matches the Grok CLI /usage view. But the report also says a small prompt did not make the field appear, so a missing field may not always mean 0% used.

Which behavior do you want?

  1. Keep "No limits reported." until xAI sends the field (current behavior).
  2. Show a 0% window with the reset date when currentPeriod is present.

If you choose option 2, I can open a focused PR. The change is in grokUsageResponseToLimits, with a test for the currentPeriod-only payload from this issue.

phant0um avatar Oct 05 '26 04:10 phant0um

Reproduced on macOS with T3 Code 0.1.0 (commit 81493efb71e8) and Grok CLI 1.0.62.

  • readGrokAccount gets HTTP 200 from /v1/billing?format=credits every time, and the span ends in Success.
  • ~/.t3/caches/grok.json stores "usageLimits": {"windows": []} with no unavailable reason, so the Limits page shows "No limits reported."
  • The account is at 0% weekly. CodexBar reads the same account as Weekly 0% with a reset on 25 Oct 14:33 UTC, so the period and reset are available.

+1 for #17061: treating an omitted percentage as 0 when a valid period is present would fix this.

iamshadmantaqi avatar Oct 18 '26 21:10 iamshadmantaqi

closing as addressed by #17061, merged into main: a missing Grok usage percentage is treated as zero when the response includes a complete, valid weekly or monthly billing period. Incomplete or invalid periods still report no limits.

thanks for reporting this. if you still face it on a build containing this fix, please ask us to reopen this issue or open a new issue linking back here, with your version, os and reproduction steps.

closed at the request of @UtkarshUsername.

t3-code-bot[bot] avatar Oct 21 '26 09:10 t3-code-bot[bot]