Skip to content

Feature: Trigger model fallback on context length exceeded #9986

@amirarenco-create

Description

@amirarenco-create

Problem

When the primary model's context limit is exceeded, OpenClaw currently freezes/errors instead of falling back to a configured fallback model.

The agents.defaults.model.fallbacks config exists, but fallback only triggers on API errors (529 overloaded, timeouts, etc.) — not on context overflow.

Use Case

  • Primary: anthropic/claude-opus-4-5 (200k context)
  • Fallback: moonshot/kimi-k2.5 (256k context)

When a conversation exceeds 200k tokens, I'd expect it to automatically try Kimi (which has more headroom) instead of failing.

Expected Behavior

  1. Detect context would exceed primary model's limit
  2. Check if any fallback model has sufficient context
  3. Automatically route to fallback with enough headroom
  4. Log the fallback event

Current Behavior

Session freezes or errors when context exceeds limit. Fallback is never attempted.

Environment

  • OpenClaw: 2026.2.3-1
  • Primary: anthropic/claude-opus-4-5
  • Fallback: moonshot/kimi-k2.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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