Skip to content

fix(auth): make Codex logout recovery actionable - #130866

Merged
obviyus merged 2 commits into
mainfrom
codex/auth-recovery-actions
Aug 27, 2026
Merged

obviyus merged 2 commits into
mainfrom
codex/auth-recovery-actions

Conversation

@obviyus

@obviyus obviyus commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Hard OpenAI OAuth failures had split recovery ownership. Automation alerts carried a Log in to Codex action, while normal turns, returned provider errors, Control UI turns, and later retries showed text-only failures. Later retries also lost the credential mode after an OAuth profile entered permanent auth cooldown.

Root cause

  • Cron built its own recovery button instead of using a shared auth-recovery payload.
  • Normal failure formatters returned text only.
  • Returned assistant errors rewrote OAuth failures before presentation was attached.
  • Failover summaries dropped authMode, so later disabled-profile errors could not safely distinguish OAuth from API-key auth.
  • Wrapped provider failures kept the exact refresh error in rawError, but the OAuth classifier only followed cause.

Fix

  • Add one canonical Codex login recovery descriptor with actionable fallback text and a typed /login codex button.
  • Apply it to thrown failures, returned provider errors, Control UI text, later OAuth-profile failures, and automation alerts.
  • Preserve OAuth mode through auth-profile and model-fallback summaries.
  • Classify exact OAuth failures from structured causes, raw messages, and bounded rawError metadata.
  • Keep API-key failures and transient refresh failures free of the Codex login action.
  • Extend the E2E mock provider so a real channel run can reproduce exact provider failure text.

Security

  • The button is an explicit command action; it does not start OAuth by itself.
  • Existing owner/admin authorization remains the only login authority.
  • Telegram groups still reject device-code delivery and tell the owner to use a DM.
  • No token, account, bot, host, or device-code material is included in this PR.

Proof

  • Regression red before the fix:
    • returned provider error: expected /login codex action, received generic refresh text;
    • normal, raw-wrapper, and Control UI cases: expected a presentation action, received none.
  • Focused Vitest: 304 tests passed across auth classification, normal failures, returned errors, cron alerts, auth lifecycle, model fallback, and E2E mock controls.
  • Static gates: format, Oxlint, import cycles, assertion safety, max-lines, auth pairing boundaries, deprecated APIs, coercion helpers, conflict markers, and test temp paths passed.
  • Exact-head ClawSweeper at c737d903364: patch correct, zero findings, security cleared, no maintainer decision, and no rank-up moves.
  • Typecheck/build: not run locally by repository host policy; hosted CI owns these gates.

Telegram Test Server E2E

  • Current main, owner DM: one provider request produced text-only auth failure and no callback button.
  • Exact head c737d903364, owner DM: the failed turn showed Log in to Codex; the real callback click completed; a private OpenAI device-code prompt arrived.
  • Exact head c737d903364, group: the failed turn showed the same button; clicking it returned DM-only guidance; zero device-code messages appeared in the group.
  • The runner released its lease and the post-run doctor returned ok: true.

Codex contract

  • ../codex/codex-rs/login/src/auth/manager.rs:1614-1665 treats invalidated refresh tokens as permanent and revoked.
  • ../codex/codex-rs/login/src/device_code_auth.rs:149-178,181-232 owns the explicit 15-minute device prompt, token exchange, validation, and persistence.

Change size

  • Production: +103 net lines. The growth carries one new cross-surface recovery capability and preserves the OAuth ownership fact across failure aggregation.
  • Tests: +247 net lines.
  • Tooling: +4 net lines.
  • No config, schema, persistence, or public Plugin SDK surface changed.

@obviyus
obviyus requested a review from a team as a code owner August 27, 2026 09:47
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@obviyus
obviyus force-pushed the codex/auth-recovery-actions branch from 9a28a91 to c737d90 Compare August 27, 2026 09:53
@obviyus
obviyus merged commit 4f9466a into main Aug 27, 2026
202 checks passed
@obviyus
obviyus deleted the codex/auth-recovery-actions branch August 27, 2026 10:13
@obviyus

obviyus commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author
Item Details
Bug A revoked OpenAI login showed text-only recovery on normal turns, returned provider errors, Control UI, and later retries; only automation alerts had a login action.
Fix One OAuth-owned recovery descriptor now adds /login codex guidance everywhere and a Log in to Codex action where the channel supports it. OAuth mode survives fallback summaries, while API-key and transient failures remain unchanged.
Example Before: a user saw “Model login expired” and had to copy a command. After: the same failure offers Log in to Codex; text-only surfaces show the exact private-chat/Web UI command.
Proof Telegram Test Server on exact head c737d903364: owner DM click produced a private device-code prompt; group click produced DM-only guidance with zero public codes. Local ClawSweeper passed with zero findings and cleared security; exact-head openclaw/ci-gate passed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
Hard OpenAI OAuth failures now offer one shared login action across normal replies, returned provider errors, fallback summaries, Control UI guidance, and automation alerts. OAuth mode survives failure aggregation so API-key failures never receive the Codex pairing action.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant