openclaw - ✅(Solved) Fix Model fallback not triggered on billing/balance errors (insufficient balance 1008) [1 pull requests, 3 comments, 4 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#52185Fetched 2026-04-08 01:14:34
View on GitHub
Comments
3
Participants
4
Timeline
7
Reactions
0
Author
Timeline (top)
commented ×3closed ×1cross-referenced ×1locked ×1

Error Message

Currently using MiniMax M2.7 as primary with blockrun/eco as fallback. When MiniMax returns HTTP 500 with error insufficient balance (1008) (hourly cap hit or balance exhausted), the fallback does not activate. Instead: 2. Each retry fails with same billing error 4. Error propagates to user Billing/balance errors (HTTP 500 with insufficient balance, quota exceeded, resource exhausted, error code 1008) should trigger the configured fallback model, just like rate-limit errors (429) do.

  • Error: HTTP 500, code 1008, message "insufficient balance" None available - the fallback simply does not activate on these error types.

Root Cause

From the OpenClaw docs on model providers:

"Requests are retried with the next key only on rate-limit responses (for example 429, rate_limit, quota, resource exhausted). Non-rate-limit failures fail immediately; no key rotation is attempted."

The fallback mechanism appears to only trigger on rate-limit conditions, not on billing/credit exhaustion errors.

Fix Action

Workaround

None available - the fallback simply does not activate on these error types.

PR fix notes

PR #52255: fix(failover): classify HTTP 500 billing errors as billing, not timeout

Description (problem / solution / changelog)

Summary

  • Providers like MiniMax return HTTP 500 with insufficient balance (code 1008) for billing exhaustion. Previously these were misclassified as timeout because the transient-5xx check ran before the billing pattern matcher, causing 4x retries against the same exhausted account instead of triggering the configured fallback model.
  • Root cause: isTransientHttpError() matches 500-class status codes and returns "timeout" before isBillingErrorMessage() ever runs. Same gap exists in classifyFailoverReasonFromHttpStatus() which had no explicit HTTP 500 handler.

Fixes #52185

Test plan

  • pnpm test -- src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts — 72/72 pass
  • 500 insufficient balance → classified as billing
  • 500 {"error":{"code":1008,"message":"insufficient balance"}}billing
  • classifyFailoverReasonFromHttpStatus(500, "insufficient balance")billing
  • Plain 500 internal server error still classified as timeout (no regression)
  • pnpm check passes (format, lint, typecheck)

Changed files

  • src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts (modified, +20/-0)
  • src/agents/pi-embedded-helpers/errors.ts (modified, +16/-0)
RAW_BUFFERClick to expand / collapse

Bug Description

Model fallback (blockrun/eco) is not triggered when a model returns insufficient balance or billing errors.

Currently using MiniMax M2.7 as primary with blockrun/eco as fallback. When MiniMax returns HTTP 500 with error insufficient balance (1008) (hourly cap hit or balance exhausted), the fallback does not activate. Instead:

  1. OpenClaw retries same model 4x
  2. Each retry fails with same billing error
  3. Fallback (blockrun/eco) is never attempted
  4. Error propagates to user

Expected Behavior

Billing/balance errors (HTTP 500 with insufficient balance, quota exceeded, resource exhausted, error code 1008) should trigger the configured fallback model, just like rate-limit errors (429) do.

Root Cause

From the OpenClaw docs on model providers:

"Requests are retried with the next key only on rate-limit responses (for example 429, rate_limit, quota, resource exhausted). Non-rate-limit failures fail immediately; no key rotation is attempted."

The fallback mechanism appears to only trigger on rate-limit conditions, not on billing/credit exhaustion errors.

Environment

  • OpenClaw: 2026.3.13
  • Provider: minimax-portal (OAuth, MiniMax M2.7)
  • Primary model: minimax-portal/MiniMax-M2.7
  • Fallback: blockrun/eco
  • Error: HTTP 500, code 1008, message "insufficient balance"

Proposed Fix

Treat billing/balance errors (code 1008, insufficient balance, quota exceeded, etc.) the same as rate-limit errors for fallback purposes. These are transient conditions that resolve when the user adds credits or the hourly cap resets.

Workaround

None available - the fallback simply does not activate on these error types.

extent analysis

Fix Plan

To fix the issue, we need to modify the OpenClaw configuration to treat billing/balance errors the same as rate-limit errors for fallback purposes.

  • Update the OpenClaw configuration to include billing/balance error codes in the retry mechanism:
# OpenClaw configuration update
retry_on_errors = [
    'rate_limit', 
    'quota', 
    'resource_exhausted', 
    '429', 
    '1008',  # insufficient balance
    'insufficient balance', 
    'quota exceeded'
]
  • Ensure the fallback model is correctly configured:
# Fallback model configuration
primary_model = 'minimax-portal/MiniMax-M2.7'
fallback_model = 'blockrun/eco'
  • Implement a custom error handler to catch and handle billing/balance errors:
# Custom error handler
def handle_billing_error(error):
    if error.code == 1008 or error.message in ['insufficient balance', 'quota exceeded']:
        # Trigger fallback model
        return fallback_model
    else:
        # Handle other errors
        return None

Verification

To verify the fix, test the following scenarios:

  • Primary model returns HTTP 500 with error code 1008 (insufficient balance)
  • Primary model returns HTTP 500 with error message quota exceeded
  • Primary model returns HTTP 429 (rate-limit error)

In each scenario, verify that the fallback model is triggered and the request is successfully processed.

Extra Tips

  • Monitor the error rates and adjust the retry mechanism as needed to prevent abuse.
  • Consider implementing a notification system to alert administrators when the primary model returns billing/balance errors.
  • Review the OpenClaw documentation for any updates on handling billing/balance errors.

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