Repository navigation
Conversation
Symptoms: Responses WebSocket connections can close immediately after a successful 101 handshake, causing clients to report "Connection reset without closing handshake" and repeatedly reconnect. Different worker initialization orders can produce alternating successful and failed connections. Cause: CCH and Next.js can both handle the same WebSocket upgrade event. After CCH completes the handshake, the Next.js listener can close the accepted socket. Solution: Route /v1/responses upgrades exclusively to CCH before invoking ordinary upgrade listeners. Preserve listener dispatch for other paths, the current worker's private HTTP loopback target, payload limits, and cleanup behavior.
Symptoms: Responses WebSocket continuations can fail with previous_response_not_found while the client connection remains open. Remote Compaction v2 can also be recorded as successful after a structured WebSocket error. Cause: Logical session affinity does not guarantee reuse of the same physical upstream WebSocket. Connection, routing, or credential changes can lose connection-local history while requests still carry previous_response_id. Structured WebSocket failures can also bypass final error accounting. Solution: Bind protected continuations to the live upstream connection, provider, endpoint, generation, and complete request-header fingerprint. Recheck access and limits, preserve prior storage semantics, and reject invalid bindings with a canonical 400 error requiring full-context replay. Prevent alternate routing, retries, HTTP fallback, hedging, Replay, and fake streaming for protected continuations. Confirm terminal delivery before closing, discard queued continuations, and preserve attempt-local error accounting with idempotent resource cleanup.
Complete missing outbound session header aliases for trusted Codex WebSocket requests and derive both absent aliases from a valid prompt_cache_key. Preserve explicit header values, request bodies, and complete connection fingerprint checks without generating identifiers or using routing session IDs.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Continuation 绑定与上游 WebSocket 处理 src/app/v1/_lib/responses-ws/continuation.ts, src/app/v1/_lib/responses-ws/internal-secret.ts, src/app/v1/_lib/responses-ws/upstream-adapter.ts, src/app/v1/_lib/responses-ws/__tests__/*, tests/unit/proxy/responses-ws-session-header-continuation.test.ts |
新增可信请求识别、会话绑定和响应 outcome 状态。上游适配器校验 continuation 绑定,并在连接有效时复用该 WebSocket。 |
WebSocket 服务端续传与升级路由 server.js, src/app/v1/_lib/responses-ws/__tests__/server-helpers.test.ts, tests/unit/server-ws-* |
服务端依据响应终态和实时绑定设置 prior-local 标记。升级路由将 /v1/responses 交给 WebSocket handler,并委派其他路径。 |
供应商固定与代理转发约束 src/app/v1/_lib/proxy/provider-selector.ts, src/app/v1/_lib/proxy/forwarder.ts, src/app/v1/_lib/proxy/fake-streaming/*, src/app/v1/_lib/proxy/replay/replay-identity.ts, tests/unit/proxy/* |
Continuation 固定到绑定供应商和端点,并跳过重试、切换及 HTTP 回退。代理过滤内部标记、保留 outcome,并为 Codex WebSocket 请求补齐会话标识。测试覆盖绑定、转发限制及会话标识处理。 |
Continuation 错误与响应结算 messages/*/errors.json, src/lib/utils/error-messages.ts, src/app/v1/_lib/proxy/errors.ts, src/app/v1/_lib/proxy/error-handler.ts, src/app/v1/_lib/proxy/response-handler.ts, src/app/v1/_lib/proxy/stream-finalization.ts, tests/unit/proxy/error-handler-durable-persistence.test.ts, tests/unit/proxy/response-handler-* |
新增规范的不可重试客户端错误响应。延迟流结算记录 continuation 错误状态,并避免将其归类为流故障或熔断失败。新增多语言错误消息及相应测试。 |
Priority:
Estimated code review effort: 4 (Complex) | ~60 minutes
Suggested reviewers: ding113, tesgth032
Merge Risk: 
Minimal · up to 17c42
-
This change pins Responses WebSocket continuations to their original provider and upstream connection, and fills in missing session header aliases for trusted Codex WebSocket requests. No concrete merge-blocking defect was identified. Merge it in the stated order after
#1516and#1517.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 39 functions across 31 files. (5 skipped: 5 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
🧪 Generate unit tests (beta)
-
- Create a new PR
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Normal turns and raw compaction requests in the same trusted Codex WebSocket session can produce different outbound session headers. Complete a missing
session_idorx-session-idalias from a valid companion; when both are absent, derive both from an existing validprompt_cache_key. Preserve explicit values, including empty or invalid headers, and leave the request body unchanged without generating session identifiers.Depends on #1516 and #1517. Merge order: #1516 -> #1517 -> this PR. All three target
dev, so this branch includes its prerequisites until they merge.Validation: This branch and its merge with upstream v0.9.8 both passed production build, Biome check and autofix, TypeScript checking, and the full Vitest suite (9,566 and 9,588 tests passed respectively; 13 skipped in each). The 72 session-header and continuation regression tests passed; added header-completion statements and branch arms have 100% coverage.


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Aligns Codex WebSocket session headers across normal turns and raw compaction requests.
No actionable issues were found. This review used code and test inspection; it did not independently run the reported checks.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Trusted Codex WebSocket turn] --> B[Complete missing session header aliases] B --> C{Local continuation?} C -->|Yes| D[Check bound provider and endpoint] D --> E[Check retained socket and matching headers] C -->|No| F[Choose upstream transport] E --> G[Forward response] F --> G G --> H[Wait for terminal delivery and HTTP completion] H --> I{Required local binding still available?} I -->|Yes| J[Accept next turn] I -->|No| K[Close client connection]Reviews (1) · Last reviewed commit: "fix(proxy): align Codex WebSocket sessio..." · Reviewed by Greptile