← Back to Pull requests

fix(executor): log metadata-only diagnostics when codex SSE ends without completion #6497

Open
unknown opened this pull request with 306 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 09, 2026 23:11 UTC
Author

Summary

  • When a Codex HTTP/SSE stream ends without a recognized terminal event, the client only sees the normalized 408 "stream closed before response.completed", and the underlying cause goes exclusively to RecordAPIResponseError — which is gated behind request-log capture that operators can't enable on live traffic because it records private prompt/tool bodies. A 22-second clean EOF and a ~900-second transport hang are indistinguishable (#6469).

  • The streaming goroutine now keeps lightweight per-event counters (event count, last event type, last event timestamp) and emits exactly one metadata-only warning line when the stream terminates without completion: a read-error class from a sanitized closed vocabulary (clean EOF / unexpected EOF / connection reset / broken pipe / timeout / TLS / HTTP/2 stream error / client cancelled), plus event count, last event type, and idle/total milliseconds. Raw error text is never logged, since transport errors can embed peer addresses.

  • Downstream cancellation stays a debug line; the client-facing normalized 408/502 behavior is unchanged. The bootstrap-buffered path already surfaces the original read error and is intentionally untouched, as is the websocket transport.
  • Two design choices worth flagging for review: (1) the diagnostic line is a default-on, low-frequency warning on the failure path rather than an opt-in flag — happy-path streams never log it; happy to convert to a config switch if preferred. (2) idle time is measured from the last SSE event received, not from request start.

    Verification

    | Check | Result |
    |---|---|
    | go test ./internal/runtime/executor/... -count=1 | ok (executor + helpers, no flaky reproduction) |
    | New tests, run before the fix (red) and after (green) | TestCodexExecutor_IncompleteStreamLogsTerminationDiagnostics, TestClassifyCodexSSEReadError (11 cases incl. peer-address non-leak) |
    | go build ./cmd/server | ok |
    | gofmt -l on touched files | clean |
    | go vet on touched packages | clean |

    Fixes #6469

    AI use

    Code and tests were drafted with GLM-5.3-Flash (ZCode) under human direction. The human reviewed the diff, validated the root-cause chain against the issue report, and ran the verification matrix locally.

    Checklist

  • Tests added (failing test written before the fix)

  • go build ./cmd/server passes

  • gofmt / go vet clean on touched files

  • No changes under internal/translator/
  • Diff: 306 lines (+229 / -77) across 3 files Reviewer: ggbdpq Review duration: 5449m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.40) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 306 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.343
    Real PR Conversation Timeline
    1 comments
    "Review active on #6497"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 22.9% · Safe to merge
    22.9%