Add Responses stream lifecycle diagnostics#19755
Closed
etraut-openai wants to merge 8 commits into
Closed
Conversation
Bojun-Vvibe
added a commit
to Bojun-Vvibe/oss-contributions
that referenced
this pull request
Apr 27, 2026
- openai/codex#19773 permissions: require profiles in TUI thread state (merge-after-nits) - openai/codex#19755 Add Responses stream lifecycle diagnostics (merge-after-nits) - openai/codex#19753 Terminate stdio MCP servers on shutdown (merge-as-is) - BerriAI/litellm#26581 fix(semantic-filter): run for anthropic_messages call type (merge-as-is)
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.
Why
Refs #19745.
Responses stream failures are currently hard to diagnose because the client often reports only the terminal transport error. That makes it difficult to tell whether a stream was silent from the start, closed after
response.created, stalled before durable output, stalled after text began, or completed with inconsistent response IDs.This adds diagnostics for those lifecycle boundaries without changing retry budgets, idle timeouts, fallback policy, model behavior, or app-server protocol shape.
What changed
ResponseStreamLifecycleRecorderincodex-apithat tracks stream attempt, transport, terminal state, response IDs, first and last event timing, output milestones, observed event kinds, and event count.ApiError::Streamdetails for failed streams and completed streams with mismatched response IDs.ResponseEvent::Createdparsing to carry the created response ID so lifecycle capture uses parsed event data instead of reparsing raw JSON.ModelClientSession, with the existing WebSocket-to-HTTP fallback reset preserving fresh attempt numbering for the fallback transport.Verification
cargo check -p codex-api -p codex-corecargo test -p codex-apicargo test -p codex-core responses_websocket_v2_surfaces_terminal_error_without_close_handshakecargo test -p codex-otel