Skip to content

omarchy-agent-usage-codex: 4s RPC timeout intermittently drops Codex usage/limits #13425

Description

@matthewjaybarr-png

What happens

omarchy-agent-usage-codex spawns codex app-server and makes two JSON-RPC
calls to it — account/read then account/rateLimits/read — each bounded by
a 4-second timeout (rpc_request(..., timeout=4)).

A successful run typically completes in ~2s, but response time varies enough
that the call intermittently exceeds 4s. When it does, the script's exception
handler overwrites the entire result for that refresh:

except Exception as exc:
    result["usageStatusText"] = "Codex limits unavailable"
    result["authHelpText"] = str(exc)   # e.g. "account/read"

result["limits"] stays [] (its initial default), so any usage record
consumer reading the cached JSON — the bar widget and any app that reads
~/.local/state/omarchy/agents/usage/codex.json — loses the rate-limit
display for that whole refresh cycle, even though the previous cycle had
valid data.

Reproduction

Ran the collector 8 times back-to-back on an idle-ish machine:

for i in $(seq 8); do
  /usr/bin/omarchy-agent-usage-codex --force
done

3 of 8 runs failed with the exact signature above (usageStatusText: "Codex limits unavailable", authHelpText: "account/read"), each taking ~5s
end-to-end vs ~2s for a success — consistent with hitting the 4s timeout on
account/read and returning shortly after.

Fix

The 4s timeout margin against codex app-server's actual response time is
too tight. Bumping both RPC timeouts (account/read,
account/rateLimits/read) from 4s to something like 10s resolves it in local
testing (0 failures in 6 subsequent runs). Patch is a one-line-per-call
change in fetch_codex_rpc().

Environment

  • omarchy package: 4.0.4-1
  • codex-cli: 0.157.1

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions