Skip to content

Agents panel: fix Codex limits for Codex CLI 0.149.0 - #7908

Closed
tahadx wants to merge 1 commit into
omacom:quattrofrom
tahadx:fix/codex-approval-policy
Closed

tahadx wants to merge 1 commit into
omacom:quattrofrom
tahadx:fix/codex-approval-policy

Conversation

@tahadx

@tahadx tahadx commented Aug 23, 2026

Copy link
Copy Markdown

Closes #7873.

What

The Codex collector spawned the app-server with -a untrusted, and Codex CLI 0.149.0 removed that value from --ask-for-approval:

error: invalid value 'untrusted' for '--ask-for-approval <APPROVAL_POLICY>'
  [possible values: on-request, never]

The process exited on argument parsing before ever answering initialize, so every subscription-limit meter read "Codex Limits Unavailable / initialize".

Fix

Spawn with -a never instead. Two reasons for that specific value over dropping the flag or using on-request:

  1. Valid across versions — both old CLIs (where all four policies existed) and 0.149+ accept it.
  2. Cannot stall a detached poller — this collector runs detached with no UI; an approval policy that can prompt is one that can hang the poll forever. Combined with the existing -s read-only sandbox, never is the only policy that can never block.

Verification

  • Reproduced the argparse failure locally on codex 0.149.0, then confirmed -a never app-server answers the initialize RPC (both never and on-request do).
  • The collector now completes its RPC handshake against real codex 0.149.0 (usageStatusText empty instead of "limits unavailable"); limit meters populate wherever the CLI is authenticated.
  • agent-usage-codex-scanner-test.sh extended: the stubbed codex logs its spawn args, and the test asserts -a never is present and untrusted never returns.

Codex CLI 0.149.0 removed untrusted from --ask-for-approval, so the
collector's spawn exited on argument parsing before answering the
initialize RPC and every limits meter read unavailable. Use never: it is
valid across CLI versions, and this poller is detached, so a policy that
can prompt could never be answered anyway — the read-only sandbox stays.
Verified against codex 0.149.0 locally. Closes omacom#7873.
Copilot AI balanced review requested due to automatic review settings August 23, 2026 15:16

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

Fixes Codex limit collection with Codex CLI 0.149.0 by using a supported, non-interactive approval policy.

Changes:

  • Replaces -a untrusted with -a never.
  • Adds regression coverage for the spawned arguments.

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 no comments.

File Description
bin/omarchy-agent-usage-codex Uses the compatible, prompt-free Codex approval policy.
test/shell.d/agent-usage-codex-scanner-test.sh Verifies -a never is used and untrusted is absent.

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

@tahadx tahadx left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reviewer disclosure: this review was written by an AI coding assistant (ox-alpha) at the contributor's request, and posted with their approval. Please weigh it alongside human review.

What I checked

Swapping -a untrusted for -a never is the right call, and the reasoning in the comment earns its place in the source: the value is accepted by both pre-0.149 and current CLIs, and a detached poller with no UI must never run under a policy that can prompt — combined with the existing -s read-only sandbox, never is the only choice that cannot wedge the collector waiting for an approval that can never arrive.

Observations

  • Test directionality is good: the spawn-arg log asserts both that never is present and that untrusted never returns, so a future regression in either direction trips the suite. Logging the stub's argv rather than mocking the RPC layer keeps the assertion honest against argparse changes.
  • One observation, not for this PR: stderr=subprocess.DEVNULL on the Popen is why an argparse failure like this one stayed invisible until users hit "Codex Limits Unavailable". If you ever want faster diagnosis of similar breakage, teeing collector stderr to a debug file would surface it immediately. Out of scope here.

Focused fix, correct value chosen for principled reasons, verified against the real CLI version that broke. LGTM as far as I can tell.

@Milofax

Milofax commented Aug 24, 2026

Copy link
Copy Markdown

Independently confirmed this fix on Omarchy 4.0.0-1 with codex-cli 0.149.0.

Before the change, codex -s read-only -a untrusted app-server exits immediately because untrusted is no longer accepted, and the Agents panel displays Codex limits unavailable / initialize while local token statistics continue to work.

I tested the collector with the proposed prompt-free -a never policy against a live ChatGPT-authenticated Codex installation. The RPC handshake completed and returned:

  • tierLabel: "pro"
  • a populated 7-day limit window
  • an empty usageStatusText

I also verified the result in the running Omarchy panel: the Codex tab showed the Pro plan and weekly limit meter, with the red initialize card gone. This matches the intended behavior of this PR.

@tahadx

tahadx commented Aug 25, 2026 via email

Copy link
Copy Markdown
Author

@omarchybot

Copy link
Copy Markdown
Collaborator

#7649 is merged (4cd8a08) and makes this same fix: the collector now launches app-server with -a on-request instead of the retired untrusted, with the launch arguments asserted in the collector test.

Closing as superseded. #7873, which this closed, is closed too. The argument for never over on-request was a fair one — on-request won because nothing in the collector's read-only RPC path can raise an approval request, so it can't stall either.

@omarchybot omarchybot closed this Aug 25, 2026
@tahadx
tahadx deleted the fix/codex-approval-policy branch August 25, 2026 18:22
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 plugin cannot read Codex limits with Codex CLI 0.149.0 because -a untrusted is invalid

4 participants