Skip to content

feat(ai): enforce gateway first-token timeout (#6000) - #7198

Merged
dan-petty merged 1 commit into
mainfrom
feat/6000-gateway-first-token-timeout
Nov 25, 2026
Merged

dan-petty merged 1 commit into
mainfrom
feat/6000-gateway-first-token-timeout

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Enforce a first-content-event deadline (ai.first_token_timeout_seconds, default 60 s) on streamed LLM gateway calls using pydantic_ai's native first_event_timeout so stalled keep-alive streams close and retry cleanly up to ai.max_retries times.

  • Add DEFAULT_AI_FIRST_TOKEN_TIMEOUT_SECONDS and AIConfig.first_token_timeout_seconds with a validator keeping it below ai.request_timeout_seconds, and regenerate docs/CONFIGURATION.md and docs/ENV_VARS.md.
  • Wire first_token_timeout through GatewayCallModel and _gateway_call_model, override _start_request_deadline to keep outer request_timeout across sends, and retry ModelRequestTimeout(setting="first_event_timeout") in failed_before_first_event.
  • Report timed_out=True in model_call_error for ModelRequestTimeout.

Closes #6000
Change: openspec/changes/archive/2026-11-25-6000-gateway-first-token-timeout/

@dan-petty dan-petty added scope/ai AI review pipeline, personas, prompts, LLM client, or RAG type/feature Type feature: a new function labels Nov 25, 2026
@dan-petty
dan-petty force-pushed the feat/6000-gateway-first-token-timeout branch from 501c64a to 06bdcf4 Compare November 25, 2026 16:26
@dan-petty
dan-petty marked this pull request as ready for review November 25, 2026 16:51
@dan-petty
dan-petty merged commit af6958c into main Nov 25, 2026
28 checks passed
@dan-petty
dan-petty deleted the feat/6000-gateway-first-token-timeout branch November 25, 2026 16:53
dan-petty-release Bot added a commit that referenced this pull request Nov 25, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.220.0](v0.219.0...v0.220.0)
(2026-11-25)


### Features

* **ai:** enforce gateway first-token timeout
([#6000](#6000))
([#7198](#7198))
([af6958c](af6958c))
* **github:** request dan-petty and automerge all PRs
([#7195](#7195))
([681c6c3](681c6c3))


### Bug Fixes

* **ci:** check ADDED/MODIFIED requirement length
([#5378](#5378))
([#7194](#7194))
([4712043](4712043))
* **ci:** run single-module narrowed tests serially
([#5612](#5612))
([#7196](#7196))
([7b3289c](7b3289c))
* **config:** refuse typesafe/jev-router as decision model
([#6361](#6361))
([#7197](#7197))
([46777dd](46777dd))
* **terraform:** exit non-zero on drift or failed check
([#7193](#7193))
([f24cfc2](f24cfc2)),
closes [#5319](#5319)

---
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/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ai): End a gateway stream that gives no first token

1 participant