Skip to content

fix(codex): explain unavailable selected auth profiles - #133355

Merged
vincentkoc merged 1 commit into
mainfrom
fix/codex-missing-auth-profile-copy
Aug 30, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/codex-missing-auth-profile-copy

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #113169

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where agents using the Codex app-server bridge could receive generic expired-login guidance when their selected OpenAI auth profile was missing from that agent's OpenClaw credential store.

The original refresh-miss premise in #113169 was retracted after log review. The remaining reproducible defect is the missing selected-profile path identified in the follow-up and ClawSweeper review: the bridge fails before an operational app-server RPC, but the selected-profile condition was collapsed into generic authentication recovery.

Why This Change Was Made

The Codex bridge now emits the generic allowlisted code selected_auth_profile_unavailable from its existing typed status-401 missing/wrong-profile error. The failover controller preserves that code while retaining reason: "auth", so profile rotation, failure bookkeeping, and model fallback behavior stay unchanged.

A shared static renderer maps only that exact code to bounded credential-import recovery. Final replies, lifecycle producers, terminal projection, persisted lastRunError, Control UI, and Gateway chat surfaces use that renderer without exposing the profile ID, raw cause, provider text, or arbitrary plugin copy.

Rejected alternatives:

  • Rendering the bridge cause directly would leak profile-specific diagnostics and arbitrary provider/plugin text into user and protocol surfaces.
  • Adding a lifecycle or Gateway errorCode field would widen the public protocol for a presentation repair.
  • Changing the failover reason would alter established auth rotation and fallback semantics.
  • Adding Codex-specific IDs or policy to generic core would violate the plugin owner boundary.
  • Recommending /login codex would be wrong for an absent agent-scoped credential; existing invalid_grant and expired-login behavior remains unchanged.

User Impact

Operators now receive this bounded recovery guidance:

The selected auth profile is unavailable in this agent's OpenClaw credential store. Import or migrate that credential into the agent, select another configured profile, or run openclaw configure, then retry.

The failure remains status 401 and participates in the existing auth rotation/bookkeeping path. Detailed profile diagnostics remain available only in the active structured error/cause.

Reported and clarified by @Jeehut. No co-author attribution is added because the reporter did not author the code.

Evidence

Before the lifecycle-owner repair, the focused Control UI and Gateway proof exposed the selected profile and raw cause instead of bounded recovery text. After the repair, the final chat reply, public lifecycle event, persisted lastRunError, agent.wait, and both Gateway chat projections contain only the static recovery text and exclude the profile ID, raw cause, and login button.

The fake Codex app-server correctly receives initialize, which is process setup. It receives no account/login/start, thread/start, thread/resume, or turn/start; the selected-profile failure occurs before operational app-server RPC. A live OpenAI call would not exercise this boundary, so the fake app-server Gateway flow is the correct end-to-end proof.

Validation on exact head dc3117ff7f907dad877156a9e269254ec85b8445, tree b8a4301d2ef7e581e74312c0e739d40696530d2d:

  • Focused bridge/failover/lifecycle/final-reply corpus: 426 passed on the behavior candidate; 32 affected focused tests passed again after the final private-export cleanup.
  • Gateway chat suites: 229 passed on the behavior candidate; the final cleanup changes only static-copy export visibility and test expectations.
  • QA Lab fake-app-server Gateway proof: 2 passed.
  • pnpm lint: passed.
  • pnpm format:check: passed.
  • Core, core-test, extension, and extension-test TypeScript graphs: passed.
  • check:changed applicable gates passed; the root-test graph is unavailable in this sparse worktree because tracked Android, QA broker, and ui/config inputs are absent.
  • Mandatory autoreview: no accepted/actionable findings on the full behavior candidate or final cleanup; final-delta correctness 0.99.
  • Existing invalid_grant copy remains covered and unchanged.

LOC: production +51/-34 (net +17); tests +524/-9 (net +515). No protocol, config, persistence, public API, or dependency change.

Codex app-server account/login behavior was checked directly against openai/codex at 5f49aba876922d6f2f55caa153bbb0ed1b46feba:

  • codex-rs/app-server-protocol/src/protocol/v2/account.rs:60-85
  • codex-rs/app-server-protocol/src/protocol/common.rs:1196-1201
  • codex-rs/app-server/src/request_processors/account_processor.rs:327-338
  • codex-rs/app-server/src/request_processors/account_processor.rs:369-378

No documentation or changelog change: the existing OpenAI provider documentation already covers credential import/migration, and this PR corrects runtime guidance to match it.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: codex size: L maintainer Maintainer-authored PR labels Aug 30, 2026
@vincentkoc vincentkoc self-assigned this Aug 30, 2026
@vincentkoc
vincentkoc requested a review from a team August 30, 2026 15:55
@vincentkoc
vincentkoc marked this pull request as ready for review August 30, 2026 15:56
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 12:27 PM ET / 16:27 UTC.

ClawSweeper review

What this changes

The PR preserves a selected-auth-profile-unavailable code through Codex auth, failover, replies, and lifecycle output so operators receive bounded credential recovery guidance rather than raw profile diagnostics.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open for maintainer review. Current main still collapses the selected-profile condition into generic subscription-auth recovery; the proposed typed code and bounded renderer address that path, but direct Codex contract inspection is unavailable and the linked issue’s closing scope needs confirmation.

Priority: P2
Reviewed head: dc3117ff7f907dad877156a9e269254ec85b8445
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, well-covered repair, with upstream-contract verification and linked-issue scope remaining for maintainer review.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate. Its added QA scenario uses the production Gateway client, injected profile removal, and observable reply/lifecycle/history outputs, but this review does not claim proof sufficiency because direct sibling Codex-source inspection is unavailable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate. Its added QA scenario uses the production Gateway client, injected profile removal, and observable reply/lifecycle/history outputs, but this review does not claim proof sufficiency because direct sibling Codex-source inspection is unavailable.
Evidence reviewed 6 items Current-main behavior remains affected: Current main wraps the unavailable-profile error into generic subscription-auth copy before it reaches later error handling, so the PR remains necessary.
Introduced owner-boundary repair: The PR removes that wrapper, assigns the unavailable-profile code at the credential producer, and allows the typed error to reach the existing failover path.
Projection coverage: The added Gateway QA scenario removes an agent-scoped profile and asserts bounded copy across chat, lifecycle, agent.wait, session state, and history while observing no login or turn RPC.
Findings None None.
Security None None.

How this fits together

The Codex app-server bridge resolves an agent’s selected credential before a model turn. Errors then pass through failover and reply/lifecycle projections to Gateway and Control UI users.

flowchart LR
  A[Selected auth profile] --> B[Codex app-server bridge]
  B --> C[Typed unavailable-profile error]
  C --> D[Agent failover]
  D --> E[Reply and lifecycle projections]
  E --> F[Gateway and Control UI]
  E --> G[Bounded recovery guidance]
Loading

Decision needed

Question Recommendation
Can a maintainer directly verify the Codex app-server account/login boundary and confirm that #113169 now represents this selected-profile failure before this PR closes it? Verify and retain the PR: Directly inspect the upstream Codex contract and confirm the linked issue’s active scope, then retain the typed-code repair and closing reference.

Why: The PR’s behavior proof and its closing reference both rely on facts not independently verifiable in this read-only environment.

Before merge

  • Resolve merge risk (P1) - The required direct inspection of the Codex app-server contract cannot be completed because sibling ../codex is absent and network source retrieval failed; this is a reviewer limitation, not missing contributor proof.
  • Resolve merge risk (P1) - The PR formally closes [Bug]: Silent OpenAI/Codex OAuth refresh miss is misreported as "No API key found / couldn't sign in" #113169, while its description says that issue’s original refresh-miss premise was retracted; merging could close a still-distinct report unless maintainers confirm its active scope.
  • Resolve merge risk (P1) - Production code is net +17 lines for one exact-code renderer and three output projections; it appears justified by keeping raw credential diagnostics out of public surfaces, but needs maintainer acceptance of that cross-cutting boundary.
  • Complete next step (P2) - A maintainer must verify the upstream Codex protocol boundary and confirm whether the formal closing link matches the linked issue’s active scope.
Agent review details

Security

None.

PR surface

Source +17, Tests +515. Total +532 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 8 51 34 +17
Tests 9 524 9 +515
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 575 43 +532

Review metrics

Metric Value Why it matters
Production versus test delta production +17 net; tests +515 net The production growth is a shared exact-code renderer and output propagation; extensive test growth covers the affected bridge, failover, lifecycle, and Gateway path.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/failover/user-copy.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify contract and issue scope (recommended)
    Before merge, directly inspect the upstream Codex account/login contract and confirm or correct the formal closing reference.
  2. Accept the current issue linkage
    Retain the closing reference only if a maintainer confirms the linked issue was narrowed to the selected-profile behavior.
  3. Pause pending evidence
    Hold the PR if neither the upstream boundary nor the issue scope can be confirmed.

Technical review

Best possible solution:

Keep the single exact-code renderer and producer-side typed error, after a maintainer verifies the upstream Codex boundary and either confirms the linked issue now tracks this failure or removes the closing reference.

Do we have a high-confidence way to reproduce the issue?

Yes—source-reproducible: configure a selected agent profile, establish the Codex session, then remove that profile before the next turn as the added Gateway scenario does. Current main’s bridge wrapper shows why the typed condition becomes generic recovery.

Is this the best way to solve the issue?

Unclear: the producer-to-projection repair is a coherent narrow path, but direct verification of the claimed Codex app-server boundary and the linked issue’s scope is still required.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a8c3e4c4ffd7.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs misleading recovery guidance for a bounded but user-visible credential-profile failure.
  • merge-risk: 🚨 auth-provider: The change alters how selected credential failures retain identity through auth failover and user-facing recovery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate. Its added QA scenario uses the production Gateway client, injected profile removal, and observable reply/lifecycle/history outputs, but this review does not claim proof sufficiency because direct sibling Codex-source inspection is unavailable.

Evidence

What I checked:

Likely related people:

  • xingzhou: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Directly inspect the Codex account/login contract cited by the PR and confirm or correct the closing reference.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-30T16:03:20.160Z sha 6aa6b4714e9107a651c9c4eec24068d8577bd9d2 :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

ClawSweeper rank-up and merge-risk dispositions for exact head 6aa6b4714e9107a651c9c4eec24068d8577bd9d2:

  1. Upstream Codex contract check: applied. The acting maintainer directly inspected sibling openai/codex at 5f49aba876922d6f2f55caa153bbb0ed1b46feba:
    • codex-rs/app-server-protocol/src/protocol/v2/account.rs:60-85
    • codex-rs/app-server-protocol/src/protocol/common.rs:1196-1201
    • codex-rs/app-server/src/request_processors/account_processor.rs:327-338
    • codex-rs/app-server/src/request_processors/account_processor.rs:369-378
      This confirms account/login/start is the login RPC boundary. The OpenClaw bridge rejects the unavailable selected credential before issuing that RPC.
  2. Exact-head Gateway proof: applied. pnpm test test/e2e/qa-lab/runtime/codex-auth-product-proof.e2e.test.ts passed 2/2 on this head. The fake app-server observed expected initialize process setup and no account/login/start, thread/start, thread/resume, or turn/start. Final chat, lifecycle, persisted lastRunError, agent.wait, and both Gateway history projections contained only the bounded recovery copy.
  3. Production delta: accepted. Production is +51/-34, net +17. The growth is the generic exact-code renderer plus lifecycle-owner propagation needed to prevent raw credential diagnostics from escaping; duplicate Codex-specific copy and wrapper behavior were removed.
  4. Stored-data heuristic: not applicable. src/agents/failover/user-copy.ts contains static presentation constants and an exact allowlist renderer. This PR has no persistence, migration, backfill, schema, config, protocol, or public API change.

Ownership is also satisfied by listed-owner authorship: live team membership shows PR and signed-commit author vincentkoc is an active maintainer of openclaw/openclaw-secops. The open team review request is retained as an additional signal.

@vincentkoc
vincentkoc force-pushed the fix/codex-missing-auth-profile-copy branch from 6aa6b47 to dc3117f Compare August 30, 2026 16:20
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

ClawSweeper exact-head disposition for dc3117ff7f907dad877156a9e269254ec85b8445:

  • Direct Codex contract inspection completed at openai/codex@5f49aba876922d6f2f55caa153bbb0ed1b46feba: codex-rs/cli/src/main.rs:220-245, codex-rs/cli/src/main.rs:2840-2870, codex-rs/app-server-protocol/src/protocol/v2/account.rs:60-85, codex-rs/app-server-protocol/src/protocol/common.rs:1196-1201, and codex-rs/app-server/src/request_processors/account_processor.rs:327-338,369-378. The account/login RPC is explicit, and configured external authentication remains host-owned; this failure occurs during selected-profile resolution before login, thread, or turn RPCs.
  • Issue scope confirmed. In [Bug]: Silent OpenAI/Codex OAuth refresh miss is misreported as "No API key found / couldn't sign in" #113169, the reporter retracted the refresh premise, explicitly asked to keep the issue open for the missing selected-profile failure, and the issue's ClawSweeper review independently identified that exact remaining defect plus the required end-to-end reply coverage.
  • Production growth is accepted: +17 net lines provide one exact-code, static allowlisted renderer and carry its bounded recovery text through the existing public projections. This prevents raw profile IDs and credential diagnostics from leaking through chat, lifecycle events, history, agent.wait, or Control UI/Gateway output. The QA scenario covers those projections.
  • The stored-data-model warning is not applicable: this changes no schema, migration, persistence representation, retention, or store behavior.
  • Rank-up move completed by the direct Codex inspection and issue-scope confirmation above. No ClawSweeper findings remain.

@vincentkoc
vincentkoc merged commit ef5e853 into main Aug 30, 2026
427 of 429 checks passed
@vincentkoc
vincentkoc deleted the fix/codex-missing-auth-profile-copy branch August 30, 2026 16:42
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Silent OpenAI/Codex OAuth refresh miss is misreported as "No API key found / couldn't sign in"

1 participant