Skip to content

fix: #3272 disarm CCR arming on the codex responses lane (unroutable acp_retrieve) - #3277

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-15_ccr-codex-lane-disarm
Oct 15, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-15_ccr-codex-lane-disarm

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

Disarm CCR arming on the codex responses lane so bili never declares acp_retrieve — or emits placeholders — to a host that structurally cannot route them. Same host mechanism as image_full (#3266/#3270).

Root cause

The codex host rejects bili-injected tools at its tool router and records a synthetic function_call_output = "unsupported call: <name>" in its own resent history (proven empirically for image_full in #3266/#3270). acp_retrieve rides the identical injection path: proxy-mode CCR arms on the responses wire whenever injectTool && storeChannelOk && ccr.enabled === true, with no host check. So a codex client sees an acp_retrieve declaration it can never route. When the model calls it (the CCR placeholder actively invites this), the client's history forks from ours → prefix-cache collapse + failure loop, and placeholderized content becomes unretrievable (silent loss).

Fix

Mirror #3270's image_full gate at the CCR stamp site (src/server/handle.ts): skip the stamp when protocol === "responses" && isCodexClient(headers). Disarmed → ccrEnabled false → the kernel ccr-store node substitutes no placeholders and prepare-responses injects no retrieve declaration. Regular compress/decompress/search_context folding is untouched.

Behavior change (old → new)

Scope: codex client on the responses wire, with CCR explicitly enabled (compress.ccr.enabled=true; CCR is opt-in since #1207, off by default).

  • Old: acp_retrieve declared + large tool results placeholderized (a token saving) but retrieval structurally broken — one retrieve away from history fork / cache collapse / silent loss.
  • New: CCR disarmed on that lane — no acp_retrieve declaration, no placeholder substitution (large tool results stay verbatim until regular folding); all other context tools unchanged.
    No other lane / wire / mode is affected (predicate scoped to responses && isCodexClient).

Relationship to #3270

Independent (this closes #3272, not #3270). Both add the same !(protocol === "responses" && isCodexClient(...)) predicate on adjacent lines of the same stamp block, so whichever merges second rebases over a trivial textual conflict — semantically clean in either order.

Tests

tests/issue3272-ccr-codex-lane-gate.test.ts (new) drives a real request through the proxy on the native responses wire and asserts the outbound body: codex UA → no acp_retrieve/placeholder + verbatim tool result; non-codex control → still arms (regression guard against over-disarm). Local: typecheck green + new suite 2/2 + marker-gate control 3/3 + 65 CCR-area tests green. Full regression deferred to CI.

Closes #3272

…acp_retrieve)

On the responses wire a codex host rejects bili-injected tools at its tool
router and records a synthetic "unsupported call" entry in its own resent
history. An armed CCR there declares acp_retrieve (unroutable by the host)
and placeholderizes oversized tool results the model can never retrieve back
(silent loss); every retrieve round-trip permanently forks client history
from ours (prefix-cache collapse). Same structural mechanism as image_full's
restore channel (#3266/#3270).

Gate the CCR arming stamp with !(protocol === "responses" && isCodexClient),
mirroring #3270's adjacent image_full gate. Disarmed -> no tool declaration,
no placeholder substitution; large tool results stay verbatim until regular
folding. Other lanes/wires unaffected; plugin-mode responses already excluded
via PLUGIN_CCR_WIRES. CCR is opt-in, so this only touches codex responses
users who explicitly enabled compress.ccr.

Test: tests/issue3272-ccr-codex-lane-gate.test.ts pins codex->disarmed /
non-codex->armed on the native responses wire.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-15_ccr-codex-lane-disarm (961509a)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3783-pr.3277.2f5ee5f

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3277.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 与 #3266/#3270 同属一个宿主机制家族(codex 在工具路由层拒绝 bili 注入的工具,并在自己重放的历史里写入合成 unsupported call),但表面与修复对象不同:#3270 门控 image_full,本 PR 门控 CCR(acp_retrieve 声明 + 占位符替换)。两个独立立项的 issue、两处相邻行的独立单行门禁,不构成重复。open PR 里也没有其他 PR 修同一处。

独立审核(对 diff 重做一遍,不复用 #3272 线程的结论)

① 原 issue(方向关):根因定位正确。CCR 武装谓词 injectTool && storeChannelOk 没有宿主维度——只要线路通道可用就武装,不检查宿主能否路由注入的工具。codex 对未知工具在自己重放历史里记合成条目(#3266 已用 image_full 实证 45 次 stderr),acp_retrieve 走同一条注入路径。在武装点修复 = 修产生者,不是下游堵症状;方案 A(disarm)此前已由 owner 拍板(#3272「A 关闭吧」)。✅

② 回归审查(触碰路径的既有行为逐项清点):

  • responses wire 上的非 codex 客户端:不变——对照测试钉住同一条线路上 CCR 仍武装(声明 + 占位符都在);
  • plugin mode:无交互——pluginCcrStamp 本就要求 ccrPluginWireOk(protocol),而 responses 不在 PLUGIN_CCR_WIRES(仅 anthropic/openai),新谓词对插件线路什么都不加;
  • anthropic/openai/google wire:不变——谓词严格限定 protocol === "responses";codex CLI 也只说 Responses API,这正是它到达 bili 的唯一格子;
  • text/marker 协议的 responses wire:storeChannelOk 本来就是 false,新条件冗余但无害;
  • disarm 副作用:storeEffectiveCcr(undefined) 走既有 feat: enable CCR (acp_retrieve) on host/plugin lanes (#1271) #1273/bug(ccr): plugin-mode retrieve acknowledgement can outlive its volatile full-text delivery #1343 丢弃路径——已确认未送达的 retrieve 带可观测日志 + corrective note 丢弃,不会静默悬空;codex 客户端在该线路从未武装过,正常无可丢;
  • 常规 compress/decompress/search_context 折叠、nudge、preflight:全部不受影响(grep 确认 storeEffectiveCcr 全仓仅此一个调用点,所有下游消费都经 ccrEnabled);
  • config surface / 持久化格式 / version / kernel:均未触碰(config-surface-guard、version-guard、kernel-guard、lock-sync 全绿)。
    结论:无意回归未发现。

③ 代码:唯一武装点加单一谓词。isCodexClient 是仓库既有的 UA 判定(精确前缀 + token 级宽松回退,刻意大小写敏感,#645/#1106/#1641),与 server.ts / prepare-responses / session-id 其他 codex 判定一致。注释讲 why + 引 provenance,不复述代码。✅

④ 测试有效性:不是 mock 测试——真实请求穿过 startServer 走 native-tool responses wire,断言出站 body。有牙:对照用例证明 harness 真能触发 CCR 占位符路径(否则对照用例自身就挂),防止主用例空真;端口用 listen(0)(确定性,#360);harness 对齐既有 #1097 store-marker-gate 模板。小瑕疵一处(不阻塞):process.env.NODE_ENV = "test" 位于 import 之后(ESM hoisting 使其在 import 求值后才执行)——与仓库既有测试文件模式一致,无实质影响。

⑤/⑤b diff 整洁度:2 个文件,每一行都服务于本 PR 目的;命名、注释、风格符合仓库惯例;无死代码、无无关改动。✅

结构化八问

  1. 是什么问题:bili 在 responses wire 上向 codex 声明 acp_retrieve,而 codex 的路由器结构性无法路由它;模型一旦调用(占位符还在主动引诱调用),codex 往自己的历史写合成 "unsupported call" 条目 → 历史分叉 → prefix-cache 崩塌 + 失败循环,且被占位化的内容不可找回(静默丢失)。
  2. 什么原因导致的:CCR 武装谓词缺宿主维度——只按「wire 通道可用」武装,不检查宿主能否路由注入的工具。
  3. 影响范围与严重程度:范围窄——需 codex CLI + responses wire + 用户显式开启 CCR(feat: CCR v2 — covered-ref spans, range-level decompress, ID-returning search_context; CCR default-on (#1179) #1207 起 opt-in,默认关)三者同时成立。范围内严重度高:一次 retrieve 调用即触发历史分叉 / cache 崩塌 / 静默丢失;范围外零影响。
  4. 怎么修复的:在武装点 disarm——protocol === "responses" && isCodexClient(headers) 时跳过 effective-CCR stamp,与 fix: image_full 死循环(#3266)——codex lane 上 restore 通道结构性不可用:按宿主门控 + 提示/回执列出可恢复 ref #3270 的 image_full 门控同构。stamp 缺失 → ccrEnabled=false → kernel 不做占位替换、prepare-responses 不注入 retrieve 声明;整条管线消费同一个 stamp,一处谓词覆盖全部下游。
  5. 是否有回归问题:见上方逐项清点——非 codex 线路、plugin mode、其他 wire、text/marker 协议、disarm 丢弃路径均保持既有行为,无回归。
  6. 是否破坏缓存:反向消除了一类 cache 崩塌诱因(历史分叉);disarm 本身只改变该格子的出站 tools 数组与大 tool result 的 verbatim 性,其余缓存/重试/游标/去重策略不受影响。
  7. 是否改了设计方向:否——沿用既有「按宿主证据门控」纪律(fix: image_full 死循环(#3266)——codex lane 上 restore 通道结构性不可用:按宿主门控 + 提示/回执列出可恢复 ref #3270),仍修在策略 stamp 点。
  8. 是否引入新的配置:无。

行为变更披露(old → new)

范围:codex 客户端 + responses wire + 显式开启 CCR 的用户。

  • 旧:acp_retrieve 被声明 + 大 tool result 被占位化(省 token),但取回结构性不可用——离历史分叉 / cache 崩塌 / 静默丢失只差一次 retrieve。
  • 新:该线路上 CCR disarm——不声明、不做占位替换,大 tool result 保持 verbatim 直到常规折叠。代价:这批用户在该线路的稳态 token 略升。其余线路 / wire / 模式零变化。

验证证据

  • 本地(定向):typecheck clean;6 个套件 44/44 绿(新套件 2/2 + store-marker-gate + ccr-plugin + ccr-v2 + fork-ccr-adoption + storage-ccr)。
  • CI(head 961509a):41 条 lane 中 35 条绿——全部静态门禁 / guard / hermetic registry e2e / real-client lanes + 12 个 test shard 中的 10 个;余 6 个 test shard 运行中,目前零红。

判定:可合(待余下 6 个 test shard 转绿,当前无任何失败)。备注:本 PR 与 #3270 在同一 stamp 块相邻行,后合者 rebase 时会有一次琐碎文本冲突,两种顺序语义都干净。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 已全部转绿:41/41 lane 全部 success(含 12/12 test shards,ubuntu/windows × node 22/24),零失败。上一条审核结论的待决条件已满足——判定维持:可合。合并动作按仓库纪律由人工执行。

@ranxianglei
ranxianglei merged commit 545db5f into master Oct 15, 2026
41 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.453-master.545db5f (rolling master tag).

npm install -g billion-context@0.0.453-master.545db5f  # 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

None yet

Projects

None yet

1 participant