Skip to content

fix(codex): user-home Codex app-servers fail every turn when an OpenAI auth profile exists - #114397

Merged
steipete merged 1 commit into
mainfrom
fix/codex-user-home-prepared-auth
Jul 27, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/codex-user-home-prepared-auth

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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:

Prepared Codex auth requires an isolated app-server home.

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" plus supervision.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.md states 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.rs login_with_api_key -> save_auth) while chatgptAuthTokens logins replace the live account via set_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: resolveCodexAppServerPreparedAuthHandoff in extensions/codex/src/app-server/auth-bridge.ts never 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.ts normalizes user-home clients to authProfileId: null, and applyCodexAppServerAuthProfile then verifies a subscription route against the native account with account/read instead 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-client would 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 regression keeps 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, including declines every prepared handoff for a user-home app-server.
  • Siblings: 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 inside resolveCodexAppServerPreparedAuthHandoff, so the regression tests do catch this bug.

node scripts/check-changed.mjs delegated to Blacksmith Testbox (lanes: extensions, extensionTests, docs), including oxfmt --check clean on all 9 changed files.

Codex protocol behavior was verified directly against the sibling ../codex checkout (files cited above), not from memory or wrappers.

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.
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: S labels Jul 27, 2026
@steipete
steipete marked this pull request as ready for review July 27, 2026 07:06
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Jul 27, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 3:11 AM ET / 07:11 UTC.

ClawSweeper review

What this changes

Keeps 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 maintainer label also requires explicit human handling.

Priority: P1
Reviewed head: abecdb09f584f8fd3d3c38aee1d98b7c4b06e20a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The proposed code path is focused and guarded, but the missing real user-home runtime proof remains a merge gate for this external PR.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body reports focused tests and a negative control, but no inspected after-fix run from a real user-home Codex app-server; attach redacted terminal/live output and remove private account, endpoint, IP, or token details. Updating the PR body should trigger a fresh ClawSweeper review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused tests and a negative control, but no inspected after-fix run from a real user-home Codex app-server; attach redacted terminal/live output and remove private account, endpoint, IP, or token details. Updating the PR body should trigger a fresh ClawSweeper review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Prepared-auth ownership change: The branch adds a home-scope decision to the prepared-auth resolver: a user-home connection returns native-auth metadata and skips both prepared API-key materialization and prepared subscription handoff.
Runtime paths are covered by branch tests: The proposed regression tests exercise subscription and Platform routes with a stored OpenAI profile, appServer.homeScope: "user", and supervision enabled; the PR body reports focused test and changed-check success.
Native-home guard remains in place: The branch leaves the shared-client rejection for any prepared auth reaching a user-home app-server and documents it as a backstop, reducing the risk of overwriting credentials shared with Codex CLI/Desktop.
Findings None None.
Security None None.

How this fits together

The 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
Loading

Decision needed

Question Recommendation
Should this auth-routing change merge after a redacted real user-home Codex app-server run proves that stored OpenAI profiles are not injected and turns complete on the native Codex account? Require real user-home proof: Request a redacted after-fix run with homeScope: "user", a stored OpenAI profile, and supervision enabled, showing a completed turn without prepared-auth injection.

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

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused tests and a negative control, but no inspected after-fix run from a real user-home Codex app-server; attach redacted terminal/live output and remove private account, endpoint, IP, or token details. Updating the PR body should trigger a fresh ClawSweeper review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - This changes authentication routing for an operator-owned CODEX_HOME; a regression could either reintroduce turn failures or accidentally route a user-home run through the wrong account path.
  • Resolve merge risk (P1) - The supplied evidence reports test-harness coverage, but does not show an after-fix real app-server run using a user home, stored OpenAI profile, and supervision enabled.
  • Resolve merge risk (P1) - The PR is behind current main, so the final merge result needs a refresh after required proof is attached.
  • Complete next step (P2) - The protected maintainer label and missing real behavior proof require human-owned review; this is not a safe automated repair task.
Agent review details

Security

None.

PR surface

Source +21, Tests +83, Docs +3. Total +107 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 24 3 +21
Tests 2 83 0 +83
Docs 1 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 111 4 +107

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Add real user-home proof before merge (recommended)
    Run the documented user-home configuration with a stored OpenAI profile and supervision enabled, then attach redacted terminal or runtime logs showing a completed turn and native-account verification.
  2. Pause until native-auth behavior is independently confirmed
    Do not merge until a Codex-area owner confirms that the current app-server contract leaves the CLI/Desktop account unchanged for both subscription and Platform routes.

Technical review

Best 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.

Labels

Label changes:

  • add P1: The reported configuration makes every affected agent turn fail, leaving an enabled Codex gateway workflow unusable for operators using user-home mode.
  • add merge-risk: 🚨 auth-provider: The patch changes whether resolved OpenAI credentials are handed to the Codex app-server or replaced by native-home authentication.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests and a negative control, but no inspected after-fix run from a real user-home Codex app-server; attach redacted terminal/live output and remove private account, endpoint, IP, or token details. Updating the PR body should trigger a fresh ClawSweeper review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The reported configuration makes every affected agent turn fail, leaving an enabled Codex gateway workflow unusable for operators using user-home mode.
  • merge-risk: 🚨 auth-provider: The patch changes whether resolved OpenAI credentials are handed to the Codex app-server or replaced by native-home authentication.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests and a negative control, but no inspected after-fix run from a real user-home Codex app-server; attach redacted terminal/live output and remove private account, endpoint, IP, or token details. Updating the PR body should trigger a fresh ClawSweeper review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Prepared-auth ownership change: The branch adds a home-scope decision to the prepared-auth resolver: a user-home connection returns native-auth metadata and skips both prepared API-key materialization and prepared subscription handoff. (extensions/codex/src/app-server/auth-bridge.ts:260, abecdb09f584)
  • Runtime paths are covered by branch tests: The proposed regression tests exercise subscription and Platform routes with a stored OpenAI profile, appServer.homeScope: "user", and supervision enabled; the PR body reports focused test and changed-check success. (extensions/codex/src/app-server/auth-profile-runtime-contract.test.ts:489, abecdb09f584)
  • Native-home guard remains in place: The branch leaves the shared-client rejection for any prepared auth reaching a user-home app-server and documents it as a backstop, reducing the risk of overwriting credentials shared with Codex CLI/Desktop. (extensions/codex/src/app-server/shared-client.ts:298, abecdb09f584)
  • PR state and human-review gate: The supplied GitHub context marks this PR maintainer; repository policy keeps protected-label items open for explicit maintainer handling. The PR is cleanly mergeable but currently behind main. (abecdb09f584)

Likely related people:

  • steipete: The available provenance identifies this person as the author of the focused branch commit that changes the auth bridge, runtime connection setup, compaction path, and their associated contract tests; current-main feature-history provenance could not be independently completed in this read-only review. (role: recent contributor to the Codex app-server auth path; confidence: low; commits: abecdb09f584; files: extensions/codex/src/app-server/auth-bridge.ts, extensions/codex/src/app-server/run-attempt-connection.ts, extensions/codex/src/app-server/compact.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted after-fix terminal or runtime evidence for the documented user-home plus supervision configuration.
  • Show the missing-native-login failure remains actionable when the native Codex home has no subscription credentials.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 65cce37 into main Jul 27, 2026
219 of 231 checks passed
@steipete
steipete deleted the fix/codex-user-home-prepared-auth branch July 27, 2026 07:19
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 27, 2026
…#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.
steipete added a commit that referenced this pull request Jul 28, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 28, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant