[Bug] Provider overload errors (529/rate-limit) should trigger auto-retry with backoff, not silent failure

Author: TrueFurinaCreated Aug 19, 2026Updated Sep 20, 2026
Labelshas-linked-pr

Problem

When the model provider returns a transient error like SystemError: The model provider is temporarily overloaded. Try again later. (ref: d539c377), OpenSquilla shows only a generic "已失败" (Failed) message with no actionable detail. The user doesn't know:

  • Whether to retry immediately or wait
  • Whether the error is transient (provider overload) or permanent (bad API key)
  • How many retries were attempted

Expected behavior

  1. Classify the error: distinguish transient errors (529, 429, 503, timeout) from permanent ones (401, 403, 404).
  2. Auto-retry with exponential backoff for transient errors (e.g., 1s → 2s → 4s → 8s, up to 3 attempts).
  3. Show meaningful feedback: "Provider overloaded — retrying in 2s... (attempt 1/3)" instead of silent failure.
  4. After max retries exhausted: show the full error with the ref code and a "Retry" button.

Current behavior

  • Error is swallowed into a generic "已失败" message.
  • No automatic retry.
  • No distinction between transient and permanent failures.
  • The ref: d539c377 is the only useful info, but it's buried.

Suggested implementation

python
# opensquilla/engine/retry.py
from enum import Enum

class ErrorCategory(Enum):
    TRANSIENT = "transient"   # 429, 529, 503, timeout, connection reset
    PERMANENT = "permanent"   # 401, 403, 404, invalid model

TRANSIENT_KEYWORDS = {"overloaded", "rate limit", "429", "529", "503", "timeout", "temporarily"}

def classify_error(error_message: str) -> ErrorCategory:
    msg_lower = error_message.lower()
    if any(kw in msg_lower for kw in TRANSIENT_KEYWORDS):
        return ErrorCategory.TRANSIENT
    return ErrorCategory.PERMANENT

async def run_with_retry(fn, max_retries=3, base_delay=1.0):
    for attempt in range(max_retries + 1):
        try:
            return await fn()
        except Exception as e:
            category = classify_error(str(e))
            if category == ErrorCategory.PERMANENT or attempt == max_retries:
                raise
            delay = base_delay * (2 ** attempt)
            # Emit progress: "Provider overloaded — retrying in {delay}s... (attempt {n}/{max})"
            await asyncio.sleep(delay)

User-visible feedback (Web UI)

⚠️ Provider overloaded — retrying in 2s... (attempt 1/3)

After exhaustion:

❌ Failed after 3 retries: The model provider is temporarily overloaded. (ref: d539c377)
[Retry] [Copy error]

Benefits

  • Transient errors self-heal without user intervention.
  • Users understand what went wrong and what to do.
  • Reduces support burden for common provider-side issues.

Environment

  • Component: src/opensquilla/engine/turn.py (error handling), src/opensquilla/gateway/static/js/views/chat.js (UI feedback)
  • Related: src/opensquilla/gateway/rpc.py (error propagation)