fix(codex): Treat Codex capacity errors as retryable#2346
fix(codex): Treat Codex capacity errors as retryable#2346luispater merged 1 commit intorouter-for-me:devfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of Codex API interactions by intelligently handling capacity-related errors. Previously, these errors might not have been automatically retried, leading to failed operations. By reclassifying "model is at capacity" messages as retryable 429 status codes, the system can now automatically reattempt requests, improving reliability and user experience when the Codex model experiences temporary load. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces logic to identify Codex model capacity errors and treat them as retryable http.StatusTooManyRequests (429) errors, even if the original status code was different. A new function isCodexModelCapacityError was added to detect these specific error messages, and newCodexStatusErr was updated to use this. A new test case was also added to verify this behavior. The review suggests simplifying the strings.Contains checks in isCodexModelCapacityError for better robustness and conciseness.
| if strings.Contains(lower, "selected model is at capacity") || | ||
| strings.Contains(lower, "model is at capacity. please try a different model") { | ||
| return true | ||
| } |
There was a problem hiding this comment.
The two strings.Contains checks for capacity errors can be simplified. Both of the error messages you're checking for contain the substring "model is at capacity". You can combine them into a single, more robust check. This will make the code simpler and more resilient to small variations in the error message from the API.
if strings.Contains(lower, "model is at capacity") {
return true
}
luispater
left a comment
There was a problem hiding this comment.
Summary:
This PR is focused and aligned with its stated intent: treat Codex “model at capacity” failures as retryable by mapping them to 429, while preserving existing retry-after parsing for true usage-limit responses.
Key findings:
- Blocking: none.
- Non-blocking: capacity detection is text-based and status-agnostic; adding a status guard (e.g., only remap on 400/429) would reduce false-positive risk.
Test plan:
- Verified the PR adds a regression test:
TestNewCodexStatusErrTreatsCapacityAsRetryableRateLimit
- Existing retry-after behavior remains covered by
TestParseCodexRetryAfter.
Follow-ups:
- Optional hardening: add a negative test ensuring non-capacity errors containing similar text are not remapped unintentionally.
This is an automated Codex review result and still requires manual verification by a human reviewer.
Summary
Testing