mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4833] [Engine] /v1/responses sends Retry-After on a GPU-busy 503, as chat and messages do #5203
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5203
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4833
Author: @gdevenyi
Created: 10/31/2026
Status: 🔄 Open
Base:
main← Head:api/responses-retry-after📝 Commits (1)
0113844/v1/responses: send Retry-After on a GpuBusy 503, as chat and messages do📊 Changes
2 files changed (+22 additions, -1 deletions)
View changed files
📝
serve/server.py(+3 -1)📝
serve/test_server.py(+19 -0)📄 Description
Problem and result
When the server refuses to load an unloaded model because the GPU is busy, chat and messages answer 503 with
Retry-After: 15./v1/responsesanswers the same 503 with no header, on stream and non-stream requests. A client then retries too soon and gives up.After this change
/v1/responsessends the header too. In the two scenarios measured on the mock engine, the OpenAI Python SDK at its default 2 retries now recovers on/v1/responses, as it does on chat. In one run on the real engine it recovers on/v1/responsestoo.Strata's docs promise the header with no route limit.
docs/DETAILS.md: "withmin_free_vram_mibset and not enough free, the request gets 503 withRetry-After".OpenAI's spec allows the header but does not require it. In
openai/openai-openapi(2e9ebb3), the 503 ofPOST /responsesisInferenceServiceUnavailable. ItsRetry-Afteris an integer, minimum 1, and "may be omitted". So the case rests on Strata's docs and the SDK behaviour below.Related discussion
/v1/responses./v1/responsesroute, before the header existed.No scope agreement is needed: this is a bug fix, not a feature, refactor or change of default.
Approach
The
/v1/responseshandler now readsretry_afterfrom the error and passes it to the 503, the same way as the shared handler that chat and messages go through. OnlyGpuBusycarries that value, soEngineStarting,EngineStuckandEngineDiedstay as they were. The error body does not change. The docs already state this behaviour, so they do not change.Validation
Revision: base
c62d5e3aplus0113844d. Linux, Python 3.12.3, OpenAI Python SDK 3.42.0. Mock engine, except for the real-engine section at the end of Passed.Passed:
Regression test, stream and non-stream:
python -m unittest serve.test_server.SharingTheGpu.test_gpu_refusal_on_responses_sends_retry_after_tooWith the fix it passes. With
serve/server.pyfrom the base, both cases fail withAssertionError: None != '15'.Test suite:
python -m unittest serve.test_server serve.test_responses serve.test_anthropic_base_url serve.test_chat_tool_results serve.test_context_overflow serve.test_imagesRan 438 tests:
FAILED (failures=1, skipped=1). The one failure is listed under Failed.Differential on the wire, base against branch, with a local script that is not in this PR. It sends 63 requests: chat, messages and responses, stream and non-stream;
GpuBusywithretry_after15, 2.5, 0 and none;EngineStarting,EngineStuckandEngineDied; normal 200s; a realmin_free_vram_mibrefusal; a foreign Origin; a missing and a correct API key; andGpuBusyraised during the run. It compares status,Retry-After,Content-Type, the CORS allow-origin header and the first 220 bytes of the body, with ids and timestamps normalized./v1/responseswith a nonzeroretry_after, and each gains the header (15, or 2 for 2.5). Nothing else changes, including chat and messages.loadnot mocked and the free VRAM faked: chat, messages and/v1/responsesall answer 503 withRetry-After: 15, stream and non-stream.Real OpenAI Python SDK against the mock engine, with a local script that is not in this PR. Each cell is one run. The time is from the start of the scenario.
before_load_strict, a real hook that fails until 10 sInternalServerErrorat 1.3 smin_free_vram_mib, the shipped 15 s wait, faked VRAM frees at 55 sInternalServerErrorat 46.4 sReal engine: RTX 5080 16 GB, engine 0.1.55 from release v0.2.9, Qwen3.8 IQ3_S, context 65536. One session each for base
c62d5e3aand branch0113844d, one run per cell.min_free_vram_mibis 15800 and a separate program holds 300 MiB of VRAM, so the card has 15363 MiB free. Nothing is patched or faked. Each refusal takes 15.2 s, the shipped wait./v1/responses, non-streamRetry-AfterRetry-After: 15/v1/responses, streamRetry-AfterRetry-After: 15/v1/chat/completions, non-stream and streamRetry-After: 15Retry-After: 15/v1/messages, non-stream and streamRetry-After: 15Retry-After: 15responses.createnon-stream, the other program leaves at 50 sInternalServerErrorat 46.9 scompleted/v1/responsesafter the other program leftcompleted, 17.94 s (this request did the load)completed, 0.17 s (the SDK's request had done the load)The 503 bodies are the same on base and branch. The 77.3 s is later than the 60.1 s on the mock engine because it includes a real model load.
Failed:
serve.test_server.GpuChoice.test_hip_ordinal(AssertionError: '0,1' != '1,0'). This change does not cause it: the test fails the same way on the basec62d5e3a.Not run:
On the real engine, because they need a patch or were not part of this run:
GpuBusyraised during the run,EngineStarting,EngineStuck,EngineDied, andretry_aftervalues other than 15. These were run on the mock engine only.The
before_load_strictscenario.The SDK on chat, the Anthropic SDK, the SDK with
stream=True, and a program that never leaves, so the SDK runs out of retries with the header.Repeats. The SDK result on the real engine is one run on each side.
Windows and macOS.
CUDA, HIP, SYCL and Metal builds. The change is Python only.
Codex. The only client measured is the OpenAI Python SDK.
Limits
min_free_vram_mib, orbefore_loadwithbefore_load_strictormin_free_vram_mib) and an unloaded model. The default path does not change.GpuBusyraised during the run, on any route. Withsvc.runpatched to raise it (base and branch give the same result):/v1/responsesalready answers 503 with the header, with a chat-shaped body.retry_after=5),svc.runalso callsensure_loaded, so this error can carry 15 too. I did not trigger that through a real load.server_errortype and code. The spec's example for this response usesservice_unavailable_errorandserver_is_overloaded. This PR does not change the body.🤖 Generated with Claude Code
https://claude.ai/code/session_01W53iURzvDQMjnYemag8uvv
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.