Skip to content

[PR] fix: preserve main folds across expanded short Responses requests - #3845

Merged
ranxianglei merged 3 commits into
ranxianglei:masterfrom
ReineLan:codex/responses-short-wire-fold-guard
Oct 20, 2026
Merged

ranxianglei merged 3 commits into
ranxianglei:masterfrom
ReineLan:codex/responses-short-wire-fold-guard

Conversation

@ReineLan

Copy link
Copy Markdown
Contributor

Fixes #3844

Six Responses input items with multiple text parts expand past the existing short-pass guard and can accumulate zombie-reap evidence against the main conversation. Preserve the inbound item count before codec expansion and use it alongside the projected count when deciding whether reconciliation can observe history deletion.

Adds direct reconciliation, kernel inactivity/recovery, and complete HTTP pipeline regressions. Four short passes retain the main blocks and coverage, and resending main history restores active folds. Existing full-history deletion controls remain covered. No kernel, configuration, or version changes.

Related: #2231, #2707.

Validation on master 85c27f0e:

  • 83/83 targeted tests passed: fold-reconcile, fold-drift, preflight-fail-fast.
  • TypeScript typecheck and production build passed.
  • Original code failed the new block-retention / coverage assertions; the patch passes.

The Responses preparation path applies in both plugin and proxy modes; the guard only prevents short passes from supplying deletion evidence. It does not bypass compression or rewrite signed content. Full-suite verdict is left to GitHub CI. The separate 413 retry fix is independent.

@ranxianglei ranxianglei changed the title fix: preserve main folds across expanded short Responses requests [PR] fix: preserve main folds across expanded short Responses requests Oct 19, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

ework接单

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。 本 PR 直接修复来源 issue #3844(Codex Desktop 上短 Responses 请求被 codec 展开后突破 fold-reconcile 的 short-pass 守卫,反复累积 zombie-reap 证据、收割主会话折叠块)。检索 open+closed issue/PR:fold-reconcile 家族在途 PR 有多个(#3734 host rewind/tail truncation、#3316 wire-shape flip 重锚、#3257 增量快路径),但没有任何一个处理「多 part 展开击穿 10-core 守卫」这个机制——症状(主会话块被误收割)与机制(入站 item 数 vs 投影 core 数失配)均不同于上述条目。同一生产事故的另一半(本地 413 后 over-window probe 重开)已由独立 PR #3867 跟踪,与本 PR 无耦合。

标签: bug + codex + scope/kernel + p1(理由:缺陷类;issue 环境为 Codex Desktop/Responses 流量;改动域是上下文管理/会话核心逻辑的折叠对账;p1——主会话压缩块被反复误删属核心承诺失灵类,生产已实际发生)。

初审进展(结论稍后按结构化八问给出):

…he openai/anthropic/google wires too (ranxianglei#3844)

ranxianglei#3642's canonical per-part granularity defeats the projected core-count guard (SIDE_REQUEST_MAX_MSGS) on every codec, not just Responses: a few multi-part inbound items project into dozens of cores, so repeated short passes accumulate zombie-reap evidence against the main conversation's folds. Extends this PR's inboundMessageCount option to the three sibling wire sites (same two-line pattern as prepare-responses) so a pass whose RAW inbound cardinality is below the side-request threshold can no longer supply deletion evidence on any wire.

Adds a both-directions regression per wire (ranxianglei#3617): uncounted expanded short passes reap the main fold (pre-fix behavior); counted passes take no evidence across four passes (byte-identical state), retain the block, and resending main history restores coverage with zero missing.
@ranxianglei ranxianglei added bug Something isn't working codex p1 scope/kernel labels Oct 19, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

(ai: vllm-qwen/qwen3.8-27b)

Added one commit (0ef73b7e0) extending this fix to the three sibling wires — same mechanism, so it belongs in this PR's closed loop rather than a follow-up:

Why: #3642's canonical per-part granularity defeats the projected core-count guard on every codec, not just Responses. openaiToCore splits array-content messages per part, anthropicToCore per text block, googleToCore one core per text part — so on those lanes a few multi-part inbound items also project past SIDE_REQUEST_MAX_MSGS, and repeated short passes accumulate zombie-reap evidence against the main conversation's folds: the same destructive path #3844 describes, reached through different wire shapes.

What changed: the same two-line pattern as prepare-responses.ts — compute inboundMessageCount from the raw inbound body (messages/contents length before codec expansion) and pass it to reconcileFoldCoverage. A pass whose RAW inbound cardinality is below the side-request threshold can no longer supply deletion evidence on any wire; skip semantics (no evidence taken, NOT recovery, episode state left as found) are untouched.

Tests: sibling-wire short multi-part passes never reap main folds (#3844 openai/anthropic/google) in tests/fold-reconcile.test.ts — both directions per wire (#3617): uncounted expanded short passes reap the main fold (asserted as the pre-fix behavior), counted passes take no evidence across four passes with byte-identical state, retain the block, and resending main history restores coverage with missing=0.

Validation: fold-reconcile 68/68, fold-drift + preflight-fail-fast 16/16, typecheck clean; full-suite verdict left to CI. No kernel, configuration, or version changes.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Review 完成。结论:可合(待 CI 绿);我在 PR 分支上补了一个 commit(0ef73b7e0,已推到作者分支并留言说明),把同一机制在另外三条 wire 上的同款路径一并修掉。

八问:

  1. 是什么问题:标题生成之类的辅助请求很短(几条消息),但 The intermediate message (core) is not protocol-agnostic: switching protocols/models causes identity churn; cross-protoc | 中间消息(core)没有做到协议无关:切协议/切模型制造身份 churn,补齐跨协议映射 #3642「每个文本 part 拆成独立 core」的投影规则会把 6 个 Responses input item × 13 parts 展开成 78 个 core 消息,绕过旁路请求守卫(<10 core 才跳过)。这些短请求根本不带主会话历史,reconcile 于是把「主会话全部 covered id 消失」当成 owner 删除证据,连续积累后误收割主会话的压缩块——压缩静默失效、上下文回涨、成本爆炸,用户得重发全量历史才能恢复。
  2. 什么原因导致的:守卫拿codec 展开后的 core 数当判据,而展开大小取决于投影粒度而非请求真实体量。「是不是旁路请求」的正确判据是原始入站基数(客户端原始 body 里的 item/message 条数)。修法 = 给 reconcileFoldCoverage 加 inboundMessageCount 选项,投影计数与原始计数双门槛 OR。
  3. 影响范围与严重程度:p1。任何在同 session id 下发多 part 短辅助请求的客户端都中招(Codex Desktop 生产已发生,bili 0.1.201)。触发条件:会话有 ≥1 个 fold 块 + 反复出现展开后 ≥10 core 的短辅助请求。后果是主会话折叠被永久放弃直到重发历史——属「核心承诺失灵」类。
  4. 怎么修复的:prepare 层在 codec 展开前数一遍原始入站条数传进 reconcile;任一计数 <10 即跳过取证(跳过语义严格保持:不取证 ≠ 恢复,episode/drift 状态原样)。我额外把它扩展到 openai/anthropic/google 三条 lane(PR 原本只修 Responses):The intermediate message (core) is not protocol-agnostic: switching protocols/models causes identity churn; cross-protoc | 中间消息(core)没有做到协议无关:切协议/切模型制造身份 churn,补齐跨协议映射 #3642 拆分规则对三个 codec 同样生效(kernel/src/wire/openai.ts:105-139 / anthropic.ts:108-118 / google.ts:189-207),同款路径必须同修——一个机制一个闭环,不拆片。每条 lane 加了双向回归(Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617):不带计数的旧路径确会收割(钉住 guard 必要性),带计数则 4 轮短请求字节级零变化 + 块保留 + 重发主历史 missing=0 恢复。
  5. 是否有回归问题:逐项审过既有行为——①守卫跳过语义不变(不取证也不恢复,streak 不动),存量 [cache-ledger] netSaved 面板在 fold 覆盖坍缩后继续累计虚增——ledger 与实际重发行为无交叉校验 #2202 守卫测试覆盖;②真·删除控制(orphan-reap、total-loss 升级、[Bug][proxy] unframed host-side history deletion leaves zombie fold blocks rendering carriers forever — one carrier flaps in/out every turn (persistent prefix-cache churn) #2695 三轮收割)不受影响:新条件只会收窄取证的 pass 集合;③出站字节零变化(纯簿记层);④REWRITE_MIN_INCOMING_TOTAL(使用pi 压缩后就提示prompt is too long #1195 drift WARN 日志行)用同样启发式但只 gate 日志、无破坏性,未动。行为变更披露(旧→新):anthropic/openai/google 三 lane 上「原始 <10 条但展开后 ≥10 core」的 pass,旧值=照常进 reconcile(会积累假证据)→ 新值=跳过;安全方向——只移除误收割能力,最坏情形是把真僵尸收割推迟到下一次 ≥10 原始条数的 pass。
  6. 是否破坏缓存:不涉及。出站字节/前缀缓存/重试/去重键均未动。
  7. 是否改了设计方向:无。未触 kernel(无需 kernel-change)、配置面、版本。
  8. 是否引入新配置:无。

质量判定:PR 本身质量高——三层回归(直接 reconcile / kernel inactivity-recovery / 完整 HTTP pipeline)是真测试且有牙(快照字节相等断言、原代码确实挂断言);guard 语义保真;diff 干净(单 commit,4 文件,每行都为目的服务)。唯一缺口就是三兄弟 wire 的同款路径,已直接补齐(本地验证:fold-reconcile 68/68、fold-drift+preflight-fail-fast 16/16、typecheck 干净;全量交给 CI)。CI 绿后可合。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

接单后先把 CI 的两个红项查清了。结论:与这个 PR 无关——是 master 自身 10-19 起就红的两个静态门禁,拖红了所有 PR;已有专门修复在途(#3871,全绿),等它合入后我把本 PR rebase 到新 master 即可全绿。

证据(本地复现,两个树各跑一遍门禁脚本):

处置(先查重再动手): #3870 已立项记录此事,#3871 就是对应修复(去掉孤儿 export + 重新生成文档表删掉 4 行旧行),其 CI 40 项检查全绿(含 docs-sync、unused-exports 和全部 test lane)。按「一个红 master 通常只有一个根因」的规则,本 PR 不叠加同样的修复 commit,避免与 #3871 的 diff 撞车。

八问(本轮增量,未变项沿用上一轮完整八问):

  1. 是什么问题: 本 PR CI 上的两个红项来自 master 侧既有的静态门禁故障,非本 PR 引入。
  2. 什么原因导致的: ① [security][web] Diagnostics blob prints private relay hosts verbatim in the config section — the "secrets masked" header only masks values, not hosts | 诊断包 config 段原样输出内网中转地址:标题说"密钥已遮蔽",但只遮值不遮主机 #3811 导出了仅同文件使用的函数;② 一次坏的合并解决在生成的文档表里留下 4 行过期重复行。
  3. 影响范围与严重程度: 所有 PR 的 CI 运行在这两门上红,且下游 test lane 被 needs 链整体跳过;不影响已发布行为,不丢数据。
  4. 怎么修复的: [PR] fix(ci): unblock master static gates - drop orphaned export and stale duplicate doc rows #3871 单独修复(纯门禁修复);本 PR 代码不动。
  5. 是否有回归问题: 无。[PR] fix(ci): unblock master static gates - drop orphaned export and stale duplicate doc rows #3871 不碰运行时/配置/wire;本 PR 既有行为审计见上一轮八问(守卫跳过语义不变、全量历史收割控制仍覆盖)。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及。
  8. 是否引入了新的配置: 无。

判定: 本 PR 代码完备、独立可合;当前唯一阻塞 = #3871 待人工合并。#3871 合入后我立即 rebase 本 PR 到新 master 并确认 CI 全绿,然后交你合并。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

状态确认(无新变化):刚查过 #3871 仍为 open(未合并),master 仍在 39fb841d3。本 PR 保持上一轮结论——代码完备(0ef73b7e0 已推送到 PR 分支),CI 上仅有的两个红项是 master 侧既有门禁故障,由 #3870/#3871 专门修复(#3871 CI 全绿)。我在本地已模拟「master + 本 PR + #3871」的合并树:两个门禁均干净,rebase 后全绿的路径已验证。

等 #3871 人工合并后我立即执行:rebase 本 PR 到新 master → 本地定向测试 + typecheck → 推送 → 确认 CI 全绿 → 交你合并。无需你做任何事。

@ranxianglei
ranxianglei merged commit 24965f3 into ranxianglei:master Oct 20, 2026
44 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.632-master.24965f3 (rolling master tag).

npm install -g billion-context@0.0.632-master.24965f3  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codex p1 scope/kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Responses] Short wire requests expand past the fold-reconcile guard and reap main-session blocks

2 participants