You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
codex_runtime.py unconditionally sets CODEX_API_KEY, which makes the Codex CLI discard a valid subscription auth.json #1971
codex_runtime.py (_execute_codex) sets bothOPENAI_API_KEY and CODEX_API_KEY unconditionally from the same resolved value (source comment: "some Codex builds also read CODEX_API_KEY... Defensive"). However, the mere presence of CODEX_API_KEY flips the Codex CLI into API-key auth mode, silently discarding a valid subscription auth.json. Result: subscription-authenticated Codex agents cannot complete any /task dispatch through Trinity, even though the same auth.json works perfectly when the CLI is invoked directly.
Codex CLI inside the agent container, authenticated via a valid subscription auth.json mounted under CODEX_HOME
No real OPENAI_API_KEY available by design (subscription auth only)
Repro (environment isolation)
With CODEX_HOME pointing at the mounted config:
Without CODEX_API_KEY (only a placeholder OPENAI_API_KEY set): the Codex CLI uses the auth.json subscription token and succeeds — real completion returned.
With CODEX_API_KEY set (with or without OPENAI_API_KEY): the CLI ignores auth.json entirely, attempts true API-key auth against api.openai.com, receives 401 Unauthorized: Incorrect API key provided, retries 5x, then fails the turn.
Since Trinity's dispatch path always injects CODEX_API_KEY, case 2 is the only reachable behavior through /task — the agent 503s on every dispatch. The only successful Codex completion we obtained was via a manual docker exec invocation that deliberately omitted CODEX_API_KEY, bypassing Trinity's dispatch entirely.
Suggested fix
Only set CODEX_API_KEY when a real API key is actually configured (or drop the defensive duplicate entirely). A one-line conditional around the injection restores subscription-auth operation without affecting API-key users.
Secondary observation (non-fatal)
Trinity's relocation of CODEX_HOME under $TMPDIR trips a Codex CLI safety heuristic: WARNING: ... Refusing to create helper binaries under temporary dir. Execution continues, so this is cosmetic — noted only because it surfaces in the same code path.
Happy to provide further detail from our evaluation notes if useful.
Took the CODEX_API_KEY fix as filed, and also fixed a second defect your repro exposes but that isn't in the issue: your working case is "only a placeholderOPENAI_API_KEY set" — that placeholder is load-bearing, because _execute_codex raised 503 before invoking the CLI whenever no API key was found, and a ChatGPT-plan container has no API key by design. So fixing only the reported half would have left subscription agents working provided they knew to set a fake key, which isn't the goal you described. The gate now accepts a subscription auth.json under CODEX_HOME, and the 503 text names both remedies instead of only "inject OPENAI_API_KEY" — that wording is what pointed you at the placeholder in the first place.
Detection is deliberately existence + non-empty only: validating the token is the CLI's job, and a stale auth.json should surface as the CLI's own auth error rather than a Trinity 503 falsely claiming no credentials are configured.
The secondary observation (Refusing to create helper binaries under temporary dir) is not fixed here — you're right that it's cosmetic, and moving CODEX_HOME off $TMPDIR would unpick the #1098 arrangement that keeps Codex state out of the git-tracked workspace. Worth its own issue; happy to file one if you'd like it tracked.
Your evaluation notes on the environment isolation were the decisive detail — the presence-vs-value distinction is not something the code comment suggested, and it's what made this diagnosable. Thank you.
Activity
dolho commentedon Aug 4, 2026
/claim — picking this up. Branch:
fix/1971-codex-api-key, offdev.github-actions commentedon Aug 4, 2026
@dolho This issue is already assigned to dolho. Use
/unclaimfirst if you want to take over.dolho commentedon Aug 4, 2026
PR: #1980
Took the
CODEX_API_KEYfix as filed, and also fixed a second defect your repro exposes but that isn't in the issue: your working case is "only a placeholderOPENAI_API_KEYset" — that placeholder is load-bearing, because_execute_codexraised 503 before invoking the CLI whenever no API key was found, and a ChatGPT-plan container has no API key by design. So fixing only the reported half would have left subscription agents working provided they knew to set a fake key, which isn't the goal you described. The gate now accepts a subscriptionauth.jsonunderCODEX_HOME, and the 503 text names both remedies instead of only "inject OPENAI_API_KEY" — that wording is what pointed you at the placeholder in the first place.Detection is deliberately existence + non-empty only: validating the token is the CLI's job, and a stale
auth.jsonshould surface as the CLI's own auth error rather than a Trinity 503 falsely claiming no credentials are configured.The secondary observation (
Refusing to create helper binaries under temporary dir) is not fixed here — you're right that it's cosmetic, and movingCODEX_HOMEoff$TMPDIRwould unpick the #1098 arrangement that keeps Codex state out of the git-tracked workspace. Worth its own issue; happy to file one if you'd like it tracked.Your evaluation notes on the environment isolation were the decisive detail — the presence-vs-value distinction is not something the code comment suggested, and it's what made this diagnosable. Thank you.
fix(codex): a non-UTF-8 .env no longer crashes dispatch (#1971, /edge…
fix(codex): stop synthesizing CODEX_API_KEY, and accept subscription …
Merge origin/dev into fix/1969-lock-denied-tick-audit (resolve tests/…
fix(codex): materialise API-key auth.json, or every turn 401s (#2208) (…