Gemini 3.7 Flash on Agent Platform: clustered 504s at low request volume despite pacing and Priority retries

Hi everyone,

We use Gemini 3.7 Flash on Gemini Enterprise Agent Platform to extract structured JSON from PDF/image reports. We use the global endpoint, Python’s Google Gen AI SDK, low thinking, and high media resolution.

Most requests are fast: successful requests average 6.7 seconds, with a median of 4.7 seconds. However, some encounter repeated 504 DEADLINE_EXCEEDED errors and ultimately fail.

Our traffic is modest, around 500-1000 extraction requests per day Successful requests typically use approximately 6,500 input tokens and 300 output tokens.

We have implemented:

  • A shared pacer spacing provider attempts by at least 500 ms per project/location/model group.
  • Bounded retries with exponential backoff and jitter, including one retry for deadline errors.
  • Priority requested on retries after an initial Standard attempt.
  • A 30-second per-attempt timeout and a 65-second overall workflow deadline, enforced locally as well as through SDK timeout settings.
  • Disabled SDK retries to avoid overlapping retry loops.

We are seeing dozens of deadline errors, more that half recovered after retrying, but a lot still fail with 504s.

These failures tend to cluster with specific timestamps but, as mentioned above, we are pacing and also occur randomly. The overall timeout guard is working; the problem is that both attempts can consume nearly their entire allowance and still fail, while most requests finish within a few seconds.

Is this expected tail latency for this workload? What diagnostics would distinguish capacity/queueing delays from input-specific processing issues? Would requesting Priority from the first attempt, or changing our retry strategy, improve reliability without extending the latency budget substantially?