googleapis / googleapis/python-genai

Retry logic should respect server-provided retryDelay from 429 responses

Aperta
#1,875 6 commenti 2 reazioni 1 assegnatario Rivendicata da @Venkaiahbabuneelam Vedi su GitHub
priority: p3 type: feature request
Lingua principale
Python
Stelle
4k
Fork
1k
Merge medio
2g 12h
PR unite (30g)
41

Descrizione

When a `429 RESOURCE_EXHAUSTED` error is returned, the API response includes a suggested retry delay in `google.rpc.RetryInfo`:

```json
{
"error": {
"code": 429,
"message": "You exceeded your current quota... Please retry in 53.016342224s.",
"status": "RESOURCE_EXHAUSTED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.RetryInfo",
"retryDelay": "53s"
}
]
}
}
```

The SDK ignores this value and uses fixed exponential backoff (~1s, ~2s, ~4s, ~8s, ~17s), wasting all 5 retry attempts in ~33 seconds when the server explicitly says to wait ~53 seconds.

**Proposed solution**

The SDK should parse `retryDelay` from `google.rpc.RetryInfo` in 429 responses and use that value (with optional jitter) instead of fixed exponential backoff. When no `retryDelay` is provided, fall back to exponential backoff.

[Source code](https://github.com/googleapis/python-genai/blob/main/google/genai/_api_client.py#L482-L486)
[Downstream issue](github.com/langchain-ai/langchain-google/issues/945)
[Forum discussion](https://discuss.ai.google.dev/t/429-errors-despite-waiting-after-retrydelay/96899)

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.