Usage → Limits hides OpenCode Console 401 auth failure behind generic "OpenCode could not read workspace usage." warning #40331
What happened#
On Usage → Limits (All environments / All providers, and filtered to OpenCode) in T3 Code Desktop, OpenCode displays the generic warning "OpenCode: OpenCode could not read workspace usage." on every refresh, with no indication of why the check failed or how to resolve it. The Cost and Tokens tabs are unaffected because they read local session logs instead of this endpoint.
Diagnosis#
- On OpenCode v2, T3 Code queries
GET /api/experimental/usage/limits?location[directory]=<dir>inpackages/provider-opencode/src/server/v2/usageLimits.ts(readServerUsageLimits, lines 69–193). - When a stored OpenCode Console login in
~/.local/share/opencode/opencode.db(credentialtable,integration_id = 'opencode') has expired or been revoked onopencode.ai, OpenCode v2.3.2 responds with HTTP 503 and a JSON body explaining the real upstream failure (401 GET https://opencode.ai/console/api/policies/current-budgets). packages/provider-opencode/src/server/v2/usageLimits.ts:84-86passes the response throughHttpClientResponse.filterStatusOk(response)without reading the error payload.- Lines 185–191 then swallow every failure with
Effect.orElseSucceedand return a hardcoded generic message:
(makeUnavailableUsageLimits({ checkedAt, reason: "probeFailed", message: "OpenCode could not read workspace usage.", })packages/provider-opencode/src/server/driver.ts:495-504has a matching catch-all fallback.) - Because the response body and upstream
401status are discarded, users with an expired OpenCode Console session have no actionable feedback. Surfacing OpenCode's error message—or detecting a Console401and suggestingopencode auth login opencode/opencode auth logout opencode—would make the warning self-serviceable. - Checked
packages/provider-opencode/src/server/v2/usageLimits.tsonmain/v0.1.12-nightly.20261121.5038: unchanged sinceb9f24b627f(2026-11-16).
Steps to reproduce#
- Have OpenCode v2 (
v2.3.2) installed with a stored OpenCode Console credential (opencode auth listshowsOpenCode Console <account> stored) whose token has expired or been revoked onopencode.ai. - Open T3 Code Desktop (
0.1.11, local server) and go to Usage → Limits (All environments / All providers), then refresh. - Observe that
GET /api/experimental/usage/limitsfails with HTTP 503 containing the upstream 401 Console error, while the T3 Code UI only shows"OpenCode could not read workspace usage.".
Version#
0.1.11 (T3 Code Desktop + local server, commit 59651c17; unchanged in v0.1.12-nightly.20261121.5038)
Environment#
macOS 27.2.1 (darwin arm64), Node v24.22.1, opencode v2.3.2, T3 Code Desktop 0.1.11 (local server)
Evidence#
# server.trace.ndjson (redacted)
{"type":"effect-span","name":"GET","kind":"client","durationMs":298.8165,"attributes":{"http.request.method":"GET","url.full":"http://127.0.0.1:49754/api/experimental/usage/limits?location%5Bdirectory%5D=%2FUsers%2F<user>","url.path":"/api/experimental/usage/limits","http.response.status_code":503,"error.type":"503"},"exit":{"_tag":"Failure","cause":"HttpClientError: StatusCode error (503 GET http://127.0.0.1:49754/api/experimental/usage/limits)"}}
# Direct call to local opencode v2.3.2 server before logging out of Console
HTTP/1.1 503 Service Unavailable
content-type: application/json
{"_tag":"ServiceUnavailableError","message":"OpenCode Console budgets are unavailable: StatusCode: non 2xx status code (401 GET https://opencode.ai/console/api/policies/current-budgets)","service":"opencode"}
# Direct call after `opencode auth logout opencode Personal`
{"location":{"directory":"~"},"data":null} [200]
Related issues#
#14983 (OpenCode Go limits missing for OpenCode 2 Console logins) — not a duplicate; that tracks Go quota discovery for Console logins, whereas this is about readServerUsageLimits discarding OpenCode's 503/401 error body and showing a generic warning.
Fix applied or workaround#
Logged out the expired OpenCode Console account (opencode auth logout opencode Personal) since Console was not needed. OpenCode then returned HTTP 200 with {"location":{"directory":"~"},"data":null}, which T3 Code treats as reason: "unsupported" and hides without a warning. Users who do want Console limits can re-authenticate with opencode auth login opencode.
Filed by#
Antigravity (Gemini 4 Neon) via t3 triage (investigation assisted by Claude Opus 5.5)
heymaaz(GitHub profile, opens in a new tab) added labelsvia-triage
tanstack-source added labelsbug
juliusmarminge closed this
Sign in to join this conversation.