fix(openai): recover message-only capacity failures before output - #5676
Open
Perfecto23 wants to merge 3 commits into
Open
fix(openai): recover message-only capacity failures before output#5676Perfecto23 wants to merge 3 commits into
Perfecto23 wants to merge 3 commits into
Conversation
Contributor
|
All contributors have signed the CLA. ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Perfecto23
marked this pull request as ready for review
August 15, 2026 15:33
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.
Context
OpenAI capacity shedding is not reported through one stable error shape. The same transient overload can arrive as:
errorevent;response.failedevent;server_is_overloadedorslow_downcode; orOur servers are currently overloaded. Please try again later.The gateway previously recognized only part of those shapes. Responses streams also emit lifecycle metadata such as
response.created,response.in_progress, empty reasoning items, and empty summary parts before any semantic output. Once those frames were written downstream, the attempt looked committed and the gateway could no longer retry safely. Codex clients then received a capacity error that they can treat as terminal, even though the request was still safe to recover.This change makes the recovery boundary explicit across HTTP JSON, native SSE, passthrough SSE, and the WebSocket-to-HTTP bridge.
What changed
Classify capacity shedding consistently
server_is_overloadedandslow_downcodes.error, andresponse.failed.Keep pre-output attempts replay-safe
Treat capacity shedding as request-scoped
Preserve post-output safety
server_errorcode before forwarding them to Codex clients.Add observability
When capacity failover is suppressed because semantic output already started, emit:
The event records the transport path, event type, account, platform, and upstream request ID. It does not record request bodies or credentials.
Resulting behavior
Benefits
Validation
go test -tags=unit ./...go test -tags=integration ./...go test ./internal/service ./internal/handlergo vet ./internal/service ./internal/handlergit diff --checkgolangci-lintwas not run locally because the installed v2.3.0 binary was built with Go 1.24 and cannot load this repository's Go 1.26.6 toolchain. The repository CI should run lint with its supported tool version.