[Bug] Bound standalone fallback retries by the response deadline #7796
Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.
<!-- community-lifecycle:workgroup-review -->
Reviewer: @1fanwang, Data Plane & Networking Lead
To speed up the review, mention them in a reply. No response? Ask another Lead: @abhinav-m22 or @Bevisy.
The fallback deadline now covers the whole retry loop and failed response bodies. Successful streams keep their provider timeouts.
/ci run
<!-- semantic-router-ci-status:v1 -->
Waiting for committer approval — /ci run
Automatic checks passed. Required expensive checks have not run yet; this is not a test failure.
A committer with repository write, maintain or admin permission can start the required checks by commenting:
/ci run
Contributors without that permission do not need to request authorization themselves.
Pending qualification: e2e.standalone, e2e.envoy-ai-gateway, e2e.pii-remote-backend, e2e.masking.
Revision f8089e736bac · CI run, attempt 1
Approval applies to this revision only. New commits require fresh qualification.
1fanwang
Zi-Yi-Ming
<!-- markdownlint-disable -->
Closes #7795
Purpose
The standalone Router applies the fallback budget as an upstream per-try timeout. When provider retries are enabled, the Router can therefore give each request to the backup a fresh timeout, send a retry after the chain deadline, and return a late success. A backup can also use up the chain by flushing a retryable error status and then stalling its error body.
Give each native fallback candidate the earlier of its per-candidate deadline and the overall fallback deadline. Use that deadline for queueing, retries, backoff, and inspection of a failed candidate's response. A timeout during error-body inspection counts the provider's status once for outlier detection. The fallback policy can select another candidate if the chain still has time. Disarm the candidate timer when the Router selects a successful response so the body continues under the existing upstream timeouts.
Owning workgroup is Data Plane & Networking (
wg/data-plane-networking).Test Plan
Run from
src/semantic-routerwith Go 1.25.14 andSR_TEST_MODE=true.Build the standalone Router and repeat the issue's slow-retry, fast-retry, provider-total-timeout, and retries-disabled cases against loopback HTTP backends.
Test Result
Retry-Afterbackoff, a backup that stalls while sending its error body, and a successful SSE stream that delivers its tail and[DONE]after the deadline. The upstream regression also verifies that one failed response counts once for passive outlier detection.golangci-lintreported two existinggovetshadow findings ineval_model_selection.goandprovider_request_adapter_ollama_test.go. Both files match the base revision.---
<details>
<summary>Semantic Router PR Checklist</summary>
[Feature],[Bug],[Docs],[Test],[Research],[Community], or[CI/Build][Router][Docs]; affected modules belong in labels and the PR bodyacceptedissue with exactly one owner: onewg/*label for project work orowner/maintainersfor repository governancegit commit -s</details>
See [CONTRIBUTING.md](../CONTRIBUTING.md) for the full contributor workflow and commit guidance.