feat: set generous request timeouts on LLMModel gateway routes - #168
Merged
Conversation
The ai-gateway controller renders each AIGatewayRoute into an HTTPRoute with a default request timeout of 60s, and the operator never overrode it for LLMModels (only passthrough routes got 120s). CPU inference and long/thinking generations easily exceed 60s, so streams died mid-token and clients saw failed model requests. The only workaround was live- patching each model's AIGatewayRoutes, which reconciliation undid. Expose spec.endpoints.requestTimeout on the LLMModel CRD (Gateway API duration string, default 600s) and stamp it onto the rule of both generated routes. The reconciler's full-spec Update pushes the timeout onto existing AIGatewayRoutes on the next reconcile, so no manual patching or resource recreation is needed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
📄 Docs preview for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The ai-gateway controller translates each model's AIGatewayRoutes into HTTPRoutes with a default
request: 60stimeout, and the operator never overrode it for LLMModels (it sets 120s for passthrough models only). CPU inference and long/thinking generations easily exceed 60s — streams die mid-token and clients see "The agent could not complete the model request". The only workaround was live-patching each model's AIGatewayRoutes withkubectl patch, which the next reconcile or resource recreation undid.Changes
spec.endpoints.requestTimeouton LLMModel — a Gateway API duration string (pattern-validated, e.g.600s,10m) defaulting to600s. Applies to both the external and internal endpoint.BuildRoutingResourcesresolves the timeout (falling back to aDefaultRequestTimeout = "600s"constant for CRs stored before the default existed) and stampstimeouts: {request: <value>}onto the rule of both generated AIGatewayRoutes.make generate manifests) and synced the chart copy atcharts/nebari-llm-serving/crds/llmmodel-crd.yaml.spec.endpointstable inconfiguration.mdx.routing_test.go, plus aruleRequestTimeouthelper.Why no migration is needed
The reconciler's
createOrUpdateUnstructureddoes a full specUpdateagainst existing AIGatewayRoutes, so deploying the new operator re-reconciles every LLMModel and pushes the timeout onto existing routes — and re-asserts it if anything strips it later, which the manual patch couldn't do.Passthrough routes keep their existing hardcoded
120s; the reported failure is specific to locally served (CPU-inference) models. The same field can be extended there later if parity is wanted.Testing
go build ./...go test ./internal/controller/...— all passmake lint(golangci-lint) — 0 issues🤖 Generated with Claude Code