Skip to content

Make Codex account/read optional in the usage collector - #13464

Closed
AnPod wants to merge 2 commits into
omacom:quattrofrom
AnPod:fix/codex-usage-optional-account-read
Closed

AnPod wants to merge 2 commits into
omacom:quattrofrom
AnPod:fix/codex-usage-optional-account-read

Conversation

@AnPod

@AnPod AnPod commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Stacked on #13458 (same call sites); rebase trivially if that lands first.

Summary

The reporter measured account/read never answering within 15s on 5 of 8 fresh app-server processes while account/rateLimits/read answered every time in 0.3–0.9s (#13266). Because both calls sit in one try, the TimeoutError("account/read") replaced the whole refresh with "Codex limits unavailable" and limits: [], discarding data that was one reply away.

  • account/rateLimits/read — the payload the panel actually shows — is now requested first.
  • account/read, which only supplies a fallback plan label (planType already comes from rateLimits first), is now wrapped in its own try with a short timeout; its failure leaves the limits intact.

Fixes #13266

Testing

  • Extended agent-usage-codex-scanner-test.sh with a fake app-server that never answers account/read: the collector must still print a clean record (usageStatusText empty) with limits present. All 23 assertions pass.
  • python3 -m py_compile passes.

account/read and account/rateLimits/read usually answer in ~2s but
routinely spike past the 4s deadline, which discards the entire
refresh's rate-limit data even though the previous cycle was fine.
10s leaves ample margin while still bounding a hung app-server.

Fixes omacom#13425
On some setups the app-server never replies to account/read at all while
rateLimits/read answers every time. The single try block treated that
silence as a total failure and replaced the whole refresh with
'Codex limits unavailable', dropping limits that were one reply away.
Ask for rateLimits/read first and keep account/read as an optional
fallback wrapped in its own try, so its silence only costs the plan-label
fallback it was providing.

Fixes omacom#13266
@dhh

dhh commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Thanks! This landed as #13733: limits are read first, and account/read is only a fallback for the plan. Closing.

@dhh dhh closed this Oct 2, 2026
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.

Agents: Codex limits dropped when app-server never answers account/read

2 participants