Menu

The retry loop in our LLM gateway: what a 5xx does next
📰

The retry loop in our LLM gateway: what a 5xx does next

DEV Community: api·半年游·12 days ago
#2W4pKrod
#devtoapi#devto#dev#retry#status
Long article (857 words) — no AI summary yet.
Reading 0:00
15s threshold

The retry loop in our LLM gateway: what a 5xx does next

“Retry on 5xx” sounds like a complete rule. In a gateway, it is only one part of the decision. A request can be pinned to one channel, marked non-retryable by an adapter, blocked by a channel-affinity rule, or out of retry budget before its HTTP status is considered.

I traced this path in the Go relay behind an OpenAI-compatible gateway and ran the status-range tests. The detail that changed my reading of the code was the default retry limit: it is zero. With that value, an ordinary upstream 503 gets one attempt. A status can belong to a retryable range while the request still has no budget to retry.

This is a report on the checked-in implementation and local tests, not a comparison of provider uptime or rate limits.

The counter counts retries, not total requests

The relay initializes its retry counter at zero and loops while the counter is less than or equal to the configured limit. So a limit of zero means one total attempt.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.