mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-02-01 23:13:36 +00:00
fix: address 3 new CodeRabbit review comments
1. agent.py: Reset opposite retry counter when entering rate_limit or error status to prevent mixed events from inflating delays 2. rate_limit_utils.py: Fix parse_retry_after() regex to reject minute/hour units - patterns now require explicit "seconds"/"s" unit or end of string 3. test_rate_limit_utils.py: Add tests for "retry after 5 minutes" and other minute/hour variants to ensure they return None Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,9 +45,13 @@ def parse_retry_after(error_message: str) -> Optional[int]:
|
||||
Returns:
|
||||
Seconds to wait, or None if not parseable.
|
||||
"""
|
||||
# Patterns require explicit "seconds" or "s" unit, OR no unit at all (end of string/sentence)
|
||||
# This prevents matching "30 minutes" or "1 hour" since those have non-seconds units
|
||||
patterns = [
|
||||
r"retry.?after[:\s]+(\d+)\s*(?:seconds?)?",
|
||||
r"try again in\s+(\d+)\s*(?:seconds?|s\b)",
|
||||
r"retry.?after[:\s]+(\d+)\s*(?:seconds?|s\b)", # Requires seconds unit
|
||||
r"retry.?after[:\s]+(\d+)(?:\s*$|\s*[,.])", # Or end of string/sentence
|
||||
r"try again in\s+(\d+)\s*(?:seconds?|s\b)", # Requires seconds unit
|
||||
r"try again in\s+(\d+)(?:\s*$|\s*[,.])", # Or end of string/sentence
|
||||
r"(\d+)\s*seconds?\s*(?:remaining|left|until)",
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user