openclaw - 💡(How to fix) Fix [Bug]: native codex harness uses broken isolated CODEX_HOME (harness-auth) while ~/.codex works [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#70511Fetched 2026-04-24 05:57:10
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
commented ×1subscribed ×1

When using the native Codex harness (codex/gpt-5.4 with embeddedHarness.runtime: "codex"), OpenClaw launches Codex app-server with an isolated CODEX_HOME under:

~/.openclaw/agents/main/agent/harness-auth/codex/<hash>

On my machine, that generated home is the failing layer.

  • Real Codex auth under ~/.codex works.
  • The generated harness-auth Codex home does not.
  • Native codex/* turns then fail with 401 Unauthorized: Missing bearer or basic authentication in header.

A local workaround is to override plugins.entries.codex.config.appServer.command with a wrapper that forces Codex app-server to use the real working ~/.codex instead of the generated bridge home.

Error Message

Error checking login status: missing field id_token at line 6 column 3 3. Or OpenClaw should detect that the generated bridge home is invalid and fail with a much more specific error than a downstream 401.

Root Cause

This is not ideal, because it bypasses the harness-auth bridge entirely and relies on the user discovering and wiring a wrapper manually.

Fix Action

Workaround

This local workaround appears necessary on my machine:

#!/bin/zsh
export HOME="/Users/<user>"
export CODEX_HOME="/Users/<user>/.codex"
exec /opt/homebrew/bin/codex "$@"

Configured as:

{
  "plugins": {
    "entries": {
      "codex": {
        "enabled": true,
        "config": {
          "appServer": {
            "command": "/Users/<user>/.openclaw/bin/codex-home-wrapper"
          }
        }
      }
    }
  }
}

This is not ideal, because it bypasses the harness-auth bridge entirely and relies on the user discovering and wiring a wrapper manually.

Code Example

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "codex/gpt-5.4",
        "fallbacks": ["openai-codex/gpt-5.3-codex-spark"]
      },
      "embeddedHarness": {
        "runtime": "codex",
        "fallback": "none"
      }
    }
  },
  "plugins": {
    "entries": {
      "codex": {
        "enabled": true
      }
    }
  }
}

---

HOME=/Users/<user> CODEX_HOME=/Users/<user>/.codex codex login status

---

Logged in using ChatGPT

---

find ~/.openclaw/agents/main/agent/harness-auth/codex -mindepth 1 -maxdepth 1 -type d | sort

---

/Users/<user>/.openclaw/agents/main/agent/harness-auth/codex/06bfb5171eff0241
/Users/<user>/.openclaw/agents/main/agent/harness-auth/codex/a9df8fee07a27f2d

---

ACTIVE_HOME=$(find ~/.openclaw/agents/main/agent/harness-auth/codex -mindepth 1 -maxdepth 1 -type d | sort | tail -n 1)
HOME=~ CODEX_HOME="$ACTIVE_HOME" codex login status

---

Error checking login status: missing field `id_token` at line 6 column 3

---

unexpected status 401 Unauthorized: Missing bearer or basic authentication in header

---

codex app-server thread resume failed; starting a new thread

---

#!/bin/zsh
export HOME="/Users/<user>"
export CODEX_HOME="/Users/<user>/.codex"
exec /opt/homebrew/bin/codex "$@"

---

{
  "plugins": {
    "entries": {
      "codex": {
        "enabled": true,
        "config": {
          "appServer": {
            "command": "/Users/<user>/.openclaw/bin/codex-home-wrapper"
          }
        }
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Summary

When using the native Codex harness (codex/gpt-5.4 with embeddedHarness.runtime: "codex"), OpenClaw launches Codex app-server with an isolated CODEX_HOME under:

~/.openclaw/agents/main/agent/harness-auth/codex/<hash>

On my machine, that generated home is the failing layer.

  • Real Codex auth under ~/.codex works.
  • The generated harness-auth Codex home does not.
  • Native codex/* turns then fail with 401 Unauthorized: Missing bearer or basic authentication in header.

A local workaround is to override plugins.entries.codex.config.appServer.command with a wrapper that forces Codex app-server to use the real working ~/.codex instead of the generated bridge home.

Environment

  • OpenClaw: 2026.4.21 (f788c88)
  • Codex CLI: 0.123.0
  • macOS (Apple Silicon)
  • Auth method: ChatGPT / Codex OAuth
  • Model: codex/gpt-5.4
  • Harness config:
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "codex/gpt-5.4",
        "fallbacks": ["openai-codex/gpt-5.3-codex-spark"]
      },
      "embeddedHarness": {
        "runtime": "codex",
        "fallback": "none"
      }
    }
  },
  "plugins": {
    "entries": {
      "codex": {
        "enabled": true
      }
    }
  }
}

Why this appears to be a harness-auth bridge bug

The official docs for the Codex harness say:

  • Codex auth must be available to the app-server process
  • Use the same auth material your local Codex app-server uses

Docs:

However, the installed OpenClaw Codex harness appears to generate and inject its own isolated Codex home instead of using the already-working local one.

From the installed bundle on my machine:

  • dist/extensions/codex/harness-*.js calls prepareCodexAuthBridge({ bridgeDir: "harness-auth", ... })
  • then injects env.CODEX_HOME = bridge.codexHome

I can reproduce that the generated home is broken while the real home is healthy.

Reproduction

  1. Ensure native Codex CLI auth is working normally.
HOME=/Users/<user> CODEX_HOME=/Users/<user>/.codex codex login status

Result:

Logged in using ChatGPT
  1. Find the generated harness-auth Codex homes.
find ~/.openclaw/agents/main/agent/harness-auth/codex -mindepth 1 -maxdepth 1 -type d | sort

Example generated dirs on my machine:

/Users/<user>/.openclaw/agents/main/agent/harness-auth/codex/06bfb5171eff0241
/Users/<user>/.openclaw/agents/main/agent/harness-auth/codex/a9df8fee07a27f2d
  1. Point Codex CLI at the latest generated harness-auth home.
ACTIVE_HOME=$(find ~/.openclaw/agents/main/agent/harness-auth/codex -mindepth 1 -maxdepth 1 -type d | sort | tail -n 1)
HOME=~ CODEX_HOME="$ACTIVE_HOME" codex login status

Actual result:

Error checking login status: missing field `id_token` at line 6 column 3
  1. Trigger a native Codex harness turn (for example /new in Discord, or any run with codex/gpt-5.4).

Actual result in gateway log:

unexpected status 401 Unauthorized: Missing bearer or basic authentication in header

I also saw:

codex app-server thread resume failed; starting a new thread

and then the turn failed before reply.

Additional evidence

The generated bridge homes do contain copied Codex-looking files such as:

  • auth.json
  • config.toml
  • installation_id
  • sqlite state/log files

So this does not look like a simple “file missing” problem. It looks more like OpenClaw is generating/syncing an auth home that Codex app-server / Codex CLI cannot reliably use.

Workaround

This local workaround appears necessary on my machine:

#!/bin/zsh
export HOME="/Users/<user>"
export CODEX_HOME="/Users/<user>/.codex"
exec /opt/homebrew/bin/codex "$@"

Configured as:

{
  "plugins": {
    "entries": {
      "codex": {
        "enabled": true,
        "config": {
          "appServer": {
            "command": "/Users/<user>/.openclaw/bin/codex-home-wrapper"
          }
        }
      }
    }
  }
}

This is not ideal, because it bypasses the harness-auth bridge entirely and relies on the user discovering and wiring a wrapper manually.

Expected behavior

One of these should be true:

  1. The generated harness-auth Codex home should be fully usable by Codex CLI / Codex app-server.
  2. Or the native harness should provide an official config path to reuse the same local Codex auth material (~/.codex) without requiring a wrapper workaround.
  3. Or OpenClaw should detect that the generated bridge home is invalid and fail with a much more specific error than a downstream 401.

Important distinction

This is not just “my OAuth token is bad.”

On the same machine:

  • real ~/.codex works immediately
  • the generated harness-auth home fails immediately

So the breakage appears to be in the OpenClaw Codex auth-home bridge layer, not in the underlying local Codex login.

extent analysis

TL;DR

The most likely fix is to override the plugins.entries.codex.config.appServer.command with a wrapper that forces Codex app-server to use the real working ~/.codex instead of the generated bridge home.

Guidance

  • Verify that the native Codex CLI auth is working normally by running codex login status with the CODEX_HOME environment variable set to ~/.codex.
  • Check the generated harness-auth Codex homes by running find ~/.openclaw/agents/main/agent/harness-auth/codex -mindepth 1 -maxdepth 1 -type d | sort and verify that they contain the expected files such as auth.json, config.toml, and installation_id.
  • Apply the local workaround by creating a wrapper script that sets CODEX_HOME to ~/.codex and executes the Codex app-server with the correct environment variables.
  • Configure the plugins.entries.codex.config.appServer.command to point to the wrapper script.

Example

{
  "plugins": {
    "entries": {
      "codex": {
        "enabled": true,
        "config": {
          "appServer": {
            "command": "/Users/<user>/.openclaw/bin/codex-home-wrapper"
          }
        }
      }
    }
  }
}

Notes

The issue appears to be related to the OpenClaw Codex auth-home bridge layer, which generates an isolated Codex home that is not fully usable by Codex CLI / Codex app-server. The workaround bypasses this layer and relies on the user discovering and wiring a wrapper manually.

Recommendation

Apply the workaround by creating a wrapper script and configuring the plugins.entries.codex.config.appServer.command to point to it, as this is the most straightforward way to resolve the issue without waiting for a potential fix in the OpenClaw

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…

FAQ

Expected behavior

One of these should be true:

  1. The generated harness-auth Codex home should be fully usable by Codex CLI / Codex app-server.
  2. Or the native harness should provide an official config path to reuse the same local Codex auth material (~/.codex) without requiring a wrapper workaround.
  3. Or OpenClaw should detect that the generated bridge home is invalid and fail with a much more specific error than a downstream 401.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: native codex harness uses broken isolated CODEX_HOME (harness-auth) while ~/.codex works [1 comments, 2 participants]