Skip to content

FailoverError on rate limit/billing is misreported as 'Context overflow' #10368

@safqore-nova

Description

@safqore-nova

Bug Description

When the Anthropic API returns a rate limit or billing error (e.g., "You have reached your specified API usage limits"), and all fallback models also fail with the same error, the user-facing message incorrectly says:

Context overflow: prompt too large for the model. Try again with less input or a larger-context model.

This is misleading. The actual error is a rate limit / billing issue, not a context overflow.

Steps to Reproduce

  1. Configure two Anthropic models (primary + fallback) in openclaw.json
  2. Hit your Anthropic API spend limit
  3. Send a message via WhatsApp

Expected Behavior

The user should see something like:

"API usage limit reached. You will regain access on 2026-03-01. Check your Anthropic billing settings."

Actual Behavior

User sees: "Context overflow: prompt too large for the model. Try again with less input or a larger-context model."

Root Cause

In agents/pi-embedded-runner/run.js, the FailoverError ("All models failed") gets caught by the outer error handler in auto-reply/reply/agent-runner-execution.js, which appears to misclassify it as a context overflow.

The actual error from Anthropic is:

FailoverError: LLM request rejected: You have reached your specified API usage limits. You will regain access on 2026-03-01 at 00:00 UTC. (rate_limit)

The isContextOverflowError() check in errors.js correctly does NOT match this error. But somewhere in the delivery pipeline, the FailoverError gets mapped to the generic "Context overflow" message.

Relevant Source Files

  • dist/agents/pi-embedded-helpers/errors.js (lines 247-249, 283-285) — isContextOverflowError + formatting
  • dist/agents/pi-embedded-runner/run.js (line 315) — context overflow return
  • dist/auto-reply/reply/agent-runner-execution.js (line 446) — outer catch
  • dist/agents/model-fallback.js (line 214) — FailoverError throw

Environment

  • OpenClaw version: 2026.1.29
  • Node: v25.5.0
  • macOS Darwin 24.6.0
  • Models: anthropic/claude-haiku-4-5-20251001 (primary), anthropic/claude-3-5-haiku-20241022 (fallback)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions