Skip to content

Feature: Circuit breaker for model rate limiting in Ralph #450

Closed

Description

@tamirdresher

Problem

When running multiple Ralph instances, Copilot model rate limits can cause cascading failures. All Ralphs fail simultaneously when the preferred model hits its quota.

Proposed Solution

Add a circuit breaker pattern that automatically falls back to free-tier models when rate limited, then recovers:

  • CLOSED (normal): Use preferred model (configurable, default claude-sonnet-4.6)
  • OPEN (rate limited): Fall back through model chain: gpt-5.4-mini → gpt-5-mini → gpt-4.1
  • HALF-OPEN (testing): After cooldown, try preferred model. 2 consecutive successes → close circuit.

State tracked in .squad/ralph-circuit-breaker.json with metrics (total fallbacks, recoveries).

Why this matters

  • Free-tier models (gpt-4.1, gpt-5-mini, gpt-5.4-mini) have 0x multiplier — unlimited usage
  • Premium models (Sonnet=1x, Opus=10x, GPT-5.4=50x) burn quota fast with multiple Ralphs
  • Without fallback, rate limits cause complete Ralph outage
  • With circuit breaker, Ralph degrades gracefully and self-heals

Implementation

This follows the classic circuit breaker pattern (Netflix Hystrix / Polly / Resilience4j) applied to model selection. The fallback chain acts like a CDN tier — always prefer premium, degrade to free tier when unavailable, recover when possible.

Real-world validation

Tested with 8 concurrent Ralphs across 8 repos. Rate limit hit after ~2 hours of intensive polling. Circuit breaker kicked in, Ralphs continued on gpt-5.4-mini, recovered to preferred model after 10-minute cooldown.

Activity

  1. added a commit that references this issue on Mar 18, 2026
    f466cca
  2. github-actions commented on Mar 18, 2026

    @github-actions
    Contributor

    🏗️ Squad Triage — Flight (Lead)

    Issue: #450 — Feature: Circuit breaker for model rate limiting in Ralph
    Assigned to: FIDO (Quality Owner)
    Reason: Issue relates to testing/quality work

    @copilot evaluation: 🔴 Not suitable — issue involves work outside the coding agent's capability profile.

    Team roster:

    • Flight (Lead) → label: squad:flight
    • Procedures (Prompt Engineer) → label: squad:procedures
    • EECOM (Core Dev) → label: squad:eecom
    • FIDO (Quality Owner) → label: squad:fido
    • PAO (DevRel) → label: squad:pao
    • CAPCOM (SDK Expert) → label: squad:capcom
    • CONTROL (TypeScript Engineer) → label: squad:control
    • Surgeon (Release Manager) → label: squad:surgeon
    • Booster (CI/CD Engineer) → label: squad:booster
    • GNC (Node.js Runtime) → label: squad:gnc
    • Network (Distribution) → label: squad:network
    • RETRO (Security) → label: squad:retro
    • INCO (CLI UX & Visual Design) → label: squad:inco
    • GUIDO (VS Code Extension) → label: squad:guido
    • Telemetry (Aspire & Observability) → label: squad:telemetry
    • VOX (REPL & Interactive Shell) → label: squad:vox
    • DSKY (TUI Engineer) → label: squad:dsky
    • Sims (E2E Test Engineer) → label: squad:sims
    • Handbook (SDK Usability) → label: squad:handbook
    • Ralph (Work Monitor) → label: squad:ralph
    • @copilot (Coding Agent) → label: squad:copilot

    To reassign, remove the current squad:* label and add the correct one.

  3. github-actions commented on Mar 18, 2026

    @github-actions
    Contributor

    📋 Assigned to EECOM (Core Dev)

    Issue: #450 — Feature: Circuit breaker for model rate limiting in Ralph

    EECOM will pick this up in the next Copilot session.

    For Copilot coding agent: If enabled, this issue will be worked automatically.
    Otherwise, start a Copilot session and say:
    EECOM, work on issue #450

  4. added a commit that references this issue on Mar 20, 2026
    336a0a0
  5. added a commit that references this issue on Mar 20, 2026
    04a44fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions