← Back to Pull requests

[Bug] Bound standalone fallback retries by the response deadline #7796

Open
Zi-Yi-Ming opened this pull request with 328 lines diff across 9 files
View on GitHub
Zi-Yi-Ming Zi-Yi-Ming commented on Dec 01, 2026 12:53 UTC
Author

<!-- 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-router with Go 1.25.14 and SR_TEST_MODE=true.

go test ./pkg/upstream ./pkg/routing/... ./pkg/gateway ./pkg/fallback ./internal/gatewayparity -count=1 -timeout=75s
go test ./pkg/extproc -run 'Test(Fallback|.*Fallback.*|.*DecisionReliability)' -count=1
go test ./internal/gatewayparity -run '^TestNativeFallbackDeadline' -count=5 -timeout=75s
go test -race ./internal/gatewayparity ./pkg/upstream -run 'Test(NativeFallbackDeadline|FallbackDeadline|.*Timeout|.*Retry)' -count=1 -timeout=75s

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

  • The affected package tests, extproc fallback tests, and targeted race run passed. The gateway deadline regressions passed five runs. They cover the budget left after the primary, Retry-After backoff, 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.

  • The original Router returned HTTP 200 and started a third backup call in all three slow-retry runs. The fixed binary returned HTTP 504 with two backup calls in all three. All three fast-retry runs still returned HTTP 200 after three backup attempts. The explicit provider-total-timeout and retries-disabled controls passed in all three runs.

  • golangci-lint reported two existing govet shadow findings in eval_model_selection.go and provider_request_adapter_ollama_test.go. Both files match the base revision.
  • ---
    <details>
    <summary>Semantic Router PR Checklist</summary>

  • PR title begins with exactly one bracketed category, such as [Feature], [Bug], [Docs], [Test], [Research], [Community], or [CI/Build]

  • The title does not stack prefixes such as [Router][Docs]; affected modules belong in labels and the PR body

  • The PR links an accepted issue with exactly one owner: one wg/* label for project work or owner/maintainers for repository governance

  • Commits in this PR are signed off with git commit -s

  • The Purpose, Test Plan, and Test Result sections reflect the actual scope, commands, and blockers for this change
  • </details>

    See [CONTRIBUTING.md](../CONTRIBUTING.md) for the full contributor workflow and commit guidance.

    Diff: 328 lines (+272 / -56) across 9 files Reviewer: 1fanwang Review duration: 117m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.49) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.49 · 328 lines diff across 9 files
    0.49
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.90 · 4 substantive comment(s)
    0.90
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    89%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.347
    Real PR Conversation Timeline
    6 items
    mergify[bot] mergify[bot] commented on Dec 01, 2026 12:56 UTC
    Bot

    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.

  • Queue this pull request once it meets the queue conditions <!-- mergify:queue-control:queue -->
  • github-actions[bot] github-actions[bot] commented on Dec 01, 2026 12:58 UTC
    Bot

    <!-- 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.

    1fanwang 1fanwang approved these changes on Dec 01, 2026 13:35 UTC
    Approved Reviewer

    The fallback deadline now covers the whole retry loop and failed response bodies. Successful streams keep their provider timeouts.

    1fanwang 1fanwang commented on Dec 01, 2026 13:38 UTC
    Contributor

    /ci run

    github-actions[bot] github-actions[bot] commented on Dec 01, 2026 14:43 UTC
    Bot

    <!-- 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.

    Reviewers
    Assignees
    Zi-Yi-Ming Zi-Yi-Ming
    Labels
    risk: low confidence: 89.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.4% (MEDIUM) · Higher = larger blast radius
    49.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.3% · Lower = rushed or shallow review
    89.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.3% · Safe to merge
    5.3%