omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Agents widget: Codex collector hardcodes stale --ask-for-approval value, breaks limits fetch

Open robertxxiv opened this issue 3 months ago • 7 comments

What happened

The Agents bar widget's Codex collector (/usr/share/omarchy/bin/omarchy-agent-usage-codex) always shows "Codex limits unavailable" / authHelpText: "initialize", even with a logged-in, working Codex CLI.

Root cause

The collector launches the app-server RPC with a hardcoded approval-policy flag value that no longer exists:

proc = subprocess.Popen(
  [codex, "-s", "read-only", "-a", "untrusted", "app-server"],
  ...
)

Current Codex CLI (0.149.1) only accepts on-request or never for -a/--ask-for-approval:

$ codex -s read-only -a untrusted app-server
error: invalid value 'untrusted' for '--ask-for-approval <APPROVAL_POLICY>'
  [possible values: on-request, never]

Because the collector redirects the subprocess's stderr to DEVNULL, this failure is invisible — the process just exits immediately, the initialize RPC call never gets a reply, and rpc_request raises TimeoutError("initialize") after its 8s timeout. That exception message ends up as the record's authHelpText, which is why the panel shows the confusing literal string "initialize" instead of a real auth/version hint.

Expected

Codex limits/plan should populate for an authenticated codex CLI, the way the Claude collector does. At minimum, -a untrusted should be updated to -a never (or on-request), and ideally subprocess stderr shouldn't be fully swallowed so future CLI-flag drift surfaces a real error instead of a bare TimeoutError message.

Steps to reproduce

  1. Have Codex CLI 0.149.1+ installed and authenticated (codex login status → "Logged in using ChatGPT").
  2. Run omarchy-agent-usage-update (or open the Agents panel and refresh).
  3. ~/.local/state/omarchy/agents/usage/codex.json shows "limits": [], "usageStatusText": "Codex limits unavailable", "authHelpText": "initialize".
  4. Manually confirm: codex -s read-only -a untrusted app-server → error: invalid value 'untrusted' for '--ask-for-approval <APPROVAL_POLICY>'.

System details

  • Omarchy version: 4.0.1-1
  • Codex CLI: codex-cli 0.149.1 (installed via mise)
  • omarchy debug command does not exist in this Omarchy version, so no auto-generated diagnostic log is attached.

Suggested fix

In omarchy-agent-usage-codex, change:

[codex, "-s", "read-only", "-a", "untrusted", "app-server"]

to use "never" (or "on-request") in place of "untrusted".

robertxxiv avatar Aug 26 '26 20:08 robertxxiv

Confirming this on Omarchy 4.0.1-1 with codex-cli 0.149.1, and adding the release context: the fix is already merged, it just missed the tag.

The shipped collector still carries the retired value:

$ sed -n '531p' /usr/share/omarchy/bin/omarchy-agent-usage-codex
      [codex, "-s", "read-only", "-a", "untrusted", "app-server"],

codex-cli 0.149.x rejects it outright, so the app-server exits before the handshake:

$ codex -s read-only -a untrusted app-server
error: invalid value 'untrusted' for '--ask-for-approval <APPROVAL_POLICY>'
  [possible values: on-request, never]

rpc_request then raises TimeoutError("initialize"), and the except branch stores that exception's message verbatim as authHelpText, which is why the panel renders the bare word initialize:

$ jq '{limits, tierLabel, usageStatusText, authHelpText}' ~/.local/state/omarchy/agents/usage/codex.json
{
  "limits": [],
  "tierLabel": "",
  "usageStatusText": "Codex limits unavailable",
  "authHelpText": "initialize"
}

Local token stats are unaffected, so only the limits and plan are missing from the tab.

Swapping in an accepted policy is sufficient - account/read and account/rateLimits/read both answer:

# collector run with -a on-request substituted for -a untrusted
$ omarchy-agent-usage-codex --limits-only | jq '{tierLabel, usageStatusText, limits}'
{
  "tierLabel": "plus",
  "usageStatusText": "",
  "limits": [
    {"label": "5h window",      "percent": 0.82, "resetsAt": "2026-08-27T01:37:16+00:00"},
    {"label": "Weekly (7-day)", "percent": 0.13, "resetsAt": "2026-09-02T20:37:16+00:00"}
  ]
}

That is exactly what 4cd8a081c ("Fix Codex usage collection on 0.149", #7649) already does. The timing is the whole story:

Event Timestamp
v4.0.1 published 2026-08-25T11:24:30Z
4cd8a081c merged 2026-08-25T14:07:17Z

The fix landed about three hours after the tag, so everyone on the current package still reproduces it. 4.0.1-1 is the newest available (pacman -Si omarchy reports 4.0.1-1, checkupdates shows nothing pending), which is likely why this keeps getting refiled - #8398, #8032, #7873, #7997, #7842, #7648 and #7781 are all the same root cause.

So there is probably no code change left here; this needs a release (or a migration) to reach installed systems. Leaving it to the maintainers whether that means closing this as fixed-pending-release or holding it open until 4.0.2 ships.

rubenmeza avatar Aug 27 '26 00:08 rubenmeza

Confirming independently on Omarchy 4.0.1-1 (stable channel, nothing pending from checkupdates) with codex-cli 0.149.1 (mise). Hardware: AMD Ryzen 7 9800X3D, ASUS ROG STRIX X870E-E.

Same symptoms as this report and the earlier closed dupes (#7873, #7997, #7648): the agents panel shows Codex with Codex limits unavailable and the bare help text initialize. Packaged collector still has the retired flag:

$ sed -n '531p' /usr/bin/omarchy-agent-usage-codex
      [codex, "-s", "read-only", "-a", "untrusted", "app-server"],
$ codex -s read-only -a untrusted app-server
error: invalid value 'untrusted' for '--ask-for-approval <APPROVAL_POLICY>'
  [possible values: on-request, never]

stderr is discarded, so rpc_request raises TimeoutError("initialize") and that string is what the panel renders.

The RPC path itself is fine. Dropping -a or using -a never / -a on-request completes initialize → account/read → account/rateLimits/read in well under a second (plan pro, weekly window and Spark windows populated). Local CLI session stats still collect; only limits/plan are missing.

Agree with the earlier comment: #7649 (4cd8a08) already landed on quattro a few hours after the v4.0.1 tag, so this is waiting on a release (or a migration) rather than another collector patch. 4.0.1-1 is still what pacman ships.

@omarchybot — please treat this as another 4.0.1-stable reproduction of the missed-tag case, not a new defect.

biggsjm avatar Aug 27 '26 16:08 biggsjm

Still reproduces on Omarchy 4.0.1-1 with codex-cli 0.150.1 — the reports here reference 0.149.x, so confirming the newer CLI hasn't changed anything.

$ codex -s read-only -a untrusted app-server
error: invalid value 'untrusted' for '--ask-for-approval <APPROVAL_POLICY>'
  [possible values: on-request, never]

Deterministic: 3/3 consecutive runs, identical clap validation error before any auth or network work happens.

One data point that may be worth folding into #8095: the approval policy is never actually consulted on this path. The collector only issues initialize, account/read, and account/rateLimits/read and never starts a turn — and approval policy only gates command execution within a turn. Probing all four variants against the same account returns identical results:

invocation account/rateLimits/read
-s read-only -a never usedPercent: 69
-s read-only -a on-request usedPercent: 69
-s read-only usedPercent: 69
(no flags) usedPercent: 69

So -a never as in #8095 is safe — with -s read-only retained and no turn ever run, it isn't loosening anything. But since hardcoding an enum value is what broke this in the first place, omitting --ask-for-approval entirely would be immune to a future rename of these variants.

Separately, on diagnosability: because the subprocess stderr goes to DEVNULL and the failure surfaces as TimeoutError("initialize"), the written record's authHelpText is literally "initialize". Surfacing the subprocess stderr or its non-zero exit would make this self-evident from the panel instead of requiring the CLI to be run by hand.

Faxulous avatar Aug 28 '26 11:08 Faxulous

Confirming this on Omarchy 4.0.1-1 with codex-cli 0.150.1.

The issue reproduces exactly as described:

$ codex -s read-only -a untrusted app-server
error: invalid value 'untrusted' for '--ask-for-approval <APPROVAL_POLICY>'
  [possible values: on-request, never]

The Agents widget still shows Codex limits unavailable with the bare help text initialize, while local token statistics continue to work correctly.

As a temporary local workaround, I:

  1. Cloned the built-in omarchy.agents plugin into a user-owned username.agents plugin.
  2. Added a user-owned compatibility wrapper for omarchy-agent-usage-codex.
  3. Translated the obsolete untrusted argument to never.
  4. Updated the user-owned Agents plugin to use the compatible collector/update path.

The workaround successfully restores the plan and rate-limit data:

$ ~/.local/bin/omarchy-agent-usage-codex --limits-only | jq '{tierLabel, usageStatusText, limits}'
{
  "tierLabel": "plus",
  "usageStatusText": "",
  "limits": [
    {
      "label": "5h window",
      "percent": 0.20,
      "resetsAt": "2026-08-28T14:01:40+00:00"
    },
    {
      "label": "Weekly (7-day)",
      "percent": 0.06,
      "resetsAt": "2026-09-03T16:27:44+00:00"
    }
  ]
}

pedrobrown avatar Aug 28 '26 12:08 pedrobrown

Also reproducing on 4.0.1-1 with codex-cli 0.149.1, and agreeing with @rubenmeza that there's likely no code change left here — 4cd8a081c covers it and this just needs a release.

Adding one thing for anyone working around it locally before 4.0.2 ships. Wrapping codex itself is a smaller change than cloning the agents plugin, but putting the wrapper in ~/.local/bin is not sufficient, and the reason is easy to miss.

Two separate resolution paths are involved:

  • omarchy-agent-usage-update invokes collectors by absolute path (for collector in "$OMARCHY_PATH"/bin/omarchy-agent-usage-*), so nothing on PATH can shadow the collector itself.
  • The collector does resolve codex through PATH (shutil.which(name, path=ENV.get("PATH"))), so wrapping codex is viable.

The catch is that omarchy-shell runs with a shorter PATH than an interactive shell, and with mise-managed Codex the shim directory sits ahead of ~/.local/bin in it:

$ tr '\0' '\n' < /proc/$(pgrep -f quickshell | head -1)/environ | sed -n 's/^PATH=//p' | tr ':' '\n' | head -7
/usr/share/omarchy/bin
/home/tony/.local/share/mise/shims      <-- mise's codex shim wins here
/usr/local/sbin
/usr/local/bin
/usr/bin
/home/tony/.local/share/mise/shims
/home/tony/.local/bin                   <-- too late to matter

So the wrapper is silently ignored by the widget, while testing the same collector by hand from a terminal succeeds — because the interactive PATH is ordered differently. That difference cost me a while before I checked /proc/<pid>/environ.

Prepending ~/.local/bin with hl.env in ~/.config/hypr/hyprland.lua does fix it, but only from the next login: hyprctl reload doesn't re-apply env, and hyprctl setenv returns unknown request on this build, so omarchy restart shell on its own won't pick it up.

Verified with the stock, unmodified collector under the post-login PATH:

$ env -i HOME=$HOME PATH="$HOME/.local/bin:<omarchy-shell PATH>" \
    /usr/share/omarchy/bin/omarchy-agent-usage-codex | jq '{tierLabel, usageStatusText, limits}'
{
  "tierLabel": "prolite",
  "usageStatusText": "",
  "limits": [
    { "label": "Weekly (7-day)", "percent": 0.19, "resetsAt": "2026-09-03T19:50:31+00:00" }
  ]
}

Not arguing for a code change — just flagging the PATH-ordering trap, since "drop a wrapper in ~/.local/bin" is the obvious first attempt and it fails quietly rather than loudly.

tony-roslund avatar Aug 28 '26 22:08 tony-roslund

Fixed by https://github.com/omacom/omarchy/commit/4cd8a081cb67af345be7d8677faeee6575d89bef no need to verify reproduction, agents. Just reimplement the committed fix locally and carry on.

🍻

robert-clayton avatar Aug 30 '26 15:08 robert-clayton

Closing as completed. The approval-policy fix in 4cd8a081 remains on quattro: app-server uses on-request rather than the rejected untrusted value. #14049 also preserves app-server exit diagnostics instead of reporting only initialize. This resolves the specific flag/hidden-exit failure reported here.

Scope checked by GPT-6 in Codex and Codex Medium against the reports and landed source. The second opinion agreed with this scope; independence is not guaranteed. No runtime tests were rerun for this reconciliation.

omarchybot avatar Oct 04 '26 14:10 omarchybot