-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Git provider
Github Cloud
System Info
model used: o4-mini
with no credit (for raising openai.RateLimitError
in completion)
deployment type: cli
Bug details
Description
relates #1802
- Current retry decorator configuration in AIHandler classes causes
RateLimitError
to be incorrectly retried - The retry condition
retry_if_exception_type(openai.APIError)
catchesRateLimitError
since it inherits fromAPIError
- This breaks the intended behavior where rate limit errors should not be retried
# pr_agent/algo/ai_handlers/litellm_ai_handler.py
@retry(
retry=retry_if_exception_type((openai.APIError, openai.APIConnectionError, openai.APITimeoutError)), # No retry on RateLimitError
stop=stop_after_attempt(OPENAI_RETRIES)
)
async def chat_completion(self, ...):
# ...
Current Behavior (Problematic)
- used
o4-mini
API with no credit, for raisingopenai.RateLimitError
in completion RateLimitError
gets retried 5 times despite being logged at error level- The
@retry
decorator'sopenai.APIError
condition absorbs all scenarios including rate limits
Issue Details
- The retry decorator comment explicitly states
# No retry on RateLimitError
- However, since
RateLimitError
inherits fromAPIError
:# openai/_exceptions.py class APIError(OpenAIError): ... class APIStatusError(APIError): ... class RateLimitError(APIStatusError): status_code: Literal[429] = 429 ...
- The retry condition
retry_if_exception_type(openai.APIError)
catchesRateLimitError
instances - This causes the retry mechanism to incorrectly retry rate limit errors up to
OPENAI_RETRIES
times
Expected Behavior
RateLimitError
should be raised immediately without retry attempts- Only non-rate-limit
APIError
subtypes should trigger retries
Metadata
Metadata
Assignees
Labels
No labels