Repository navigation
fix(pi-native): self-heal ACP tools dropped by a mid-session registry rebuild (#2708) - #2713
Conversation
… rebuild (#2708) pi rebuilds its executable tool list per request from its tool registry (_refreshToolRegistry walks the live extension instances' tool maps into _toolRegistry; setActiveToolsByName filters active names through _toolRegistry.has(name) and silently drops any name it no longer holds). When that rebuild runs while our extension instance's map is empty (a runtime replacement / reload mid-session), the ACP tools leave both the registry and the active set while the transcript keeps declaring their names — so the model keeps calling tools pi rejects by name ("Tool compress not found") forever. registerTools() was gated once-per-sid (`if (sid === state.sid) return` plus the toolsFor guard), so nothing ever re-registered them: unrecoverable until a restart, and silent on both sides (no log). Fix: remember the tools we registered (state.registeredTools) and, on every provider request for an already-registered sid, probe the host's real registry via getAllTools() and re-assert any we dropped. registerTool is idempotent (dedup by name) and post-bind triggers a registry refresh, so the session self-heals on the next request cheaply. The same re-assert runs at the end of a successful registration to cover a same-id session_start whose register loop is skipped. Hosts without a registry query (older pi / omp) keep the once-per-sid behavior — the probe degrades to a no-op, and a throwing query never triggers a blind re-register. A console.warn names the dropped tools so the failure stops being silent. Tests: four regression cases in plugin-agent.test.ts (drop → self-heal + log; fast path does not re-register; no-query host stays inert; same-id session_start re-asserts during registration).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2943-pr.2713.4a4165aThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2713.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 完成(已 rebase 到当前 master 逐行审过;并对照 1. 是什么问题 2. 什么原因导致的 3. 影响范围与严重程度 4. 怎么修复的 5. 是否有回归问题 6. 是否破坏缓存 7. 是否改了设计方向 8. 是否引入了新的配置 测试有效性:四个回归 case 是真测试——断言的是可观测副作用(重注册调用计数、warn 文本、ownership header 落章),分别钉死 fast-path 自愈、fast path 无 drop 不重注、无探针宿主 inert、session_start 再断言四条路径,任一条机制被移除对应 case 必红。 CI 状态与判定:除 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.249-master.aac8bc3 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2708
Problem
In the pi-native (plugin) lane the six ACP tools are registered into pi's tool registry once per session id. pi rebuilds its executable tool list from that registry on every request (
_refreshToolRegistrywalks the live extension instances' tool maps into_toolRegistry;setActiveToolsByNamefilters active names through_toolRegistry.has(name)and silently drops any name it no longer holds). When that rebuild runs while our extension instance's map is empty (an extension-runtime replacement / reload mid-session), the ACP tools leave both the registry and the active set while the session transcript keeps declaring their names — so the model keeps calling tools pi rejects by name (Tool compress not found). BecauseregisterTools()was gated once-per-sid (if (sid === state.sid) returnplus thetoolsForguard), nothing ever re-registered them: unrecoverable until restart, and silent on both sides of the wire (no log line anywhere).Fix
Remember the tools we registered (
state.registeredTools) and, on every provider request for an already-registered sid, probe the host's real registry viagetAllTools()and re-assert any of our tools that vanished.registerToolis idempotent (dedup by name) and post-bind triggers a registry refresh, so the session self-heals on the next request cheaply. The same re-assert runs at the end of a successful registration to cover a same-idsession_startwhose register loop is skipped. Aconsole.warnnames the dropped tools so the failure stops being silent.Hosts without a registry query (older pi / omp) keep the exact once-per-sid behavior — the probe degrades to a no-op, and a throwing query never triggers a blind re-register.
Behavior change (disclosed)
pi.getAllTools()once (cheap, synchronous) and re-registers only if one of our previously-registered tools is missing. When nothing was dropped there is no extra work beyond one name-set lookup and no log line.bili-plugin(<agent>): N bili tool(s) dropped from the host registry (<names>) — re-registering (#2708)— emitted once per drop event, not per request.No config-surface change. No wire/message-shape change (re-registered definitions are byte-identical
manifestToTooloutput; no payload/tool-call arguments touched). Nokernel/orpi-subagents/change. No new dependencies.Tests
Four regression cases in
tests/plugin-agent.test.ts:getAllToolsstays inert (no crash, no blind re-register);session_startafter a drop re-asserts during registration.Verified on the rebased head (current master):
tsc --noEmitclean;plugin-agent.test.ts69/69; neighboring pi-lane suites (fork-adopt, native-caller-stamping, session-name, subagent-registry) green. Full build + suite run in CI.