fix(llm): cap retry-after delays#1351
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 addresses a potential issue where LLM providers could return excessively large Highlights
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 a cap on Retry-After delays from LLM providers to prevent excessively long sleep periods. A new function cap_retry_after is added in src/llm/retry.rs along with a MAX_RETRY_AFTER_SECS constant, and this is applied consistently across anthropic_oauth.rs, nearai_chat.rs, and workspace/embeddings.rs where Retry-After headers are parsed. The tests have also been updated to verify this new capping behavior. The changes are well-implemented and address the issue described. I have one suggestion to improve the robustness of the cap_retry_after function.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be863db005
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
henrypark133
left a comment
There was a problem hiding this comment.
Review: Cap retry-after delays to prevent unbounded sleep
Solid defensive fix. A malicious or malformed Retry-After header could previously cause effectively unbounded sleep — now capped at 3600s.
Positives:
cap_retry_after()centralized insrc/llm/retry.rswith clear doc comment- Applied consistently across all 4 parsing sites (anthropic_oauth, nearai_chat, OpenAI embeddings, NearAI embeddings)
- Gemini's suggestion to use
duration.min()instead ofDuration::from_secs(duration.as_secs().min(...))was a good catch — preserves sub-second precision - Tests cover both edge cases (u64::MAX and 0)
No missed sites, no security concerns. LGTM.
* fix(llm): cap retry-after delays * Update src/llm/retry.rs Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* fix(llm): cap retry-after delays * Update src/llm/retry.rs Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Clamps absurd Retry-After values to avoid effectively unbounded sleeps.
Fixes #1287.