openclaw - 💡(How to fix) Fix `codex/gpt-5.5` fails after successful `codex login` because Codex synthetic auth returns `codex-app-server` instead of a real token [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72236Fetched 2026-04-27 05:32:47
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Author
Timeline (top)
closed ×1commented ×1

When OpenClaw is configured to use the modern Codex provider path, for example codex/gpt-5.5, requests can still fail even though Codex CLI login succeeded.

In my case, the main model consistently failed with:

Failed to extract accountId from token

and then fell back to another provider.

The issue appears to come from the Codex extension's synthetic auth implementation: it returns the placeholder string codex-app-server as the provider token instead of resolving the real authenticated Codex token.

Error Message

[agent/embedded] embedded run agent end: ... provider=codex error=Failed to extract accountId from token

Root Cause

The Codex extension currently synthesizes auth in:

  • extensions/codex/provider.ts
  • extensions/codex/provider-discovery.ts

Both paths return:

{
  apiKey: "codex-app-server",
  source: "codex-app-server",
  mode: "token"
}

That value is a marker, not a real access token. Downstream code later treats it like a real token and eventually fails when trying to extract chatgpt_account_id / accountId.

Fix Action

Fix / Workaround

Verified local workaround

As a local hotfix, I changed the Codex synthetic auth path to:

Code Example

Failed to extract accountId from token

---

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "codex/gpt-5.5"
      }
    }
  }
}

---

codex login

---

codex login status

---

[agent/embedded] embedded run agent end: ... provider=codex error=Failed to extract accountId from token
[agent/embedded] embedded run failover decision: ... from=codex/gpt-5.5 ... rawError=Failed to extract accountId from token
[model-fallback/decision] ... candidate_failed requested=codex/gpt-5.5 candidate=codex/gpt-5.5 reason=auth ...

---

{
  apiKey: "codex-app-server",
  source: "codex-app-server",
  mode: "token"
}

---

winnerProvider = codex
winnerModel = gpt-5.5
fallbackUsed = false
RAW_BUFFERClick to expand / collapse

Title: codex/gpt-5.5 fails after successful codex login because Codex synthetic auth returns codex-app-server instead of a real token

Summary

When OpenClaw is configured to use the modern Codex provider path, for example codex/gpt-5.5, requests can still fail even though Codex CLI login succeeded.

In my case, the main model consistently failed with:

Failed to extract accountId from token

and then fell back to another provider.

The issue appears to come from the Codex extension's synthetic auth implementation: it returns the placeholder string codex-app-server as the provider token instead of resolving the real authenticated Codex token.

Environment

  • OpenClaw: 2026.4.23
  • Codex CLI: reproduced before and after upgrading to 0.125.0
  • Main model: codex/gpt-5.5
  • Fallback model during testing: kimi-code-openai/kimi-for-coding
  • Host: Linux VPS

Reproduction

  1. Configure OpenClaw to use a Codex model as the primary model, for example:
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "codex/gpt-5.5"
      }
    }
  }
}
  1. Authenticate Codex CLI successfully:
codex login
  1. Confirm Codex CLI is logged in:
codex login status
  1. Send a normal OpenClaw agent request.

Actual result

The Codex main model fails and OpenClaw falls back. Logs look like:

[agent/embedded] embedded run agent end: ... provider=codex error=Failed to extract accountId from token
[agent/embedded] embedded run failover decision: ... from=codex/gpt-5.5 ... rawError=Failed to extract accountId from token
[model-fallback/decision] ... candidate_failed requested=codex/gpt-5.5 candidate=codex/gpt-5.5 reason=auth ...

Expected result

If Codex CLI is already authenticated, codex/gpt-5.5 should use that authenticated state and complete normally without falling back.

Root cause

The Codex extension currently synthesizes auth in:

  • extensions/codex/provider.ts
  • extensions/codex/provider-discovery.ts

Both paths return:

{
  apiKey: "codex-app-server",
  source: "codex-app-server",
  mode: "token"
}

That value is a marker, not a real access token. Downstream code later treats it like a real token and eventually fails when trying to extract chatgpt_account_id / accountId.

Verified local workaround

As a local hotfix, I changed the Codex synthetic auth path to:

  1. Read ~/.codex/auth.json
  2. Use tokens.access_token when present
  3. Fall back to codex-app-server only if no real token is available

After that change, the same request succeeded with:

winnerProvider = codex
winnerModel = gpt-5.5
fallbackUsed = false

Why this looks like an upstream bug

  • It reproduces even after successful codex login
  • It still reproduces after manually syncing OpenClaw auth profiles
  • Replacing only the synthetic auth token source fixes the issue

That strongly suggests the problem is not user OAuth state, but how the Codex plugin resolves runtime auth.

Suggested fix

The Codex provider should resolve a real runtime token from Codex CLI state, or through a shared runtime auth helper, instead of always returning codex-app-server.

At minimum, resolveSyntheticAuth() should not hand back a placeholder token for an auth-required openai-codex-responses path when a real authenticated Codex session exists.

Additional note

Even if the final upstream fix does not read ~/.codex/auth.json directly, the current behavior still appears wrong: a placeholder marker is being returned in a path that later expects a real token with account claims.

extent analysis

TL;DR

The Codex extension's synthetic auth implementation should be updated to return a real authenticated Codex token instead of the placeholder string codex-app-server.

Guidance

  • Verify that the codex login command has successfully authenticated the user by checking the output of codex login status.
  • Check the ~/.codex/auth.json file for the presence of a valid access token.
  • Update the resolveSyntheticAuth() function in the Codex provider to return a real runtime token from Codex CLI state or a shared runtime auth helper.
  • As a temporary workaround, manually modify the Codex synthetic auth path to read ~/.codex/auth.json and use the tokens.access_token when present.

Example

// Example of updated resolveSyntheticAuth() function
function resolveSyntheticAuth() {
  const authJson = require('~/.codex/auth.json');
  if (authJson && authJson.tokens && authJson.tokens.access_token) {
    return {
      apiKey: authJson.tokens.access_token,
      source: 'codex-cli',
      mode: 'token'
    };
  } else {
    // Fall back to default behavior or throw an error
  }
}

Notes

The suggested fix assumes that the ~/.codex/auth.json file contains a valid access token. If this is not the case, additional error handling may be necessary.

Recommendation

Apply the workaround by updating the resolveSyntheticAuth() function to return a real runtime token from Codex CLI state or a shared runtime auth helper. This should fix the issue and allow the Codex model to use the authenticated state without falling back.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING