Repository navigation
fix(server): respect upstream Retry-After during retries - #723
Yezheng Li (yezhengli-Mr9) wants to merge 1 commit into
Conversation
|
Yezheng Li (@yezhengli-Mr9) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change to honor upstream Retry-After headers.
No open issues 🎉
What changed in this PR
Updates gateway retries to respect upstream Retry-After headers, addressing #722 while preserving existing jittered backoff and cancellation behavior.
Changes:
- Handles delay-seconds and HTTP dates as minimum retry delays.
- Logs invalid headers and retains existing backoff.
- Adds eight regression cases covering valid, missing, invalid, and expired headers.
| File | Description |
|---|---|
tests/server/test_proxy_disconnect.py |
Adds parametrized retry-delay regression coverage. |
agentlightning/server/proxy.py |
Passes and parses Retry-After when scheduling retries. |
Review effort: Balanced
Counterpart tools, related PRs, and research
Statuses verified on 2026-12-04 (Pacific time). Counterparts are comparisons, not added dependencies.
Sample and measured improvement
Retry-After: 2; fixed jitter multiplier 1.0.Fri, 04 Dec 2026 12:00:03 GMT.{"choices":[{"message":{"content":"patch ready"}}]}.Evidence: Windows / Python 3.12.16, actual gateway retry functions, real loopback HTTP sockets, three alternating baseline/patched pairs per condition. Baseline is
6d7f272806d0f210f6c98b32081adeccdeb343f7; jitter is fixed to 1.0 for both arms to isolate scheduling. These are constructed overload fixtures, not model inference, token savings, training, coding-task score or a research benchmark.Summary
Fixes #722.
The gateway currently retries overloaded model servers without observing their cooldown headers. Pass
Retry-Afterfrom a retryable HTTP response into the existing sleep, preservingmax(jittered_backoff, server_delay).Executed validation
Reproduce tests
From a checkout with the dev dependencies installed:
The new tests need no model, GPU, API key or Docker daemon. They exercise actual HTTPX request/response handling with fixed clock/backoff and inspect the awaited delay. The timing experiment uses a separate real loopback HTTP server; its exact standalone runner is included below.
Review checklist
This is an engineering reliability contribution; no novelty or inference-efficiency claim is made.
Standalone paired HTTP experiment runner
Save as
retry_after_experiment.pyoutside the repository and run in the installed development environment:Publication and CI status
5ed180ed10c3ef7c4da7f55d2f8addd39d8b952e. The only difference from the upstream feature head is the one-line push trigger in the fork's workflow; production source and tests are identical. No fork-only PR was created or merged.action_required, waiting for maintainer approval; not claimed green. CLA processing was pending at publication.