openclaw - 💡(How to fix) Fix [Bug]: OAuth model failover error surfaces to UI even when fallback succeeds — ChatGPT Plus cap misidentified as API rate limit [4 comments, 3 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#49491Fetched 2026-04-08 00:54:46
View on GitHub
Comments
4
Participants
3
Timeline
8
Reactions
0
Timeline (top)
commented ×2cross-referenced ×2mentioned ×2subscribed ×2

When the primary model (OpenAI Codex / ChatGPT Plus OAuth) hits the ChatGPT Plus subscription usage cap, OpenClaw:

  1. Surfaces the error to the UI even when a fallback model (Anthropic) successfully handles the request
  2. Labels the error as "API rate limit reached" — misleading when on OAuth (not an API key). The actual failure is a ChatGPT Plus plan usage cap, which is a different condition entirely.
  3. Triggers a WebSocket auth lockout loop when the user attempts reconnect after a gateway restart, compounding the perceived outage.

Error Message

Primary failure (from gateway log):

embedded_run_agent_end: error="⚠️ API rate limit reached. Please try again later."
rawErrorPreview="You have hit your ChatGPT usage limit (plus plan). Try again in ~734 min."

Fallback success (same run):

model_fallback_decision: decision="candidate_succeeded"
candidateProvider="anthropic" candidateModel="claude-sonnet-4-6"
attempt=2

WebSocket lockout:

gateway/ws: unauthorized reason=rate_limited
reason="unauthorized: too many failed authentication attempts (retry later)"

Root Cause

When the primary model (OpenAI Codex / ChatGPT Plus OAuth) hits the ChatGPT Plus subscription usage cap, OpenClaw:

  1. Surfaces the error to the UI even when a fallback model (Anthropic) successfully handles the request
  2. Labels the error as "API rate limit reached" — misleading when on OAuth (not an API key). The actual failure is a ChatGPT Plus plan usage cap, which is a different condition entirely.
  3. Triggers a WebSocket auth lockout loop when the user attempts reconnect after a gateway restart, compounding the perceived outage.

Code Example

embedded_run_agent_end: error="⚠️ API rate limit reached. Please try again later."
rawErrorPreview="You have hit your ChatGPT usage limit (plus plan). Try again in ~734 min."

---

model_fallback_decision: decision="candidate_succeeded"
candidateProvider="anthropic" candidateModel="claude-sonnet-4-6"
attempt=2

---

gateway/ws: unauthorized reason=rate_limited
reason="unauthorized: too many failed authentication attempts (retry later)"
RAW_BUFFERClick to expand / collapse

Description

When the primary model (OpenAI Codex / ChatGPT Plus OAuth) hits the ChatGPT Plus subscription usage cap, OpenClaw:

  1. Surfaces the error to the UI even when a fallback model (Anthropic) successfully handles the request
  2. Labels the error as "API rate limit reached" — misleading when on OAuth (not an API key). The actual failure is a ChatGPT Plus plan usage cap, which is a different condition entirely.
  3. Triggers a WebSocket auth lockout loop when the user attempts reconnect after a gateway restart, compounding the perceived outage.

Steps to Reproduce

  1. Configure primary model as openai-codex/gpt-5.4 via ChatGPT Plus OAuth
  2. Use the system heavily until the ChatGPT Plus monthly usage cap is hit
  3. Observe: error message "⚠️ API rate limit reached. Please try again later." is shown to the user in the UI
  4. Check logs: fallback to Anthropic claude-sonnet-4-6 succeeds on attempt 2
  5. User still sees the error despite the response being served successfully by Anthropic

Expected Behavior

  • If a fallback model handles the request successfully, no error should be shown to the user
  • If the error must be shown, the message should distinguish between:
    • API key rate limit (requests/minute or token quota)
    • ChatGPT Plus subscription usage cap (monthly plan limit on OAuth path)
  • WebSocket reconnect after restart should not enter a lockout loop when using a valid (but stale) token — it should prompt for a fresh URL instead

Actual Behavior

  • "API rate limit reached" is shown in the UI even though Anthropic fallback served the response
  • The ChatGPT Plus cap is indistinguishable from an API rate limit in error messaging
  • After a gateway restart during the incident, the webchat control UI entered a rate_limited WebSocket lockout: unauthorized: too many failed authentication attempts (retry later)
  • The user experienced this as a full outage for ~7 hours despite the fallback chain functioning correctly throughout

Logs

Primary failure (from gateway log):

embedded_run_agent_end: error="⚠️ API rate limit reached. Please try again later."
rawErrorPreview="You have hit your ChatGPT usage limit (plus plan). Try again in ~734 min."

Fallback success (same run):

model_fallback_decision: decision="candidate_succeeded"
candidateProvider="anthropic" candidateModel="claude-sonnet-4-6"
attempt=2

WebSocket lockout:

gateway/ws: unauthorized reason=rate_limited
reason="unauthorized: too many failed authentication attempts (retry later)"

Environment

  • OpenClaw version: 2026.3.13
  • OS: macOS Darwin 25.3.0 arm64
  • Primary model: openai-codex/gpt-5.4 (ChatGPT Plus OAuth)
  • Fallback: anthropic/claude-sonnet-4-6

Impact

High. This caused an entire day of perceived outage for a production agent setup, despite the fallback chain working correctly. The error UX made it impossible to distinguish "system broken" from "primary model capped, fallback running fine."

extent analysis

Fix Plan

To address the issues, we need to:

  • Distinguish between API rate limit errors and ChatGPT Plus subscription usage cap errors
  • Prevent WebSocket auth lockout loops after a gateway restart
  • Ensure successful fallbacks are not surfaced as errors to the user

Code Changes

We will modify the error handling and WebSocket reconnect logic:

# Check if the error is due to ChatGPT Plus usage cap
if "You have hit your ChatGPT usage limit" in rawErrorPreview:
    # Display a distinct error message for ChatGPT Plus usage cap
    error_message = "ChatGPT Plus usage limit reached. Please try again later."
else:
    # Display the standard API rate limit error message
    error_message = "API rate limit reached. Please try again later."

# Only surface the error to the user if the fallback failed
if candidateProvider == "primary" and error_message:
    # Display the error message to the user
    print(error_message)
elif candidateProvider != "primary":
    # Fallback succeeded, do not display an error message
    print("Response served successfully by fallback model.")

# Modify WebSocket reconnect logic to prompt for a fresh token after a gateway restart
if reason == "unauthorized: too many failed authentication attempts (retry later)":
    # Prompt the user to authenticate again
    print("Please authenticate again to continue.")

Configuration Changes

Update the OpenClaw configuration to include distinct error messages for API rate limit and ChatGPT Plus usage cap errors.

Verification

To verify the fix, reproduce the steps to reproduce the issue and check that:

  • The error message displayed to the user distinguishes between API rate limit and ChatGPT Plus usage cap errors
  • The fallback model serves the response successfully without surfacing an error to the user
  • The WebSocket reconnect logic prompts the user to authenticate again after a gateway restart instead of entering a lockout loop

Extra Tips

Regularly review and update error handling and WebSocket reconnect logic to ensure they align with the latest API and subscription usage cap requirements. Monitor system logs to quickly identify and address any issues that may arise.

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