Skip to content

Anthropic 'Internal server error' (api_error) doesn't trigger model fallback #23193

@jarvis-lane

Description

@jarvis-lane

Bug

When Anthropic returns a 500 with {"type":"error","error":{"type":"api_error","message":"Internal server error"}}, the fallover mechanism doesn't trigger even though fallbacks are configured.

Root Cause

classifyFailoverReason checks error patterns but none match this error:

  • isTransientHttpError — requires raw string to start with a numeric HTTP status (/^(?:http\s*)?(\d{3})/). Anthropic's JSON payload doesn't match.
  • isOverloadedErrorMessage — checks for overloaded_error, overloaded, service unavailable, high demand. api_error / Internal server error doesn't match any.

Expected Behavior

"Internal server error" and "type": "api_error" should be classified as transient/overloaded errors and trigger the configured fallback chain.

Suggested Fix

Add to ERROR_PATTERNS.overloaded:

"internal server error",
/"type"\s*:\s*"api_error"/i,

Or add a dedicated check in classifyFailoverReason for JSON-wrapped API errors that extracts the HTTP-equivalent status.

Config

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-opus-4-6",
        "fallbacks": ["anthropic/claude-sonnet-4-6", "openai/gpt-5.2"]
      }
    }
  }
}

Impact

4 consecutive API 500 errors killed an agent session with zero useful output. Fallbacks were never attempted. Discovered in production with openclaw agent CLI spawned sessions.

Version

OpenClaw 2026.2.21-2 (35a57bc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions