Repository navigation
fix: mirror the codex CLI wire shape in preflight summary calls for codex clients (#2733) - #2735
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2979-pr.2735.bb97d0eThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2735.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 已按 [PR] 流程完成核验(不重做):拉取分支 核验证据
结构化八问
行为变更披露复核(与 PR 一致,确认成立):仅 codex 客户端的 bili 内部摘要请求从 收工判定:代码与测试质量达标,方向正确(修根因、单 facet、不越界到 #2733 其余两个待决 facet);等最后一个 windows-22 CI job 转绿即可合并,合并前建议顺手解决第 5 问的 e2e 覆盖缺口(手动 dispatch 或 follow-up)。合并动作本身留给人工:#2735 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.321-master.5cf0717 # this exact build
npm install -g billion-context@master # always the newest merged build
|
What & why
Part of #2733 (issue stays open — the D1 nudge-suppression facet awaits owner sign-off and the codex-side window-divergence facet awaits the reporter's
codex --version/config).Root cause (proven from the issue log + upstream sources): new-api / anyrouter-family codex relays validate inbound
/v1/responsescalls as legitimate Codex requests —inputmust be typed message items AND carryinclude:["reasoning.encrypted_content"](the real codex CLI's signature, sent unconditionally bycodex-rs/core/src/client.rs); anything else is HTTP 400invalid_responses_request. bili's main path forwards real codex bytes verbatim so it is unaffected — but bili's own side-channel preflight summary call built a minimal payload (input:[{role:"user",content}], noinclude) and was rejected 100% on such relays (12/12 in the issue log, session 01a1250d). The preflight lane was therefore dead there, and codex's local auto-compaction won every race it entered.Evidence: sylearn/AIUsage documents the exact validator behavior + minimal accepted body; caidaoli/ccLoad tests use the identical error body for the anyrouter codex channel; the issue log shows the exact 400 body
{"error":{"message":"invalid codex request (request id: …)","type":"new_api_error","code":"invalid_responses_request"}}on every summary attempt (stream AND non-stream).Change
src/preflight.ts—summaryPayload()gains an optionalcodexClientflag; when true, the Responses-protocol summary payload mirrors the real CLI shape:Detection reuses
isCodexClient(deps.headers)(same UA predicate as prepare-responses / overflow-target logic) at the single call site inrequestSummary(). The operator-configured external-summary lane (src/external-summary-http.ts) intentionally keeps the legacy shape — that endpoint is an explicit operator choice.Behavior change disclosure (old → new)
For codex clients only, bili's internal summarization call now sends typed input items + the
includesignature instead of the minimal item. Non-codex clients and all other protocols are byte-identical. No config surface, persistence, or main-path wire change. Rationale: without this, preflight compression is silently unusable behind strict codex relays and codex native compaction takes over (lower fidelity, full cache bust).Verification
tests/issue2733-preflight-codex-shape.test.ts: fake anyrouter-style validator upstream rejects non-signature summary calls with the exact 400 body → before the fix test 1 fails (proven by revert-and-run), after the fix both tests pass; test 2 pins that non-codex UAs keep the legacy shape (no signature leak).tests/preflight-*, codex-compact/local-compaction, external-summary-http/batch, 超窗拒答以 5xx 返回时出现探测死循环;外部摘要链路三处静默/上限问题(含文件:行号与本地验证) #2484/[Bug] 摘要请求看不到被压缩区间里的图片:renderRange 只取 m.text,图片连占位都没有 #781 summary suites).ACP_TEST_E2E=1 tests/e2e/e2e-codex.test.ts) could not run in this environment: its upstream endpoint comes from CI secrets (E2E_UPSTREAM_URL/KEY) and the harness fails at phase-1 warmup with ECONNREFUSED to the secret port — before any preflight code path executes. CI will run it.