feat: implement request retry mechanism for provider requests#8699
feat: implement request retry mechanism for provider requests#8699Soulter wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
retry_provider_request_contexthelper only retries failures in__aenter__and not errors that occur while iterating/using the stream; if the intent is to make streaming calls more robust, consider whether you also want a retry strategy around mid-stream failures or add a brief comment clarifying that only connection/setup errors are retried.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `retry_provider_request_context` helper only retries failures in `__aenter__` and not errors that occur while iterating/using the stream; if the intent is to make streaming calls more robust, consider whether you also want a retry strategy around mid-stream failures or add a brief comment clarifying that only connection/setup errors are retried.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized request retry mechanism using the tenacity library to handle transient errors and rate limits for LLM provider requests. It adds a new request_retry.py module and integrates it into the Anthropic, Gemini, and OpenAI provider sources to retry queries, streams, and model listing requests. Additionally, corresponding unit tests have been added to verify the retry behavior under transient connection failures. I have no feedback to provide as there are no review comments to address.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Modifications / 改动点
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Introduce a shared retry mechanism for transient provider request failures and apply it across major LLM providers.
New Features:
Enhancements:
Tests: