sage-recovery-patterns

Implement circuit breakers, rate limiters, and retry policies for LLM API calls in Rust services.

12|1|Updated Jul 15, 2025
One-click install
npx skills add https://github.com/majiayu000/sage --skill sage-recovery-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sage-recovery-patterns
Source: https://github.com/majiayu000/sage/tree/main/.sage/skills/sage-recovery-patterns
Command: npx skills add https://github.com/majiayu000/sage --skill sage-recovery-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Sage recovery patterns provide a structured approach to adding resilience to LLM integrations by combining circuit breakers, rate limiters, and retry policies to prevent cascading failures and improve reliability.

Core Features & Use Cases

  • Circuit Breaker pattern to stop calls when the upstream LLM provider is failing.
  • Rate Limiter to cap traffic and avoid throttling or overload.
  • Retry Policy with backoff to recover from transient errors.
  • Supervisor to manage long-running tasks and restarts.
  • Use Case: Integrate with chat workflows to ensure fallbacks when the API is unresponsive.

Quick Start

Example: wrap an llm_client.chat(request) call with a CircuitBreaker configured to trip after 5 failures, a SlidingWindowRateLimiter for 60 requests per minute, and an exponential Backoff RetryPolicy with max_retries = 5.

Frequently Asked Questions about sage-recovery-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent cascading failures when my LLM API provider goes down?

You can prevent cascading failures by implementing a circuit breaker pattern that trips after a configurable threshold of API failures, stopping traffic to the failing LLM provider and preventing system-wide overload.

What is the best way to handle rate limiting for LLM API requests?

The best way to handle LLM API rate limiting is configuring a SlidingWindowRateLimiter to cap traffic, preventing API throttling and avoiding upstream overload from excessive requests.

How do I configure retry policies with backoff for transient LLM errors?

Configure retry policies with backoff for transient LLM errors by setting an exponential Backoff RetryPolicy with a defined max_retries limit, ensuring automated recovery without overwhelming the API.

Can I integrate fault tolerance patterns into my existing Rust service architecture?

Yes, you can integrate fault tolerance patterns into Rust-based or service-oriented architectures, as these composable resilience components are designed for existing systems requiring stateful supervision and robust error handling.

Do I need a supervisor to manage long-running LLM tasks?

You need a supervisor to manage long-running LLM tasks and handle restarts when the API is unresponsive, ensuring robust error handling and maintaining reliable workflow execution across failures.

When should I not use a circuit breaker for my LLM integration?

Avoid using a circuit breaker for LLM integrations when transient errors are infrequent and the application tolerates minor latency, as tripping the circuit might unnecessarily block valid chat workflow requests.