-
-
Notifications
You must be signed in to change notification settings - Fork 79.2k
OpenAI Codex OAuth can bind to a deactivated ChatGPT workspace when accounts have multiple workspaces #56693
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
OpenClaw's OpenAI Codex OAuth flow appears to rely on upstream
@mariozechner/pi-ai/oauthworkspace/account selection without validating that the selected ChatGPT workspace is still active.If a ChatGPT account has multiple workspaces and one of them is
deactivated, OAuth login may intermittently succeed but later fail with aworkspace deactivatederror, depending on which workspace/account context gets selected.Environment
2026.3.28-beta.1mainbranch ofopenclaw/openclawopenai-codexvia ChatGPT OAuthReproduction
openai-codexOAuth.Expected behavior
OpenClaw should not bind to or continue using a deactivated ChatGPT workspace when an active workspace is available.
Ideally it should:
accountIdafter OAuth,workspace deactivatedand retry/fallback to another active workspace,Actual behavior
The OAuth flow can complete successfully, but later runtime behavior fails because the selected workspace/account context is deactivated.
Code analysis
From the current
mainbranch, OpenClaw seems to delegate the critical workspace/account selection behavior to upstream OAuth helpers and does not add an active-workspace validation layer.OAuth login path
src/plugins/provider-openai-codex-oauth.tsThis path calls
loginOpenAICodex(...)from@mariozechner/pi-ai/oauthand returns the credentials, but I do not see any OpenClaw-side logic here that enumerates workspaces or filters out deactivated ones after login.Provider auth result construction
extensions/openai/openai-codex-provider.tsrunOpenAICodexOAuth()builds the stored auth result from returned credentials, but does not appear to perform a post-login workspace/account sanity check before persisting them.Usage path does support accountId, but only passively
src/infra/provider-usage.fetch.codex.tsThis code sends
ChatGPT-Account-IdwhenaccountIdexists, but that only helps if the stored credential already contains a correct, active account/workspace selection.Refresh fallback exists, but only for one narrow failure mode
extensions/openai/openai-codex-provider.tsThere is already a refresh fallback for:
Failed to extract accountId from tokenHowever, I do not see analogous handling for:
workspace deactivatedSuspected root cause
OpenClaw currently appears to trust upstream OAuth/account resolution too much for multi-workspace ChatGPT accounts.
If upstream selection is unstable / cached / defaulted to the wrong workspace, OpenClaw has no additional guardrail to:
Suggested fixes
Any of these would likely improve the situation:
Post-OAuth workspace validation in OpenClaw
accountIdRuntime fallback on
workspace deactivatedworkspace deactivated, do not fail immediatelyUpstream fix in
@mariozechner/pi-ai/oauthBroaden current refresh fallback logic
extract accountIdfallback handling to also consider deactivated-workspace casesWhy this matters
This is especially painful because OAuth can appear to succeed, so users only discover the problem later during actual provider use. For accounts with multiple workspaces, this makes the OpenAI OAuth path feel flaky and nondeterministic.
If helpful, I can also prepare a PR sketch for either:
@mariozechner/pi-ai/oauth.