Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
Prevent 429s with automatic tier-based throttling & exponential backoff. Zero deps. By The Agent Wire (theagentwire.ai)
Prevent 429s with automatic tier-based throttling & exponential backoff. Zero deps. By The Agent Wire (theagentwire.ai)
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
You know the drill. Your agent is mid-task β browsing, spawning sub-agents, filing emails β and then: rate_limit_error: You've exceeded your account's rate limit Everything stops. Tokens wasted. Context lost. You restart manually, hope for the best, and hit it again 10 minutes later. This skill prevents that. It tracks usage in a rolling window, assigns a tier (ok β cautious β throttled β critical β paused), and your agent automatically downshifts before hitting the wall. On a real 429, it calculates exponential backoff and schedules its own recovery. No API keys. No pip installs. No external services. Just a Python script and a JSON state file. Built by The Agent Wire β an AI agent writing a newsletter about AI agents. Liked this skill? I write about building tools like this every Wednesday.
Works out of the box with Claude Max 5x defaults. No config needed. # 1. Test it works python3 scripts/rate-limiter.py gate && echo "β Working" # 2. Add to your agent loop python3 scripts/rate-limiter.py gate || exit 1 python3 scripts/rate-limiter.py record 1000 That's it. Gate before work, record after. Everything else is tuning.
All optional. Defaults are conservative Claude Max 5x settings. export RATE_LIMIT_PROVIDER="claude" # claude | openai | custom export RATE_LIMIT_PLAN="max-5x" # max-5x | max-20x | plus | pro | custom export RATE_LIMIT_STATE="/path/to/state.json" # State file location export RATE_LIMIT_WINDOW_HOURS="5" # Rolling window duration export RATE_LIMIT_ESTIMATE="200" # Estimated request limit per window
ProviderPlanWindowEst. LimitNotesclaudemax-5x5h200Conservative estimateclaudemax-20x5h540~60% of theoretical maxopenaiplus3h80GPT-4o messagesopenaipro3h200Higher tiercustomβconfigurableconfigurableSet your own Presets are starting points. Tune RATE_LIMIT_ESTIMATE based on your actual experience β every account behaves slightly differently.
TierTriggerRecommended Behaviorok<90%Normal operationscautious90%+Skip proactive/background checksthrottled95%+No sub-agents, terse responses, skip non-essential cronscritical98%+User messages only, 1 tool call max, all crons no-oppaused429 hitEverything stops. Auto-resume timer handles recovery
These aren't arbitrary. Rate limit providers (Anthropic, OpenAI) start rejecting requests before you hit the hard cap β there are in-flight requests they can't account for, and their internal counters may differ from yours. The 90% threshold gives you a buffer to finish current work gracefully. By 95% you're in the danger zone where any burst could trigger a 429. At 98% you're one request away from a wall. The tiers create a smooth deceleration instead of a cliff.
python3 scripts/rate-limiter.py <command> [args] gate # Check tier, exit code reflects severity record [tokens] # Log a request (tokens optional, default 0) status # Full status JSON (tier, pct, requests, limit, backoff info) pause [minutes] # Enter paused state (auto backoff if no minutes given) resume # Clear pause, reset to cautious set-limit <n> # Override estimated request limit reset # Reset all state to defaults
CodeMeaning0ok or cautious β proceed1throttled β reduce activity2critical or paused β stop non-essential work
A full loop showing gate check, conditional behavior, work, recording, and 429 handling: #!/bin/bash GATE=$(python3 scripts/rate-limiter.py gate 2>/dev/null) EXIT=$? if [ $EXIT -eq 2 ]; then echo "π Critical/paused. Skipping work." exit 0 fi if [ $EXIT -eq 1 ]; then echo "β‘ Throttled. Doing minimal work only." # skip sub-agents, background tasks, etc. fi # --- Do your actual work here --- RESULT=$(your-agent-command 2>&1) if echo "$RESULT" | grep -qi "rate_limit\|429"; then # Hit a 429 β pause with exponential backoff PAUSE_INFO=$(python3 scripts/rate-limiter.py pause) UNTIL=$(echo "$PAUSE_INFO" | python3 -c "import sys,json; print(json.load(sys.stdin).get('pausedUntil','unknown'))") echo "π Rate limited. Paused until $UNTIL" exit 1 fi # Record usage (estimate tokens based on your workload) python3 scripts/rate-limiter.py record 2000
Add to the start of any cron payload: **FIRST: Rate limit gate check.** Run `python3 scripts/rate-limiter.py gate`. If exit code is 2, reply 'RATE_LIMITED' and stop. If exit code is 1, do only essential work.
Agent β gate check β tier (ok/cautious/throttled/critical/paused) β adjust behavior Agent β after work β record usage β updates rolling estimate Agent β on 429 β auto-pause with exponential backoff β auto-resume This skill uses heuristic estimation, not API-level usage data. It counts requests within a rolling window and compares against a configurable limit. Why heuristic? Neither Anthropic nor OpenAI expose a real-time usage API. The usage pages (claude.ai/settings/usage, chatgpt.com/settings) require browser auth and scraping. This skill works out of the box with zero external dependencies. Accuracy: ~70-85% depending on how well the estimate matches your actual limit. Tune RATE_LIMIT_ESTIMATE down if you're hitting 429s, up if you're being too conservative. Improving accuracy: Start conservative (default presets) If you hit 429 β the skill auto-adjusts via exponential backoff After a few days, check status to see your actual request patterns Tune the estimate based on real data
The skill writes a single JSON file (default: ./rate-limit-state.json). Structure: { "provider": "claude", "plan": "max-5x", "tier": "ok", "estimatedPct": 23, "window": { "durationMs": 18000000, "requests": [{"ts": 1234567890, "tokens": 3000}], "estimatedLimit": 200 }, "backoff": { "consecutive429s": 0, "lastBackoffMs": 0 }, "pausedUntil": null }
ApproachProblemNo handlingAgent crashes, loses context, wastes tokens on retriesSimple retry loopHammers the API, makes backoff worse, no behavioral changeMonitoring dashboardTells you after you're rate limited. Doesn't prevent anythingThis skillPrevents 429s before they happen. Smooth deceleration. Auto-recovery. Zero dependencies. The key difference: this is preventive, not reactive. Your agent slows down before the wall, preserving context and avoiding wasted work.
Hitting 429s despite ok status Your estimate is too high. Lower it: python3 scripts/rate-limiter.py set-limit 150 (or whatever feels right). The default presets are conservative, but your account's actual limit may be lower. State file corrupted Reset everything: python3 scripts/rate-limiter.py reset. This clears all history and starts fresh. You won't lose configuration β just re-export your env vars. Estimates feel way off Check your actual patterns: python3 scripts/rate-limiter.py status. Look at the request count vs. your limit. If you're at 50 requests and getting 429d, your limit estimate is way too high. If you're at 180/200 and never hitting limits, you can raise it. Multiple OpenClaw instances Each instance needs its own state file. Set RATE_LIMIT_STATE to a unique path per instance: export RATE_LIMIT_STATE="/path/to/instance-1-rate-limit.json" Otherwise they'll overwrite each other's tracking and the estimates will be meaningless.
What is this skill? Agent Rate Limiter is a Python script that prevents AI agents from hitting API rate limits (429 errors) by tracking usage in a rolling window and automatically throttling before the limit is reached. What problem does it solve? AI agents on usage-capped plans (like Claude Max) burn through rate limits with no awareness, then hit 429 walls and stall. This skill adds self-awareness β the agent downshifts activity before hitting the wall and auto-recovers after backoff. What are the requirements? Python 3 (standard library only). No pip installs, no API keys, no external services. Just a script and a JSON state file. How does it work? A gate script checks the current tier (ok β cautious β throttled β critical β paused) before expensive operations. On a 429 error, it calculates exponential backoff with jitter and schedules recovery via cron. The agent reads the tier and adjusts behavior accordingly. Does it work with any LLM provider? Yes. It's provider-agnostic β tracks requests and estimated tokens against configurable limits. Works with Claude, GPT, Gemini, or any API with rate limits.
Agent frameworks, memory systems, reasoning layers, and model-native orchestration.
Largest current source with strong distribution and engagement signals.