Repository navigation
[PR] fix: answer WS-lane failures with object error frames and true 1009 sizes (#4601) - #4624
ranxianglei wants to merge 9 commits into
Conversation
…izes (#4601) Two defects on the codex Responses-WebSocket failure path (field: bili 0.1.206, codex-tui 0.164.0, 17.5 MB un-intercepted compaction, close 1009, turn failed after ~15 minutes): 1. Pipeline failures were answered with the HTTP proxy-failure body whose 'error' is a string. The WS-lane error contract is { type, status, error: { code?, message?, headers? } } (codex parse_wrapped_websocket_error_event); a string fails that deserialization, so codex dropped the frame and waited out its 5-minute idle timeout x retries. ResponsesWsResponse.end() now normalizes at this single conversion point: object errors pass through, string errors become { code: proxy_failure, message: '<error>: <detail>' }, missing errors fall back to incomplete_response. Status semantics keep statusCode >= 400 (default 502); the unparseable-buffer fallback now honors an explicit 4xx/5xx status instead of always 502. HTTP lanes keep their string-error contract untouched. 2. The 1009 oversize diagnostic measured sentBytes only for string bodies — a verbatim-passthrough (Buffer) body reported '0.0 MiB' plus the false 'no sheddable images' reason although no shedding was attempted. Buffer bodies are now measured, and the no-shed branch names the real reason (body is not a JSON wire body — image shedding cannot apply). Regression suite: tests/issue4601-ws-failure-frame.test.ts (both defects + negative gates: HTTP string contract, admission errorFrame shape).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6167-pr.4624.c56bffdThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4624.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…master-red) The unused-exports gate fails on master itself (verified on origin/master tip 146b34f): src/agent/client-build-note.ts exported ClientBuildCheck while every reference sat inside the declaring file (INTERNAL_ONLY). This PR touched neither that file nor its importers, so the failure is inherited from master, not introduced by #4601. Drop the leading export per the gate's sanctioned fix for INTERNAL_ONLY. The type stays defined and used internally (maxTestedVersion / DSH_BUILD_CHECK and the emit call sites); no other module references it by name, so nothing breaks. Isolated drive-by commit so the #4601 diff stays scoped.
(ai: vllm-qwen/qwen3.8-27b) CI auto-fix (attempt 1/2): fixed the red
判定:已推送,新 head |
(ai: vllm-qwen/qwen3.8-27b) 这是 [PR] 镜像单,未重做工作——已拉取分支(ce00312,基于当前 master 146b34f,领先 1 个提交)逐行核对代码、核查了 CI 状态。结论如下。 查重: 不重复。 #4624 是 #4601 的唯一在途修复;最近邻 #4595(codex prewarm probe relay)也动 标签: bug / codex / opencodev2 / scope/wiring / p2(缺陷只在管道级失败时显形,正常成功回合不受影响,故 p2)。 八问
测试有效性3 个用例都有牙:核心回归断言 CI 状态与合并判定
|
master window commits 293ae65/de5e03659 bumped kernel/package.json to 0.0.165 without regenerating the lockfiles; lock-sync re-resolution then rewrites the stale recorded versions (root 0.0.163, kernel 0.0.164) and fails. Pure recorded-version sync via npm install --package-lock-only; no dependency or semantic change.
|
(ai: sglang-gpu0/qwen3.8-27b) 已合入 master: 本 PR 的改动经「codex 车道小修合集第三辑」#5971 送审合入。本 PR 关闭以免重复。 |
…ersize passthrough hint (for ranxianglei#4624, closes ranxianglei#4601)
What this fixes
Field incident (bili 0.1.206, codex-tui 0.164.0): an un-intercepted compaction was forwarded at 17,490,755 bytes, the upstream closed with 1009, bili logged
WS upstream rejected the 0.0 MiB request with close 1009, and codex failed the turn only after ~15 minutes of 5-minute idle timeouts x retries — because it never saw the failure.Two defects on that failure path:
dispatchanswers pipeline failures withbuildProxyFailureResponse, whose body carrieserroras a string. On the WebSocket laneResponsesWsResponse.end()spread that body into{ ...details, type: "error", status }— so the frame kept a stringerror. Codex parses WS error events as{ type, status, error: { code?, message?, headers? } }(parse_wrapped_websocket_error_eventincodex-rs/codex-api/src/endpoint/responses_websocket.rs); a string fails deserialization, the frame is not treated as an error, and the stream waits out its idle timeout. Every pipeline-level failure on the lane (upstream timeout/reset, circuit fail-fast, 1009 oversize, anything) hit this.relay.tscomputedsentBytesonly for string bodies — a verbatim-passthrough (Buffer) body reported0.0 MiBtogether with the default "no sheddable images outside the protected recent messages" reason, although no shedding was ever attempted (shedding needs a JSON wire body).Changes
src/responses-ws.ts—ResponsesWsResponse.end()normalizes the non-terminal JSON body into the WS-lane error contract at this single conversion point: objecterrorpasses through unchanged; stringerrorbecomes{ code: "proxy_failure", message: "<error>: <detail>" }; a missingerrorfalls back to theincomplete_responseshape. Status keeps its semantics (statusCode >= 400, default 502).src/server/relay.ts—sentBytesmeasures Buffer bodies (wireBody.byteLength) instead of hardcoding 0;wsOversizeDiagnosisgains an optionalwhyoverride used by the no-shed guard branch to state the truth ("the body is not a JSON wire body (verbatim passthrough) — image shedding cannot apply") instead of claiming sheddability was checked.tests/issue4601-ws-failure-frame.test.ts— new regression suite: pipeline 1009 → object-form frame codex can parse (fail-fast within 15 s vs the 300 s idle timeout), passthrough 1009 → real size + honest reason, plus negative gates pinning the HTTP string-error contract and the admissionerrorFrameshape.Behavior changes (old → new)
errorwas a string, now an object{ code, message }. Old frames were silently ignored by codex (the bug); new frames make it fail fast. Other fields (detail,upstreamFailure) remain additive as before.statusCode(default still 502). Only reachable when the server set a 4xx/5xx status but wrote a non-JSON body; previously unreachable in practice.buildProxyFailureResponsekeeps its string-errorcontract (pinned by the new gate test).Verification
tests/codex-responses-ws.test.ts(9),tests/issue3701-ws-byte-budget.test.ts(11),tests/responses-ws-http-fallback.test.ts(9) — 29/29.tsc --noEmitclean. Full-suite verdict = CI on this head.src/responses-ws.ts(probe-gate region inonMessage, ~line 655) — disjoint from this change (end(), ~line 569); rebase if they land together.Closes #4601