openclaw - 💡(How to fix) Fix [Bug]: Codex OAuth compaction falls back to direct OpenAI API and fails without OPENAI_API_KEY [5 pull requests]

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…

A session using openai/gpt-5.5 with a valid OpenAI Codex OAuth profile fails during compaction with:

Missing API key for OpenAI on the gateway. Use openai/gpt-5.5 with the Codex OAuth profile, or set OPENAI_API_KEY for direct OpenAI API-key runs.

This is not limited to Slack. It appears to happen whenever compaction is triggered. The agent works normally before compaction, and openclaw models status reports Codex OAuth as usable.

The failure path appears to be:

  1. Session reaches the compaction threshold.
  2. Codex-native/app-server compaction cannot use the existing thread/session binding.
  3. OpenClaw falls back to a context-engine/direct provider path.
  4. That fallback path tries to use the direct OpenAI provider.
  5. Since the installation is intentionally using Codex OAuth and has no OPENAI_API_KEY, compaction fails and the user receives the missing API key warning.

Root Cause

A session using openai/gpt-5.5 with a valid OpenAI Codex OAuth profile fails during compaction with:

Missing API key for OpenAI on the gateway. Use openai/gpt-5.5 with the Codex OAuth profile, or set OPENAI_API_KEY for direct OpenAI API-key runs.

This is not limited to Slack. It appears to happen whenever compaction is triggered. The agent works normally before compaction, and openclaw models status reports Codex OAuth as usable.

The failure path appears to be:

  1. Session reaches the compaction threshold.
  2. Codex-native/app-server compaction cannot use the existing thread/session binding.
  3. OpenClaw falls back to a context-engine/direct provider path.
  4. That fallback path tries to use the direct OpenAI provider.
  5. Since the installation is intentionally using Codex OAuth and has no OPENAI_API_KEY, compaction fails and the user receives the missing API key warning.

Fix Action

Fixed

Code Example

[agent/embedded] codex app-server compaction could not use thread binding
[agent/embedded] native harness compaction could not use its session binding; falling back to context engine: no codex app-server thread binding
[agent/embedded] [compaction-diag] end runId=2a6dbce3-8204-4ce4-817d-ca3b533d600d sessionKey=agent:jenny:slack:channel:c0b1fnbny5p diagId=cmp-mpkmesl7-485csw trigger=budget provider=openai/gpt-5.5 attempt=1 maxAttempts=1 outcome=failed reason=unknown detail=No_API_key_found_for_provider_openai_._You_are_authenticated_with_OpenAI_Codex_OAuth_OpenAI_agent_mo durationMs=6739

⚠️ Missing API key for OpenAI on the gateway. Use openai/gpt-5.5 with the Codex OAuth profile, or set OPENAI_API_KEY for direct OpenAI API-key runs.

### OpenClaw version

2026.5.22 (a374c3a)

### Operating system

Ubuntu 24.04.4

### Install method

npm / pnpm package-manager install, not git checkout

### Model

openai/gpt-5.5

### Provider / routing chain

OpenClaw -> OpenAI Codex OAuth -> openai/gpt-5.5

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

A session using openai/gpt-5.5 with a valid OpenAI Codex OAuth profile fails during compaction with:

Missing API key for OpenAI on the gateway. Use openai/gpt-5.5 with the Codex OAuth profile, or set OPENAI_API_KEY for direct OpenAI API-key runs.

This is not limited to Slack. It appears to happen whenever compaction is triggered. The agent works normally before compaction, and openclaw models status reports Codex OAuth as usable.

The failure path appears to be:

  1. Session reaches the compaction threshold.
  2. Codex-native/app-server compaction cannot use the existing thread/session binding.
  3. OpenClaw falls back to a context-engine/direct provider path.
  4. That fallback path tries to use the direct OpenAI provider.
  5. Since the installation is intentionally using Codex OAuth and has no OPENAI_API_KEY, compaction fails and the user receives the missing API key warning.

Steps to reproduce

  1. Start OpenClaw 2026.5.22 with OpenAI Codex OAuth configured.

  2. Configure an agent with model openai/gpt-5.5.

  3. Do not set OPENAI_API_KEY; use Codex OAuth only.

  4. Confirm the agent auth is usable:

    openclaw models status --agent <agent-id>

    The output shows:

    • Runtime auth
    • openai via codex uses openai-codex ... status=usable
  5. Use the agent until the session reaches the compaction threshold, or otherwise trigger budget-based compaction.

  6. Observe that compaction fails and the user-visible response becomes:

    ⚠️ Missing API key for OpenAI on the gateway. Use openai/gpt-5.5 with the Codex OAuth profile, or set OPENAI_API_KEY for direct OpenAI API-key runs.

  7. Check gateway logs.

Expected behavior

Compacted without errors.

Actual behavior

When compaction is triggered, the session fails with a missing OPENAI_API_KEY warning, even though the active model is openai/gpt-5.5 and Codex OAuth auth is usable.

Observed gateway log:

[agent/embedded] codex app-server compaction could not use thread binding
[agent/embedded] native harness compaction could not use its session binding; falling back to context engine: no codex app-server thread binding
[agent/embedded] [compaction-diag] end runId=2a6dbce3-8204-4ce4-817d-ca3b533d600d sessionKey=agent:jenny:slack:channel:c0b1fnbny5p diagId=cmp-mpkmesl7-485csw trigger=budget provider=openai/gpt-5.5 attempt=1 maxAttempts=1 outcome=failed reason=unknown detail=No_API_key_found_for_provider_openai_._You_are_authenticated_with_OpenAI_Codex_OAuth_OpenAI_agent_mo durationMs=6739

⚠️ Missing API key for OpenAI on the gateway. Use openai/gpt-5.5 with the Codex OAuth profile, or set OPENAI_API_KEY for direct OpenAI API-key runs.

### OpenClaw version

2026.5.22 (a374c3a)

### Operating system

Ubuntu 24.04.4

### Install method

npm / pnpm package-manager install, not git checkout

### Model

openai/gpt-5.5

### Provider / routing chain

OpenClaw -> OpenAI Codex OAuth -> openai/gpt-5.5

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence

```shell

Impact and severity

No response

Additional information

No response

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

Compacted without errors.

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]: Codex OAuth compaction falls back to direct OpenAI API and fails without OPENAI_API_KEY [5 pull requests]