Repository navigation
[PR] pi-native: re-assert the active tool loadout after a /tree rewind (compress etc. no longer silently die) | pi-native: /tree rewind 后重断言活动工具 loadout(compress 等工具不再静默失效) - #3545
Conversation
pi's navigateTree() resets the ACTIVE tool loadout to what the surviving transcript system entries declare (_restoreToolsFromTranscript), discarding the entry that declared the bili tools whenever it sits after the rewind target (the normal case - the manifest handshake is async). The definitions stay in the registry, so #2708's registry probe sees nothing missing, but pi dispatches on the loadout: every later compress/decompress/acp_status call fails with "Tool X not found" until restart, silently on both sides. Re-assert the loadout on the session_tree event, which fires right after the reset and before the next _startRun: additive-only (names the host currently holds are never removed), logged, and a no-op on hosts without the getActiveTools/setActiveTools surface (older pi / omp). Root cause stays in pi core (_restoreToolsFromTranscript dropping a still-true declaration); this is the in-scope bili-side compensation. Fixes #3542
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4191-pr.3545.91490cdThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3545.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 最近邻是已关闭的 #2708( 独立审核结论(以下机制均本人对 pi 源码/tarball 重新核对,未复用 issue 文本): 方向(①):修复层次正确——根因在 pi core 回归清点(②),diff 触碰路径的既有行为逐项判定:
代码(③):新函数 测试有效性(④):5 个新测试都有牙——(1)恢复+日志内容断言(XDG_STATE_HOME 隔离 bili.log,断言 warn 点名 compress)(2)additive-only 保宿主名字序 bash,read,compress,acp_status快速路径零 setter/re-register 调用(4)无 API 宿主 no-op(5)查询抛错 no-op。Fake host 忠实建模 pi(loadout 与 registry 分离、Set 去重)。任一 facet 回归都会让至少一个测试失败。一个覆盖缺口已审: Diff 整洁度(⑤):2 文件 +167/-0,每行与目的相关,无无关变更;commit message 含机制+边界说明+Fixes #3542。 CI:独立核对 head 7550425 的全部 42 个 check run——全 success/skipped(skips 均为条件式 real-client e2e 门),零失败。 热文件备注: 结构化八问:
判定:满足 §7.4 auto-merge gate 全部条件(单模块 fix:、有回归测试、CI 在 pushed head 上绿、clean diff、Fixes #3542、未触承重设施),可交人工合并。 另:按标题国际化惯例已将 PR 标题改为英文前缀形式 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.648-master.391b802 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3542
问题
pi-native 模式下用 pi 内置
/tree回退(典型流程:回退到首条用户消息 + 换模型 + 重发)后,bili 的 ACP 工具(compress/decompress/acp_status…)变成「已注册但未激活」:定义仍在 pi 的 registry 里,但离开了活动 loadout(pi 声明给模型、且 dispatcher 按名检查的那一套)。此后模型每次调用都被 pi 拒Tool compress not found,整场会话无法恢复,两侧都无日志。机制(pi-coding-agent 1.3.0 逐行核对,行号与 issue 一致):
navigateTree()(dist/core/agent-session.js:3232)末尾先_restoreToolsFromTranscript()(:3376)再 emitsession_tree(:3378);_restoreToolsFromTranscript()(:1374)把 loadout 重置为存活 system entries 声明的并集。bili 的 manifest 握手是异步的,其工具声明 entry 落在回退目标之后,被丢弃 → 工具离开 loadout;_startRun清_pendingToolNames;registry 重建只在 reload(includeAllExtensionTools)或名字全新时加回;getAllTools()),定义还在 → 看不见这一类。修法
在
session_tree事件上重断言 loadout——该事件恰在重置之后、下一次_startRun之前触发:reload()无条件重新激活全部 extension tools 的先例一致;getActiveTools/setActiveTools面(老 pi / omp)或查询抛错(stale ctx)→ no-op,绝不盲目 set(与reassertDroppedTools同一纪律)。已核对 0.83.0 与 1.3.0 两个版本都具备该 API 面。边界说明:根因在 pi core(
_restoreToolsFromTranscript把会话级仍为真的工具声明当历史状态丢弃),真实修复属于上游;本 PR 只做 in-scope 补偿,不向上游提 issue(owner 决定)。行为变更披露
/tree(及同类 tree 导航)后,若 bili 工具不在活动 loadout 中会被重新激活,并多一行[native-client] … dropped from the active loadout … — re-asserting (#3542)warn 日志。未回退的会话、无该 API 面的宿主行为完全不变。验证
tests/plugin-agent.test.ts,fake host 模拟 loadout 被重置而注册保留):恢复+日志、additive-only 保序补名、快速路径零调用、无 API 宿主 no-op、查询抛错 no-op;既有 pi-native: tools register once per session id, so a pi tool-registry rebuild silently removes compress/decompress/... for the rest of the session #2708 四测保持绿。套件 74/74 通过。tsc --noEmit干净;tsup build 通过。全量 suite 交 CI。