Skip to content

Rate limit detection missing 'too many tokens per day' pattern (AWS Bedrock) #38822

@felipematos

Description

@felipematos

Problem

AWS Bedrock models return a specific error message when daily token limits are exceeded:

Too many tokens per day

This error is not recognized by OpenClaw as a rate-limit condition, causing the primary model to keep failing without properly triggering fallback.

Root Cause

The rate limit detection regex in OpenClaw only matches:

/(rate[_ ]limit|too many requests|429|resource has been exhausted|cloudflare)/i

Missing patterns:

  • too many tokens per day (AWS Bedrock specific)
  • tokens per day
  • quota exceeded (some providers)

Impact

  • Primary model keeps failing repeatedly
  • Fallback chain doesn't trigger properly
  • System appears "stuck" trying the same broken model
  • No circuit breaker for repeated failures

Suggested Fix

Add missing patterns to the rate limit detection:

// gateway-cli-CuFEx2ht.js (line ~5780)
rate_limit: /(rate[_ ]limit|too many requests|429|resource has been exhausted|cloudflare|too many tokens|tokens per day)/i,

// api-key-rotation-5wHpygo9.js
if (lower.includes("too many tokens")) return true;
if (lower.includes("tokens per day")) return true;

Workaround Applied (local)

We've patched the compiled files locally:

  • Added too many tokens and tokens per day to the regex
  • Gateway restarted successfully

Environment

  • OpenClaw version: 2026.3.2
  • Platform: Ubuntu 22.04
  • Node.js: v25.8.0

Thank you for considering this fix! 🦞

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