Repository navigation
feat: neverPreserveRecentTools config knob (acp-kernel 0.0.92) - #547
Conversation
Top-level acp.json key removed from the soft-protected recent zone (kernel #395). Recommended remedy for the batch-read fold->re-read loop (upstream billion-context #1198/#1277): remove only 'read', keep decompress/search_context. Unlike the two protection keys an empty array is a VALID max-protection escape hatch, so it is validated separately from cleanProtectionList. Refs #545
📦 Built Extension ArtifactBranch: Option A — Install from npm PR tag (recommended)pi install npm:billion-context-pi@pr-547Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pi-pr547.tgz
pi install ./packageThis comment is automatically updated on each push. |
[bot] 🏷 收到,正在按 PR Review 规范审查:方向(上游 billion-context #1277/#1198)、回归面(config/user-config 既有行为)、代码、测试有效性、diff 整洁度。会本地拉分支跑 typecheck+test+build,并核对 acp-kernel 0.0.92 是否已发布到 npm(CI |
PR #547 Review —
|
| 既有行为 | 结论 |
|---|---|
| 未设置该键的用户 | 保持。resolveConfig 逐字透传 undefined(刻意不 ?? []);内核 isNeverPreserveRecent(dist :1202):patterns === void 0 ? 内置列表 : patterns → 内置列表接管。已 grep 确认 0.0.92 dist 无任何 ?? [] 强制转换;{...base,...overrides} 展开中显式 undefined 键安全(base 本无此键) |
| acp.json 未知键处理 | 有意变更(披露):此前写在 acp.json 里的 neverPreserveRecentTools 会被当未知键静默忽略,现在生效——这是功能本身,非回归 |
| 畸形值处理 | 保持 fail-loud:adapter 层 cleanNeverPreserveList warn + 回退(不合并不丢弃整个配置),内核层 validateConfig 第二道防线("must be a string array") |
| 内核 pin 0.0.91→0.0.92 | 无隐藏漂移:diff 了两个版本的 dist,恰好 13 行,全部是该功能(validate 3 行 + isNeverPreserveRecent 参数化 5 行 + 调用点 1 行,余为上下文)。内置列表不变;0.0.91 精确匹配 .includes() → 0.0.92 matchToolPattern(新增前缀通配支持),对无通配的内置列表行为完全一致 |
| ref-tag 渲染 / token 校准 / 前缀缓存 | 未触碰 |
| host 检测 / stand-down、sidecar 格式、update.ts、identity/session | 未触碰 |
本包 version 字段 |
未 bump(正确,content commit 不动版本) |
| README「What gets protected」 | 默认值未变,描述仍然准确(可选后续,不阻塞) |
③ 代码审查 ✓
src/config.ts逐字透传 + 注释写明「unset → 内置列表接管」,与内核契约一致;src/user-config.ts用独立的cleanNeverPreserveList而非复用保护键的非空校验——正确,空数组在此是合法的最大保护逃生门,复用会误杀;KNOWN 集合同步更新,不会误报未知键;- 无
as any/@ts-ignore,无多余注释。
④ 测试有效性 ✓
7 个新测试断言有牙,且钉住了关键分叉:[] 合法(与两个保护键的非空规则对比)、trim、user 覆盖 adapter、畸形回退矩阵(有/无 adapter 值两路)。adapter 层测形状是恰当的——内核侧语义我另行端到端验证(见下)。CI 全量套件 + e2e 兜底。
⑤ diff 整洁度 ✓
8 文件 +117/−6,每行都与本 PR 目的相关;lockfile 双处 0.0.92 + integrity 同步;无空白 churn、无跑题文件。head b3a4e59 基于当前 master(1a737da),无需 rebase。
本地验证(分支 worktree @ b3a4e59,npm ci)
- typecheck 干净,build OK(dist/index.js 942KB,自包含);
- 全量套件:分支 951 测 / 846 过 / 99 挂;pristine master(worktree @1a737da,kernel 0.0.91)944 / 839 / 99。失败集按名称排序后逐字节相同 → 99 个失败全部为预先存在的环境问题(沙箱 /tmp 只读 → session sidecar
EACCES: permission denied, lstat '/tmp/pai-acp-*.acp.json'),无一由本 PR 引入;分支额外多过一个 flaky 文件(restart-cache),与 issue 描述一致; - 7 个新测试本地全部通过;
- CI @ b3a4e59:pr-validation、test(ubuntu+windows × node22+24)、build-artifact、e2e(ubuntu+windows)、docker —— 全部 success;
- npm:
acp-kernel@0.0.92已发布(latest)→ 跨仓发布顺序满足。
端到端行为探针(真实 resolveConfig → 真实内核 pipeline,观察最近区工具结果的折叠资格)
| 配置 | read | bash | decompress | search_context | write |
|---|---|---|---|---|---|
| A 未设置(内置接管) | 可折叠 | 可折叠 | 可折叠 | 可折叠 | 受保护 |
B [](最大保护) |
受保护 | 受保护 | 受保护 | 受保护 | 受保护 |
C 推荐值 [decompress,search_context,bash] |
受保护 | 可折叠 | 可折叠 | 可折叠 | 受保护 |
三例与 issue/文档描述逐字吻合;C 例即死循环修复路径——新鲜 read 留在最近区、随后按位置老化,而 bash/decompress/search_context 仍可立即回收。
Auto-merge gate
不适用:feat: + 配置 schema 面 + 跨仓内核 pin → 无论哪条都要求人工合并。审查过程中未发现需要直接补修的小问题,未向 PR 分支添加任何 commit。
中文摘要:审查了 neverPreserveRecentTools 配置项 PR(#547)——方向正确(治上游 #1277/#1198 批量读文件折叠死循环的根因),回归面干净(未设置时内核内置列表接管、既有用户行为零漂移,0.0.91→0.0.92 内核 diff 仅 13 行且全部为该功能),本地 typecheck/build/定向测试通过、99 个环境性失败与 master 基线逐字节一致,CI 全绿,推荐值语义经端到端探针验证与文档一致,可以合并。
…lusion list The positive-facing counterpart of neverPreserveRecentTools: patterns REMOVED from the effective exclusion list computed by the kernel (acp-kernel >= 0.0.93). The #1198/#1277 batch-read fold->re-read remedy is one entry, ["read"], without restating — or freezing a copy of — the built-in list. [] is rejected (pure no-op here — a near-certain typo for neverPreserveRecentTools: []). Refs ranxianglei/billion-context#1277
|
Added the positive-facing companion knob on top of this branch (c3c77f0):
{ "preserveRecentTools": ["read"] } // the one-entry #1198/#1277 remedyEffective exclusion = Wiring: Kernel pin bump to a real 0.0.93 follows after acp-kernel#428 merges & releases (tarball install is |
新 commit c3c77f0(
|
| 检查 | 结果 |
|---|---|
tests/config.test.ts + tests/user-config.test.ts |
91/91 通过(与你声明一致;新测试都是 shape 级,不依赖 0.0.93) |
运行时安全(0.0.92 下带该键跑 processTurn) |
✅ 无 validateConfig 告警刷屏,键被静默忽略(no-op),不会在 pin bump 前污染用户日志 |
npm run typecheck |
❌ 失败:src/config.ts(585,5): error TS2561: 'preserveRecentTools' does not exist in type 'Partial<Config>'. Did you mean to write 'preserveRecentTokens'? |
npm run build |
❌ 同错(build 脚本含类型检查步骤,tsup 本体成功但整体非零退出) |
④ 阻塞项:CI 红(已确认,非猜测)
GitHub check-runs @ c3c77f0:test(ubuntu/windows × 22/24)、build-artifact、e2e(×2)、docker 全部 failure,仅 pr-validation success。根因就是上表 TS2561——CI 顺序 npm ci → typecheck → build → test,typecheck 挂掉后全线连带。这个 head 现在不可合并。
合并路径(建议,无歧义版)
不需要改这个 commit,也不需要拆 PR。按你写好的顺序走完即可:
- acp-kernel#428 合并(目前仍 open,head d54835b;npm latest 仍是 0.0.92);
- 0.0.93 发布后先验证:
npm view acp-kernel version== 0.0.93(跨仓发布顺序铁律); - 本 PR 追加 pin-bump commit(
package.json+package-lock.json,精确版本,不加^); - CI 转绿后由人合并整个 PR(两个旋钮一起进)。
当前状态是一个正确的中间态:adapter 侧就绪、运行时安全、文档诚实标注了「requires acp-kernel >= 0.0.93」,只差内核发布这一环。
中文摘要:审查了新 commit c3c77f0(preserveRecentTools 正向旋钮)——代码/测试(91/91)/中英文档均合格,内核 #428 实现与文档契约逐字一致、运行时在 0.0.92 下安全无副作用,但因本 commit 仍 pin 0.0.92(类型缺该字段),typecheck/build 必然失败、CI 实测全红,暂不可合并;待 #428 合并、0.0.93 发布并追加 pin-bump commit 转绿后即可整体合并。
…l 0.0.92 The kernel pin is still 0.0.92 until acp-kernel#428 (preserveRecentTools, 0.0.93) is released; Partial<Config> from 0.0.92 rejects the key at the literal. Annotated overrides object compiles against both versions; the property rides defaultConfig's spread and is ignored by kernels that don't read it.
Exposes kernel
neverPreserveRecentTools(acp-kernel #395, released in 0.0.92 — pin bumped here) as a top-level~/.pi/acp.jsonkey: tool-name patterns excluded from the soft-protected recent zone, so matching tool results inside the recent window become compressible immediately instead of aging out first.Why (upstream billion-context #1198/#1277)
The kernel built-in list
["decompress", "search_context", "read", "bash"]keepsread/bashcompressible because they are the largest reclaimable mass — but in batch-read workflows (upstream #1198: 1M window correctly detected, usage 11–18%) the compression cadence folds freshly-read files right away → the model re-reads them → growth triggers another fold → death loop (9 compressions in 26 min).Recommended remedy (owner guidance on upstream #1277): remove only
read—{ "neverPreserveRecentTools": ["decompress", "search_context", "bash"] }— fresh read results then stay in the recent zone and age out by position later (unlike
protectedLatestTools, which would pin the newest read forever, orprotectedTools, which would never fold any read). Keepdecompress/search_contextin the list: re-including them pins just-restored blocks in the recent zone where they become unreclaimable.[]is a valid max-protection escape hatch.Changes
src/config.ts:AdapterConfig.neverPreserveRecentTools+ passthrough intodefaultConfigoverrides (unset → kernel built-in governs)src/user-config.ts: top-level acp.json key (KNOWN set) +applyUserConfigvalidation via a separatecleanNeverPreserveList— an EMPTY ARRAY IS VALID here, unlike the two protection keys' non-empty-array checkchore: pin acp-kernel 0.0.92Tests
tests/config.test.ts(+2): resolveConfig verbatim passthrough ([]included), unset → undefined.tests/user-config.test.ts(+5): acp.json pickup,[]accepted, trim + user-overrides-adapter, malformed falls back to adapter, malformed dropped when no adapter value. All 87 green in both files.Full suite branch vs pristine master (same kernel tarball): failure sets identical (environmental), branch additionally passes one flaky file (restart-cache).
Refs upstream billion-context #1277 / #1198