Repository navigation
Gemini 2.5 503 "High Demand" errors - recommended handling strategy? #1742
Replies: 1 comment
Hello @LiveNathan , nice to meet you. #Q1 — Is RetryProperties configurable per-provider? Yes, fully. Each provider has its own @ConfigurationProperties class implementing RetryProperties with its own prefix. For Gemini: The retry policy (SpringAiRetryPolicy) retries on TransientAiException and rate-limit phrases, and skips control-flow signals like ReplanRequestedException. Q2 — Model fallback / circuit-breaker?What exists today: FallbackByNameModelSelectionCriteria / withFirstAvailableLlmOf("gemini-2.5-flash-lite", "gemini-2.5-flash") — this is a static fallback at model-selection time. It picks What does NOT exist: There is no runtime circuit-breaker that promotes to a heavier model on 503/quota errors mid-request. The current retry logic exhausts all attempts against the same Workaround today: You can implement this yourself by wrapping the call in a try/catch and retrying with a different LlmOptions: try { Roadmap: A proper runtime model-escalation path (try lite → on quota exhaustion, escalate to full model) is not currently planned but would be a natural extension of Thank you |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've been hitting frequent
503errors from Google Gemini 2.5 models (gemini-2.5-flash-litein my case, but reports online indicategemini-2.5-flashandgemini-2.5-proare also affected) over the past two days. I'm looking for advice on the best way to handle this within Embabel, and whether any framework-level improvements could help.Environment
gemini-2.5-flash-liteError
The root cause coming from
com.google.genai.errors.ServerException:Full stack trace visible in logs via:
Observed behavior
Embabel's
RetryPropertiesdoes retry on failure (Retry count: 1logged fromc.e.agent.spi.common.RetryProperties), and eventually succeeds - but the tool loop is taking ~47-55 seconds per call as a result:What I've done
I wrote a custom
ResilientLlmExecutorfallback wrapper that catches these errors and retries with exponential backoff (or falls back to an alternate model). It's working, but I'm not sure if this is the right layer to be solving this, or if there's a better hook Embabel provides.application.properties
I have also attempted to tune the retry behavior:
Context: This is a widespread Google-side issue
For what it's worth, this appears to be a persistent infrastructure capacity problem on Google's end - there are many reports across [Google's developer forums](https://discuss.ai.google.dev/t/503-this-model-is-currently-experiencing-high-demand-spikes-in-demand-are-usually-temporary-please-try-again-later/138664) and the [googleapis Python SDK repo](googleapis/python-genai#1373). One particularly concerning finding: Google appears to be [counting failed 503 retries toward the daily rate limit quota](https://www.reddit.com/r/GeminiAI/comments/1ritany/google_is_counting_failed_requests_because_of/), meaning aggressive retry loops can accelerate quota exhaustion.
Questions
RetryPropertiesconfigurable per-provider? I'd like to tune the backoff specifically for the Google GenAI provider (e.g., longer initial delay, exponential backoff, fewer total attempts to avoid quota burn).gemini-2.5-flash-litereturns 503, automatically retry withgemini-2.5-flashbefore giving up.ResilientLlmExecutorapproach (wrapping at theLlmOperationsorChatModellevel) the right place for this, or is there a more idiomatic Embabel extension point?Happy to share the
ResilientLlmExecutorimplementation if useful as a reference or potential contribution.All reactions