Skip to content

openai-codex provider broken since 2026.4.5 — Cloudflare challenge + missing OAuth scope #68033

@apexict245

Description

@apexict245

Bug Description

The openai-codex provider fails on all models (gpt-5.4, gpt-5.3-codex, gpt-5.2) since approximately version 2026.4.5. Two stacked issues prevent any request from completing.

Environment

  • OpenClaw version: 2026.4.12 (also tested on 2026.4.14)
  • Container: ghcr.io/openclaw/openclaw:latest
  • Platform: Docker on macOS (Colima), arm64
  • Auth method: Codex CLI OAuth (openclaw onboard --auth-choice openai-codex)
  • OpenAI subscription: Pro ($200/mo)

Issue 1: Cloudflare JS Challenge (HTTP 403)

The openai-codex provider uses a hardcoded native route (route=native policy=hidden) that hits chatgpt.com/backend-api. Cloudflare returns a JS challenge that headless containers cannot solve:

HTTP/2 403
cf-mitigated: challenge

Container logs show:

embedded run agent end: isError=true model=gpt-5.4 provider=openai-codex 
error=LLM request failed: DNS lookup for the provider endpoint failed. 
rawError=<html>...(Cloudflare challenge page)...

The error message "DNS lookup failed" is misleading — DNS resolves fine, the issue is Cloudflare returning HTML instead of JSON.

Tested from both container and host — same 403 with cf-mitigated: challenge on all paths:

  • curl https://chatgpt.com/backend-api/codex/v1/responses → 403
  • Both with and without Bearer token

Issue 2: Missing api.responses.write OAuth Scope

The Codex CLI OAuth client (app_EMoamEEZ73f0CkXaXp7hrann) requests scopes: openid profile email offline_access api.connectors.read api.connectors.invoke. It does NOT include api.responses.write.

When testing the token directly against api.openai.com/v1/responses:

{
  "error": {
    "message": "Missing scopes: api.responses.write"
  }
}

Re-authing via openclaw onboard --auth-choice openai-codex issues a fresh token with the same limited scopes.

What We Tried (All Failed)

  1. Revoking OpenClaw consent in OpenAI connected apps settings, then re-authing
  2. Running openclaw onboard --auth-choice openai-codex (fresh token, same scopes)
  3. Upgrading Codex CLI from 0.104.0 to 0.120.0
  4. Pinning to openai-codex/gpt-5.3-codex (same Cloudflare block)
  5. Using the codex/gpt-5.4 provider prefix (separate provider entry in models.json, also fails)
  6. Overriding baseUrl in models.json — the native route (policy=hidden) ignores it

Additional Issue: openclaw onboard Wipes Auth

Running openclaw onboard --auth-choice openai-codex empties agents/main/agent/auth.json (0 bytes). This causes ALL providers to lose authentication until the container is fully restarted with environment variables re-injected. This feels like a separate bug.

Expected Behavior

The openai-codex provider should route requests to the ChatGPT backend API in a way that either:

  • Bypasses Cloudflare challenges (as the Codex CLI itself does)
  • Or uses the public API (api.openai.com/v1/responses) with proper OAuth scopes including api.responses.write

Workaround

Using anthropic/claude-haiku-4-5-20251001 as primary model with direct Anthropic API key. This works reliably but doesn't use the OpenAI Pro subscription.

Reproduction Steps

  1. Deploy OpenClaw 2026.4.12+ in Docker
  2. Run openclaw onboard --auth-choice openai-codex and complete the OAuth flow
  3. Set primary model to openai-codex/gpt-5.4
  4. Send any message
  5. Observe Cloudflare 403 in container logs with cf-mitigated: challenge

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions