Skip to content

Codex collector: plan label and model-scoped limit windows - #7725

Open
nixfred wants to merge 1 commit into
omacom:quattrofrom
nixfred:feat/codex-limits-parity
Open

nixfred wants to merge 1 commit into
omacom:quattrofrom
nixfred:feat/codex-limits-parity

Conversation

@nixfred

@nixfred nixfred commented Aug 22, 2026

Copy link
Copy Markdown

Changes

Brings the Codex tab of the Agents panel up to parity with the Claude tab. account/rateLimits/read already returns more than the collector showed, so this only surfaces what Codex reports:

  • tierLabel becomes a human plan name (prolite → "Pro Lite", plus → "Plus") instead of the raw API token, matching Claude's "Max 20x" / "Pro".
  • Window labels follow the Claude collector's wording ("Session (5-hour)", "Weekly (7-day)") so the LIMITS section reads the same on both tabs.
  • Model-scoped allowances under rateLimitsByLimitId (e.g. "GPT-5.3-Codex-Spark", each with its own 5-hour and weekly window) are emitted with a title, the way Claude reports "Fable Weekly", so the panel renders them as their own rows instead of dropping them.
  • spendControlReached surfaces as the usage status text.
  • Launches app-server with -a on-request, same as Fix Codex usage collection on 0.149 #7649 (Codex 0.149 retired untrusted, Codex 0.149 breaks Agents panel limit display #7648). Happy to rebase on Fix Codex usage collection on 0.149 #7649 once it lands — this is meant to stack on it, not compete with it.

Before (Codex 0.149.0, Pro Lite): no plan, limits: [].
After:

tierLabel: "Pro Lite"
Weekly (7-day)                          6%
GPT-5.3-Codex-Spark Session (5-hour)    0%
GPT-5.3-Codex-Spark Weekly (7-day)      0%

Tests

  • bash test/shell.d/agent-usage-codex-scanner-test.sh — mock app-server now answers with a realistic rateLimits / rateLimitsByLimitId payload; asserts the plan label and every limit row.
  • ./test/cli
  • live bin/omarchy-agent-usage-codex --limits-only against Codex CLI 0.149.0 on Omarchy 4.0.0-1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PDPn6hVmawjV1sSRLedsUD

Copilot AI balanced review requested due to automatic review settings August 22, 2026 01:23
@nixfred
nixfred force-pushed the feat/codex-limits-parity branch from c0dc557 to 2c9a34a Compare August 22, 2026 01:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Brings Codex usage reporting closer to Claude’s Agents panel presentation.

Changes:

  • Adds human-readable plan and limit labels.
  • Exposes model-scoped limits and spend-control status.
  • Uses Codex’s supported on-request approval policy and expands tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
bin/omarchy-agent-usage-codex Normalizes and collects expanded Codex limit data.
test/shell.d/agent-usage-codex-scanner-test.sh Adds realistic plan and scoped-limit assertions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

;;
account/rateLimits/read)
jq -cn --argjson id "$id" '{id: $id, result: {rateLimits: {}}}'
jq -cn --argjson id "$id" '{id: $id, result: {rateLimits: {limitId: "codex", planType: "prolite", primary: {usedPercent: 6, windowDurationMins: 10080, resetsAt: 1787887121}, secondary: null}, rateLimitsByLimitId: {codex: {limitId: "codex", planType: "prolite", primary: {usedPercent: 6, windowDurationMins: 10080, resetsAt: 1787887121}}, codex_bengalfox: {limitId: "codex_bengalfox", limitName: "GPT-5.3-Codex-Spark", primary: {usedPercent: 0, windowDurationMins: 300, resetsAt: 1787379264}, secondary: {usedPercent: 12, windowDurationMins: 10080, resetsAt: 1787966064}}}}}'
The Codex row reported a plan and limit windows that did not match what Codex
itself shows: the label ignored the plan on the account, and limit windows were
read without scoping them to the model they belong to, so a window for one
model could be reported against another.

Read the plan label from the account record, and scope each limit window to its
model before reporting it. A future-dated cache is treated as a miss rather
than trusted, --limits-only falls back to a full scan when no cache exists, and
an interrupted scan is no longer cached as if it had completed.

test/shell.d/agent-usage-codex-scanner-test.sh covers the cache miss, the
fallback, malformed rows, an unwritable cache, and the interrupted scan. All
pass on quattro.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TT7trpn4vaR9Yj4yLdPjd1
@nixfred
nixfred force-pushed the feat/codex-limits-parity branch from fb8a344 to f7e5af0 Compare September 8, 2026 15:29
@nixfred

nixfred commented Sep 8, 2026

Copy link
Copy Markdown
Author

Rebased onto current quattro — sorry for the noise, and thank you for your patience on this one.

This PR had drifted so far from its base that GitHub was rendering it as ~118,000 lines across 100 files, which made the Codex collector change impossible to actually review. That was an artifact of the branch point, not the change.

It is now the real diff and nothing else. Tests pass on today's quattro.

No behaviour has changed from what was originally proposed — only the base it sits on.

@nixfred

nixfred commented Sep 9, 2026

Copy link
Copy Markdown
Author

On the Copilot note about the mock not inspecting its arguments — that was right, and it is already handled in this branch. test/shell.d/agent-usage-codex-scanner-test.sh now rejects any invocation other than the expected one, so a regression back to -a untrusted fails the test rather than passing it:

# Fail if the collector regresses to `-a untrusted` (Codex 0.149 / #7648).
if [[ $1 != "-s" || $2 != "read-only" || $3 != "-a" || $4 != "on-request" || ${5:-} != "app-server" ]]; then
  echo "unexpected codex invocation: $*" >&2
  exit 1
fi

The comment predates the rebase, so it may be pointing at the older diff.

@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
@dhh dhh mentioned this pull request Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants