openclaw - 💡(How to fix) Fix Codex API server_error (500) not recognized by model failover classifier

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…

Error Message

When the OpenAI Codex API returns a server_error (HTTP 500), OpenClaw does not trigger model fallback. Instead, the error is surfaced directly to the user, even when a fallback chain is configured. A Codex server_error should be classified as a transient/retryable error and trigger the model fallback chain (e.g. Codex → Opus → Sonnet → etc). The error is displayed to the user. No fallback model is attempted. The user has to manually switch models via /model. The failover classifier (classifyFailoverReason in pi-embedded-helpers) does not recognize the Codex/OpenAI error JSON format: {"type":"error","error":{"type":"server_error","code":"server_error","message":"An error occurred while processing your request..."}}

  • isJsonApiInternalServerError() checks for "type":"api_error" + "internal server error" (Anthropic's format), but Codex uses "type":"server_error" + "code":"server_error"
  • isTransientHttpError() looks for a leading HTTP status code (like 500 ...), but the Codex error starts with Codex error: {...}
  • No other classifier matches the Codex error format embedded run agent end: runId=... isError=true error=Codex error: {"type":"error","error":{"type":"server_error","code":"server_error",...}}

Code Example

{"type":"error","error":{"type":"server_error","code":"server_error","message":"An error occurred while processing your request..."}}

---

function isCodexServerError(raw: string): boolean {
  if (!raw) return false;
  const lower = raw.toLowerCase();
  return lower.includes('"type":"server_error"') || lower.includes('"code":"server_error"');
}

---

embedded run agent end: runId=... isError=true error=Codex error: {"type":"error","error":{"type":"server_error","code":"server_error",...}}

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

A Codex server_error should be classified as a transient/retryable error and trigger the model fallback chain (e.g. Codex → Opus → Sonnet → etc).

Still need to ship something?

×6

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

Back to top recommendations

TRENDING