Skip to content

feat: Auto-detect rate limits and wait for reset #82

Open

Description

@Ibramadi75

Problem

When running Ralph in a loop (ralph.sh --tool claude), hitting the Claude Code usage limit causes the loop to either:

  • Exit completely (when using /ralph-loop skill inside Claude Code)
  • Continue with empty/failed iterations until MAX_ITERATIONS is reached

There's no way to gracefully pause and resume when quota resets.

Solution

Detect rate limit errors in Claude's output and automatically sleep until the quota resets.

Error message format

Claude usage limit reached. Your limit will reset at 7pm (Asia/Tokyo).

Implementation

  1. Parse the output for rate limit patterns (usage limit reached, rate limit, quota exceeded)
  2. Extract reset time and timezone from the message
  3. Calculate seconds until reset
  4. Sleep and resume the same iteration (don't count as failed)
  5. Fallback to 5-hour wait if parsing fails

Code structure

  • lib/rate-limit.sh - Extracted functions for rate limit handling
  • ralph.sh - Sources the lib and uses handle_rate_limit() in main loop

References

Activity

  1. merahul22 commented on Apr 15, 2026

    @merahul22

    check #147 i have implemented same

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions