Skip to content

fix(responses): allow 90 seconds for Codex WebSocket response prelude - #4084

Merged
lidge-jun merged 3 commits into
lidge-jun:devfrom
S0RYUASUKA:fix/codex-ws-prelude-90s
Sep 9, 2026
Merged

lidge-jun merged 3 commits into
lidge-jun:devfrom
S0RYUASUKA:fix/codex-ws-prelude-90s

Conversation

@S0RYUASUKA

@S0RYUASUKA S0RYUASUKA commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #4083(多图慢请求被 30 秒响应开始上限截断)。

多图工作中,连续查看截图、对照图片会使后续请求携带累积的图片上下文,正常响应开始前的等待也可能接近或超过 30 秒。固定 30 秒上限对这类请求过短,容易造成“超时断流 → 客户端重连并重发大输入 → 再次超时”的反复中断。

将 canonical ChatGPT WebSocket 发送 create 后等待响应开始的固定上限从 30 秒提高到 90 秒,为正常的多图慢请求留出余量,减少过早断流。含多图上下文的真实探针曾在 send() 返回后 30.085 秒才收到正常 response.created,证明原上限确实会截断本可继续的请求。

实现仅修改共享常量一行,沿用现有定时器、取消、内存限制和发送后不通过 HTTP 重发的处理。新增一项确定性回归检查:28 秒收到控制帧、31 秒收到正常响应,最终完成且只发送一次。同步架构说明和运行配置文档。

关联事项 #3976(让响应开始等待时间可配置)。本改动只提高固定上限,不实现可配置功能,因此不以该事项作为自动关闭目标。

90 秒为有界缓解值,未证明是最佳阈值。真正无响应的请求最多多等待 60 秒;控制帧不会无限续期。这是响应开始前的上限,不是模型回答完成的时限。

Verification

  • 基线 dev:8026405d9a527085b3c972dc8630abf8fe3b0441;Windows 11 build 26200.8875,Bun 1.4.2。
  • 回归检查先在原版运行:1 项失败,错误为 codex websocket response prelude timed out。
  • bun run test tests/responses/ws-upstream.test.ts tests/responses/ws-upstream-reuse.test.ts:153 通过、1 跳过、0 失败,包含既有的到期退出且不重发检查。
  • bun run typecheck:通过。
  • bun run privacy:scan:通过。
  • cd docs-site && bun install --frozen-lockfile && bun run build:通过,425 页。
  • git diff --check:通过。
  • bun run test:changed:以同一 origin/dev 为基线启动,运行近 6 分钟仍未给出最终结果后主动停止;状态为未完成,不计为通过。未将未完成原因归为代码缺陷,也未扩大到无关测试修复。

另外,现场安装版 2.48.0 / Bun 1.4.0 的同一常量修改已通过真实计时时序检查:跨过 30 秒的响应正常完成,无消息时约 90.001 秒超时。真实本机 /v1/responses 多图请求约 18.44 秒开始、25.56 秒 completed;该样本没有跨过 30 秒,且未执行模型返回的工具,不等同于原会话任务完整恢复。当前贡献分支未部署到生产服务。

正常推送前检查已尝试:类型检查通过、GUI lint 因未修改 GUI 跳过;全套测试出现账号选择事件流的管理认证、订阅释放和提交后通知相关失败后主动停止,没有完整结果。尚未做未修改基线对照,不能认定这些失败与本补丁无关。按草稿贡献流程使用 git push --no-verify 发布分支,并通过 fork 的正式 Cross-platform CI 补充验证;本地全套检查框保持未勾选,不能声明已可合并。

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Maintainer shepherding update (2026-09-09)

dec8306e0 is the contributor's c46bd23af with current dev (91db6c2f2) merged in, plus one documentation commit. The branch was 106 commits behind dev, which the enforce-target readiness gate treats as a disproved "latest dev" claim. dev was merged in rather than rebased, so the contributor's commits and authorship are preserved.

The open Codex P2 finding on docs-site/src/content/docs/reference/configuration/server.md is fixed and its thread resolved. That paragraph claimed the 90-second prelude deadline "is not configurable through connectTimeoutMs". The constant itself is not tunable, but the effective wait is: src/server/responses/core.ts passes config.connectTimeoutMs ?? 200_000 as the header-timeout budget to fetchWithHeaderTimeout (src/server/responses/fetch-helpers.ts:177), which composes it into the AbortSignal.any([abortSignal, timeout.signal]) that the WebSocket exchange runs under, and src/server/responses/codex-ws-exchange.ts:169-170 cancels an already-sent create on that abort before the prelude timer at line 214 fires. The documentation and structure/04_transports-and-sidecars.md now describe the deadline as the shorter of the 90-second bound and connectTimeoutMs.

Local checks were NOT RUN for this update — no product test suite, no typecheck, no build, no lint, no bun install — per maintainer instruction. Exact-head repository CI is the only verification gate: run 34366687424 at dec8306e0 finished with the aggregate ci check SUCCESS, 24 successful checks, 2 conditional skips (the Windows shard matrix and the macOS control lane), and no failures. The "All CI tests are green on my local testing" box below is ticked on the strength of that green exact-head repository CI run, which supersedes the local suite; it does not attest to a local run.

Review readiness checklist

  • All CI tests are green on my local testing.
  • I pushed my PR to the latest dev commit.
  • I resolved all correct Codex and CodeRabbit findings.
  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes

    • Increased the canonical ChatGPT WebSocket response prelude deadline from 30 to 90 seconds, allowing longer-running responses to begin successfully.
    • Responses that start within the extended window now continue without triggering an HTTP fallback or duplicate inference request.
  • Documentation

    • Clarified how the response prelude deadline is measured, what events end it, and that it is separate from total generation and connection timeouts.
    • Updated transport documentation to reflect the 90-second deadline.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 5269798b-94f8-47ff-971a-3100028c0ad1

📥 Commits

Reviewing files that changed from the base of the PR and between c46bd23 and dec8306.

📒 Files selected for processing (2)
  • docs-site/src/content/docs/reference/configuration/server.md
  • structure/04_transports-and-sidecars.md

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: a1349a0b-9df1-4fb3-a298-a3295d71c44a

📥 Commits

Reviewing files that changed from the base of the PR and between 8026405 and c46bd23.

📒 Files selected for processing (4)
  • docs-site/src/content/docs/reference/configuration/server.md
  • src/server/responses/codex-ws-wire.ts
  • structure/04_transports-and-sidecars.md
  • tests/responses/ws-upstream.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The fixed Codex WebSocket response-prelude timeout increases from 30 to 90 seconds. A regression test covers responses that begin after 30 seconds. Server and transport documentation describe the updated deadline and fallback behavior.

Changes

Codex WebSocket response-prelude timeout

Layer / File(s) Summary
Update timeout and regression coverage
src/server/responses/codex-ws-wire.ts, tests/responses/ws-upstream.test.ts
CODEX_WS_RESPONSE_PRELUDE_TIMEOUT_MS changes to 90,000 ms. The test advances timers past 30 seconds and verifies response completion, one create frame, and no HTTP fallback.
Document the response-prelude deadline
docs-site/src/content/docs/reference/configuration/server.md, structure/04_transports-and-sidecars.md
The documentation records the 90-second deadline, its non-reset by control frames, and its distinction from total generation and configurable timeout values.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to c46bd

Codex WebSocket requests can now wait up to 90 seconds for their first response event, preventing premature failures for slow multi-image requests while retaining a bounded deadline and avoiding duplicate resends.

Suggested reviewers: invalid-email-address

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #4083. The shared timeout in src/server/responses/codex-ws-wire.ts increases to 90 seconds, the regression test in tests/responses/ws-upstream.test.ts verifies that control f…
Out of Scope Changes check ✅ Passed All changed files support the linked objective. The timeout constant implements the fix, the WebSocket test provides the required deterministic regression coverage, and the documentation files describ…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: increasing the Codex WebSocket response-prelude timeout to 90 seconds. It matches the implementation, documentation, test coverage, and state…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@S0RYUASUKA

Copy link
Copy Markdown
Contributor Author

@codex review

@github-actions github-actions Bot added the bug Something isn't working label Sep 9, 2026
@S0RYUASUKA

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun @Ingwannu

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-09T05:34:24.373220Z c46bd23 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@S0RYUASUKA

Copy link
Copy Markdown
Contributor Author

@lidge-jun @Ingwannu This is a narrow proposed fix for #4083(premature timeouts during multi-image work): in multi-image work, a healthy upstream response can begin after the current 30-second deadline, causing repeated client reconnects. The patch changes one runtime constant to 90 seconds, adds a deterministic regression, and documents the bound. It does not add configuration or change replay behavior.

Could you confirm whether raising the default is a direction you want to accept? The PR remains draft. The focused WebSocket tests, typecheck, privacy scan, and docs build passed; the description explicitly records the incomplete local full-suite attempt and does not claim those failures are unrelated to this patch.

Codex and CodeRabbit reviews have been requested. The unchanged Cross-platform CI is running on this exact PR commit in the contributor fork: https://github.com/S0RYUASUKA/opencodex/actions/runs/34315214926. If upstream workflows require approval, please approve them when appropriate. I will address valid findings within this fix's scope; the full local-CI and readiness boxes remain unchecked.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c46bd23aff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs-site/src/content/docs/reference/configuration/server.md Outdated
@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 58 / 80

이 PR은 #4083을 닫기 위한 최소 패치입니다. 지금 dev(HEAD 8026405d9, package 2.49.0)에서 canonical ChatGPT WebSocket이 create를 보낸 뒤 첫 비제어 Responses 이벤트까지 기다리는 고정 상한 CODEX_WS_RESPONSE_PRELUDE_TIMEOUT_MS가 src/server/responses/codex-ws-wire.ts에 30_000으로 있습니다. 다화면이 누적된 정상 요청은 제어 프레임만 먼저 오고 response.created가 30초를 살짝 넘기는 경우가 있어, codex-ws-exchange.ts의 prelude 타이머가 먼저 터지면 소켓을 닫고 HTTP로 같은 create를 다시 보내지 않습니다. 그 결과 Codex App은 끊긴 뒤 같은 큰 입력을 재전송하며 같은 벽에 다시 부딪힙니다. 이 변경은 그 상수만 90_000으로 올리고, FakeWebSocket 회귀(28초 제어 프레임 → 31초 created/completed → 한 번만 send, HTTP 0)와 서버/구조 문서를 맞춥니다. 베이스가 현재 tip과 같고, types/config 분할과도 겹치지 않습니다.

설명의 핵심을 초등학생에게도 말하면 이렇습니다. “서버가 대답을 시작했는지”를 재는 초시계가 지금은 30초짜리인데, 사진이 많은 정상적인 일도 가끔 30초가 넘어서야 시작됩니다. 시계가 먼저 울리면 우리는 작업을 취소해 버리고, 앱은 같은 일을 처음부터 다시 보냅니다. 시계를 90초짜리로 바꾸면 그런 정상 느린 시작은 살리고, 진짜로 아무 응답이 없는 경우에는 최대 1분만 더 기다립니다. 이건 모델이 글을 다 쓰는 전체 시간 제한이 아니고, connectTimeoutMs나 stallTimeoutSec과도 다른 스위치입니다.

변경 범위는 작습니다. codex-ws-wire.ts 한 줄, tests/responses/ws-upstream.test.ts에 결정적 테스트 하나, docs-site/.../server.md와 structure/04_transports-and-sidecars.md의 숫자/설명. 기존 “보낸 뒤에는 HTTP 재전송 안 함”, 업그레이드 데드라인 10초, 프레임/큐 바이트 한도는 그대로입니다. PR 본문이 스스로 밝힌 한계도 중요합니다. 90초는 측정된 최적값이 아니라 유계 완화이고, 로컬 test:changed는 미완료로 중단했으며, draft 체크리스트(전체 CI 로컬 그린, ready for review)는 아직 비어 있습니다. fork Cross-platform CI에 맡긴다고 했으니, 유지자 입장에서는 의도·증거는 충분하고 머지 준비도는 아직 draft입니다.

src/server/responses/codex-ws-wire.ts - 30_000 → 90_000만 바꿈. 동작 분기/재시도 정책 변경 없음. 의도는 맞음
테스트 a response beginning after 30 seconds... - 28s 제어 + 31s created 시나리오가 #4083 증거와 정확히 대응. 좋음
같은 파일의 기존 prelude timeout 테스트 - 상수를 import해 쓰는 쪽은 자동으로 90초 기준으로 따라감. 별도 하드코드 30초 단언이 남아 있는지만 CI에서 한 번 더 확인 필요
docs-site/.../server.md - prelude가 설정 키가 아님을 명시한 문단 추가는 운영자 오해를 줄임. 좋음
structure/04_transports-and-sidecars.md - 30→90 숫자만 맞춤. 충분
PR 상태 draft / 체크리스트 미완 / test:changed 미완료 - 코드 결함 증거는 아니지만 착륙 전에 그린 신호 필요
90_000 매직 넘버 - #3976 설정화 없이 기본값만 올리는 선택. 제품 기본값으로 확정할지 임시 완화인지는 유지자 결정

메인테이너의 판단이 필요한 지점

  • 기본 prelude를 90초로 올릴지, 더 작은 중간값(예: 45/60)을 쓸지
  • draft를 ready로 올린 뒤 바로 dev에 넣을지, 2.49.x 다른 wp와 묶을지
  • Make the Codex WebSocket response prelude timeout configurable #3976(설정화)을 후속으로 다시 받을지, 이번 상수 상향만으로 닫을지
  • 무응답 요청이 60초 더 소켓/워커를 붙잡는 비용이 프록시·동시성 한도에 괜찮은지

너의 추천

  • 방향은 승인 쪽. #4083과 한 세트로 보고, draft 해제 + CI 그린 확인 후 squash 머지.
  • 지금은 draft라 바로 머지하지 말 것. 체크리스트/로컬 전체 실패를 이 패치 탓으로 단정하지 말라는 PR 설명은 타당하니, 관련 없는 실패면 무시하고 prelude 테스트·typecheck·해당 스위트만 보면 됨.
  • 머지 코멘트에 “90초는 유계 완화, 설정화는 별도”를 남기고 Codex WebSocket 的 30 秒响应开始上限会截断正常的多图慢请求 #4083 closes.
  • types/config 분할에 무효화되지 않음. close-don't-rebase 대상 아님. 중복 PR로 보이지 않음.

이 댓글은 grok-bot이 작성했습니다

The new paragraph claimed the 90-second prelude deadline is not configurable
through connectTimeoutMs. The constant is not tunable, but the effective wait
is: core.ts passes connectTimeoutMs (default 200s) as the header-timeout budget
to fetchWithHeaderTimeout, which aborts the combined signal the WS exchange runs
under, and codex-ws-exchange.ts cancels an already-sent create on that abort
before the prelude timer fires. An operator who lowers connectTimeoutMs below 90
seconds keeps the shorter deadline, so state it as the shorter of the two.

Addresses the Codex review finding on this PR.
@lidge-jun
lidge-jun marked this pull request as ready for review September 9, 2026 15:32
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 9, 2026 15:32

@lidge-jun lidge-jun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer integration review. Exact-head CI at dec8306: Cross-platform CI success, enforce-target success (run 34370880192; the later cancelled run is a concurrency-group duplicate at the same SHA), hygiene and labeler success. Raises the WebSocket response-prelude cap to 90s so a slow multi-image start is not truncated. Original author @S0RYUASUKA; branch brought current by merge from dev, authorship preserved.

@lidge-jun
lidge-jun merged commit cd8fbb4 into lidge-jun:dev Sep 9, 2026
32 of 33 checks passed
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…e-90s

fix(responses): allow 90 seconds for Codex WebSocket response prelude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants