Skip to content

fix(ai): one retry layer for a gateway call - #5973

Merged
dan-petty merged 2 commits into
mainfrom
fix/5965-one-retry-layer
Nov 16, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/5965-one-retry-layer

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The LLM gateway owns the retries and the fallbacks of a model call. LiteLLM 1.103.11 raises a 408 error inside a stream (an OpenRouter timeout) with no retry and no fallback, and the client sent a pydantic-ai call up to 9 times for other failures.

  • A pydantic-ai call to a gateway chat group goes through GatewayCallModel, a pydantic-ai FallbackModel of the same model: at most ai.max_retries + 1 sends, only after a failed connect or a stream that failed before its first event. The SDK and the transport make no retries.
  • LLMClient with provider gateway sends a call again only after a failed connect.
  • New setting ai.request_timeout_seconds (1200 s): one deadline over all sends of a call. The router timeout goes from 1500 s to 900 s, below each call deadline. The settings refuse an implement call deadline above the step limit.
  • The unused StreamRetryModel is deleted.

Closes #5965

Change: openspec/changes/archive/2026-11-16-5965-one-retry-layer/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/ai AI review pipeline, personas, prompts, LLM client, or RAG labels Nov 16, 2026
The gateway owns the retries and the fallbacks of a call. A pydantic-ai call to a
gateway chat group goes through GatewayCallModel, which sends it at most
ai.max_retries + 1 times, and only when it did not reach the gateway or when its
stream failed before its first event. The SDK and the HTTP transport of the
gateway chat client retry nothing. The direct client resends only a failed
connect to the gateway. ai.request_timeout_seconds sets one deadline per call,
and the router timeout (900 s) now ends before it.
@dan-petty
dan-petty force-pushed the fix/5965-one-retry-layer branch from bf0d338 to e6593c1 Compare November 16, 2026 13:33
@dan-petty
dan-petty marked this pull request as ready for review November 16, 2026 13:41
@dan-petty
dan-petty merged commit 87ebf9f into main Nov 16, 2026
25 checks passed
@dan-petty
dan-petty deleted the fix/5965-one-retry-layer branch November 16, 2026 13:42
dan-petty-release Bot added a commit that referenced this pull request Nov 16, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.164.0](v0.163.0...v0.164.0)
(2026-11-16)


### Features

* **roadmap:** Verify a claimed missing check in a helper
([#5868](#5868))
([e6cf731](e6cf731))


### Bug Fixes

* **ai:** one retry layer for a gateway call
([#5973](#5973))
([87ebf9f](87ebf9f)),
closes [#5965](#5965)
* **roadmap:** Refuse a class claim the staged source lacks
([#5834](#5834))
([b12cca7](b12cca7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/ai AI review pipeline, personas, prompts, LLM client, or RAG type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ai): one retry layer for a gateway call

1 participant