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:
cabana8471
2026-01-30 21:41:01 +01:00
parent f018b4c1d8
commit 88c695259f
3 changed files with 14 additions and 2 deletions

View File

@@ -53,8 +53,12 @@ class TestParseRetryAfter(unittest.TestCase):
def test_minutes_not_supported(self):
"""Test that minutes are not parsed (by design)."""
# We only support seconds to avoid complexity
# These patterns should NOT match when followed by minute/hour units
assert parse_retry_after("wait 5 minutes") is None
assert parse_retry_after("try again in 2 minutes") is None
assert parse_retry_after("retry after 5 minutes") is None
assert parse_retry_after("retry after 1 hour") is None
assert parse_retry_after("try again in 30 min") is None
class TestIsRateLimitError(unittest.TestCase):