Repository navigation
fix(codex): user-home Codex app-servers fail every turn when an OpenAI auth profile exists - #114397
Conversation
A prepared OpenClaw auth handoff was still resolved for connections that target the operator's native Codex home, so every turn failed with "Prepared Codex auth requires an isolated app-server home." once a stored OpenAI profile produced a prepared model route. User-home mode now keeps its native account for both subscription and Platform routes, matching the documented contract; the shared-client guard stays as the backstop.
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 3:11 AM ET / 07:11 UTC. ClawSweeper reviewWhat this changesKeeps Codex app-servers configured to use the operator’s user home on native Codex authentication instead of preparing and injecting an OpenClaw OpenAI profile. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 6 items remain Keep this PR open for human review: the patch is narrowly scoped and preserves the native-home safety backstop, but the supplied evidence is harness/test proof rather than an after-fix run against a real user-home Codex app-server. The protected Priority: P1 Review scores
Verification
How this fits togetherThe bundled Codex plugin converts an agent’s resolved OpenAI/Codex auth route into app-server startup options. In user-home mode, that process shares the operator’s Codex CLI/Desktop home, so the connection must retain its native account rather than receive prepared credentials. flowchart LR
A[Agent model route] --> B[Codex auth bridge]
C[OpenClaw auth profiles] --> B
D[App-server home scope] --> B
B --> E{User home?}
E -->|Yes| F[Native Codex account]
E -->|No| G[Prepared auth handoff]
F --> H[Codex app-server turn]
G --> H
Decision needed
Why: The patch deliberately changes credential-routing behavior for a home shared with Codex CLI/Desktop; unit and harness tests establish intended control flow but cannot demonstrate the real app-server/account interaction required by the repository proof policy. Before merge
Agent review detailsSecurityNone. PR surfaceSource +21, Tests +83, Docs +3. Total +107 across 9 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one authoritative home-scope decision in the auth bridge, preserve the shared-client safety invariant, and attach redacted real user-home app-server evidence for both the successful native-account path and the actionable missing-native-login failure path before merging. Do we have a high-confidence way to reproduce the issue? No high-confidence independently reproduced run is available in this review. The PR supplies a precise configuration and regression harness path, so the failure is source-reproducible, but no live user-home app-server result was inspected. Is this the best way to solve the issue? Unclear. Routing the decision through the auth bridge and retaining the shared-client rejection is a coherent narrow design, but the required direct runtime/Codex-contract confirmation and real after-fix behavior proof are still needed before treating it as the best verified fix. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1fe66e0fe840. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…#114397) A prepared OpenClaw auth handoff was still resolved for connections that target the operator's native Codex home, so every turn failed with "Prepared Codex auth requires an isolated app-server home." once a stored OpenAI profile produced a prepared model route. User-home mode now keeps its native account for both subscription and Platform routes, matching the documented contract; the shared-client guard stays as the backstop.
…dex home (#114719) A user-home app-server keeps its native Codex account, and OpenClaw verified only half of that contract. A subscription route was checked against the native account, but a Platform (API-key) route was not: an operator signed in to Codex with a ChatGPT subscription who selected an API-billed model silently spent their plan. Both directions of the same billing boundary now share one account/read check. An absent account is left alone, since a native home may serve a custom model provider that reports no OpenAI account at all. The home-scope rule behind #114397 was also expressed four times: two prepared-auth call sites spread it in conditionally from raw plugin config, two others read resolved start options, and the supervision connection applied its own default inline. resolveCodexAppServerHomeScope now owns it, and homeScope is a required argument of resolveCodexAppServerPreparedAuthHandoff, so a new call site that forgets it fails to compile instead of failing every turn. Docs dropped the stale user-home paragraph that still described the startup failure #114397 removed and told operators to delete a working OpenAI profile.
…dex home (openclaw#114719) A user-home app-server keeps its native Codex account, and OpenClaw verified only half of that contract. A subscription route was checked against the native account, but a Platform (API-key) route was not: an operator signed in to Codex with a ChatGPT subscription who selected an API-billed model silently spent their plan. Both directions of the same billing boundary now share one account/read check. An absent account is left alone, since a native home may serve a custom model provider that reports no OpenAI account at all. The home-scope rule behind openclaw#114397 was also expressed four times: two prepared-auth call sites spread it in conditionally from raw plugin config, two others read resolved start options, and the supervision connection applied its own default inline. resolveCodexAppServerHomeScope now owns it, and homeScope is a required argument of resolveCodexAppServerPreparedAuthHandoff, so a new call site that forgets it fails to compile instead of failing every turn. Docs dropped the stale user-home paragraph that still described the startup failure openclaw#114397 removed and told operators to delete a working OpenAI profile.
What Problem This Solves
Fixes an issue where operators running the Codex plugin with
appServer.homeScope: "user"(the documented "share threads with Codex Desktop and CLI" mode) would see every agent turn fail with:The trigger is having a normal stored OpenAI auth profile (created by
openclaw models auth login) while the agent's model resolves an OpenAI route. Core runtime planning then hands the Codex plugin a prepared subscription (or Platform) auth route, the plugin resolved that route into a prepared auth handoff, and app-server startup rejected it because the connection targets the native Codex home. The gateway is unusable: no turn can start.On the affected production gateway this reproduces with
homeScope: "user"plussupervision.enabled: true; turning supervision off restores turns, which flips which plugin-config/connection path is live but is not a supported workaround for operators who want supervision.The behavior also contradicted our own documentation.
docs/plugins/codex-harness.mdstates that user-home mode uses that home's "native Codex auth, config, plugins, and thread store" and that "OpenClaw does not inject an OpenClaw auth profile into this app-server." The runtime instead hard-failed whenever such a profile merely existed and produced a prepared route.Why This Change Was Made
The guard itself is correct and stays: a user-home app-server owns the operator's real account, and Codex persists api-key logins into
CODEX_HOME/auth.json(codex-rs/login/src/auth/manager.rslogin_with_api_key->save_auth) whilechatgptAuthTokenslogins replace the live account viaset_external_auth(codex-rs/app-server/src/request_processors/account_processor.rs). Injecting OpenClaw auth there would rewrite the credentials Codex CLI and Desktop share.The defect was one layer up:
resolveCodexAppServerPreparedAuthHandoffinextensions/codex/src/app-server/auth-bridge.tsnever knew about home scope, so it produced prepared auth for a connection that can never accept it. The supervision connection already had this knowledge; the ordinary user-home connection did not. The fix teaches that single owner about home scope, so user-home connections return the native handoff (no prepared auth) for both subscription and Platform routes, exactly as the docs describe. Downstream behavior already works:shared-client.tsnormalizes user-home clients toauthProfileId: null, andapplyCodexAppServerAuthProfilethen verifies a subscription route against the native account withaccount/readinstead of logging in. The same one-sided gap existed in native compaction (compact.ts), fixed alongside it. The shared-client throw is kept as a backstop invariant with a comment explaining what it protects.Alternatives rejected: silently dropping prepared auth inside
shared-clientwould have left the rest of the plugin (cache keys, reviewer policy, provider selection) believing an OpenClaw profile was in play, and would have removed the invariant that protects~/.codex. Throwing only for explicitly selected profiles was also rejected, since no prepared profile, explicit or default, may be logged into the operator's native home.User Impact
Operators can run
appServer.homeScope: "user"with supervision enabled and a stored OpenAI auth profile: turns now run on the native Codex account instead of failing. If that native home is not logged in, a subscription route still fails with the actionable "Codex subscription auth profile could not produce login credentials." message rather than the misleading isolated-home error. Docs now state that a stored profile is deliberately not injected and that subscription routes are verified against the native account.Evidence
Focused tests (
node scripts/run-vitest.mjs, local, trusted source):extensions/codex/src/app-server/auth-profile-runtime-contract.test.ts— 11 passed, including the new table-driven regressionkeeps a user-home app-server on native Codex auth for a subscription route / a Platform route(stored OAuth profile + prepared route +appServer.homeScope: "user"+supervision.enabled: true, the exact production combination).extensions/codex/src/app-server/auth-bridge.test.ts— 80 passed, includingdeclines every prepared handoff for a user-home app-server.side-question.test.ts,compact.test.ts,shared-client.test.ts,binding-connection.test.ts— 168 passed;run-attempt.test.ts— 117 passed.Negative control: with the home-scope check neutered, both new contract tests fail (
Tests 2 failed | 9 passed), the api-key case failing insideresolveCodexAppServerPreparedAuthHandoff, so the regression tests do catch this bug.node scripts/check-changed.mjsdelegated to Blacksmith Testbox (lanes: extensions, extensionTests, docs), includingoxfmt --checkclean on all 9 changed files.Codex protocol behavior was verified directly against the sibling
../codexcheckout (files cited above), not from memory or wrappers.