MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / RetryConfig

Class RetryConfig

mini_agent/retry.py:23–61  ·  view source on GitHub ↗

Retry configuration class

Source from the content-addressed store, hash-verified

21
22
23class RetryConfig:
24 """Retry configuration class"""
25
26 def __init__(
27 self,
28 enabled: bool = True,
29 max_retries: int = 3,
30 initial_delay: float = 1.0,
31 max_delay: float = 60.0,
32 exponential_base: float = 2.0,
33 retryable_exceptions: tuple[Type[Exception], ...] = (Exception,),
34 ):
35 """
36 Args:
37 enabled: Whether to enable retry mechanism
38 max_retries: Maximum number of retries
39 initial_delay: Initial delay time (seconds)
40 max_delay: Maximum delay time (seconds)
41 exponential_base: Exponential backoff base
42 retryable_exceptions: Tuple of retryable exception types
43 """
44 self.enabled = enabled
45 self.max_retries = max_retries
46 self.initial_delay = initial_delay
47 self.max_delay = max_delay
48 self.exponential_base = exponential_base
49 self.retryable_exceptions = retryable_exceptions
50
51 def calculate_delay(self, attempt: int) -> float:
52 """Calculate delay time (exponential backoff)
53
54 Args:
55 attempt: Current attempt number (starting from 0)
56
57 Returns:
58 Delay time (seconds)
59 """
60 delay = self.initial_delay * (self.exponential_base**attempt)
61 return min(delay, self.max_delay)
62
63
64class RetryExhaustedError(Exception):

Callers 5

async_retryFunction · 0.70
__init__Method · 0.50
__init__Method · 0.50

Calls

no outgoing calls

Tested by 2