genai : fixed respect retry_delay from Gemini 429 ResourceExhausted error in retry logic #946
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
This PR fixes the retry logic in the LangChain Google integration to respect the
retry_delay
field returned by the Gemini API inResourceExhausted
(429) errors. Previously, the retry mechanism ignored the server-suggested delay, causing premature retries and quota issues. The fix introduces a custom wait strategy that uses the server-provided delay when available and falls back to exponential backoff otherwise. This aligns client retry behavior with Gemini’s rate limiting guidance, improving reliability and reducing quota exhaustion errors.Relevant issues
Type
🐛 Bug Fix
Changes (optional)
wait_with_server_retry_delay
custom wait strategy class_create_retry_decorator
to use this custom wait handler