Repository navigation
feat(pi): capability-aware proxy-style ACP channel for pi-subagents children (#2268) - #2276
Conversation
…hildren (#2268) pi-subagents builtin roles ship strict frontmatter tools: allowlists that grant none of the ACP context tool names; since #2185's required-extension self-registration those children get named plugin sessions but lose the wire-injected ACP tools they had pre-#2185 (anonymous pfa-* proxy mode), so interactive compression silently regressed for default roles. Per-request gate (src/server/pi-subagent-channel.ts): a plugin-stamped pi request carrying pi-subagents' <active_agent name=> child marker whose tools array exposes none of the bili-injectable names is served through the proxy-style channel (wire-injected tools + nudge, server-side execution, acp_summary carrier). Session identity stays plugin-bound; stateless per request, self-healing on whitelist changes; scoped to nicobailon/pi-subagents children only (owner-directed); roles exposing any injectable name stay pure plugin mode (partial grants unsupported). Tests: 11 unit (marker sniff, 4-shape tools walker, composition) + 4 real-HTTP rig cases; e2e-native-pi gains a real pi-subagents@0.76.1 unmodified-delegate child scenario (injected ACP surface + preserved whitelist + acp_status round trip + named-session persistence + parent purity). CLIENTS en/zh caveat rewritten from manual-grant recipe to auto-injection behavior.
2eb2132 to
ef12054
Compare
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2427-pr.2276.bdefc0eThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2276.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 完成 — 判定:可合并。 已按 PR Review 规范走完 ①原issue → ②回归清点 → ③代码 → ④测试有效性 → ⑤diff整洁度。先报告审查中发现并已修复的唯一拦路项,再按结构化七问作答。
const pluginMode = pluginAgent !== undefined && !pluginLaneDegraded(session) && !subagentFallback.present;本地定向验证:typecheck clean、新增单测 11/11、 ① 是什么问题:pi-subagents 的 7 个 builtin role frontmatter 都是不带 ACP 工具名的严格 allowlist;#2185 把它们 named-plugin 化后,children 失去了 #2185 之前(匿名 pfa-* proxy session)从 wire 注入得到的 ACP 工具,交互式压缩静默退化为只剩 preflight 硬兜底。 ② 什么原因导致的:两层因果。① pi 的最小权限工具规划根本不会把扩展注册名放进 effectiveToolAllowlist(上游安全模型,bili 不能也不该绕过);② #2185 把 children 从匿名 proxy lane 切到纯 plugin lane,关闭了 wire 注入通道——能力与通道被绑死在同一开关上。 ③ 怎么修复的:在 ④ 是否有回归问题:审过触碰路径的既有行为——untagged / 非 pi / granted 请求与之前逐字节一致(gate 需三条件同时成立,既有 e2e-native-pi 的 untagged traffic 即 no-op 证明);#2155 degrade/restore 语义保留(其 12 项套件 green);preflight mode-independent 未动;CCR stamping / image arming / demoteGate / stableSystemAnchor 均按既有设计跟随 effective mode(KDD#7 双模式 carrier 语义不变)。未发现无意回归;有意行为变更(PR body 的 old→new 表)披露完整。一处文档措辞("duplicate tool declarations are rejected by providers")严格说不准确(injectTool/injectOpenaiTool/injectGoogleTool/injectResponsesTool 均对 bili-owned 名去重,重复声明到不了 provider),但细看可作「为何不支持 partial grant」的设计理由解读,且更替措辞会过claim,故不改——留档备查。 ⑤ 是否破坏缓存:不涉及——无 dedup key / 重试 / 增量游标变化;fallback child session 每请求 tools 数组稳定(role whitelist + 注入后缀),prefix cache 行为与其他 proxy-mode session 相同。 ⑥ 是否改了设计方向:不涉及——复用两条既有 lane,只加一个决策点;不绕过 pi-subagents 安全模型(bili 不要求 host 执行未声明工具);范围按 owner 决定限 nicobailon/pi-subagents。 ⑦ 是否引入新配置:不涉及——diff 不触碰 config surface;上游 kill switches( 结论:可合并。 rebased head |
[bot] 🏷 收到「上游 PR 冲突」唤醒——经查证是过期通知,本轮未做任何改动(按规则不重复 rebase)。 查证证据(刚执行):
结论:dirty 状态产生于我 rebase 之前(旧 head 七问速览(完整论证见上一条 review 回复):
判定维持:可合并。 #2276 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.99-master.c4e5954 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2268
Problem
pi-subagents' 7 builtin roles all ship strict frontmatter
tools:allowlists that grant none of the ACP context tool names. Since #2185's required-extension self-registration, those children get named plugin sessions but run in pure plugin mode with no local ACP tools and no wire injection — interactive compression silently regressed for default roles versus pre-#2185 (when FG children were anonymouspfa-*proxy-mode sessions whose ACP tools came from proxy wire injection).Fix
Per-request capability gate (
src/server/pi-subagent-channel.ts) wired at the singlepluginModedecision point insrc/server.ts: a plugin-stamped pi request that carries pi-subagents'<active_agent name="…">child marker AND exposes none of the bili-injectable tool names in its parsedtools[]is served through the existing proxy-style channel (wire-injected tools + nudge, server-side execution,acp_summarycarrier; CCR/image/demote gates follow the effective mode). Session identity stays plugin-bound (named session,pluginAgent=pi, stamping untouched). Stateless per request: mid-session whitelist changes self-heal on the next request.buildInProcessChildLaunch) for BOTH foreground and background hosts; the raw-body sniff is exact across all four wire shapes (marker bytes are never JSON-escaped). The alternative signalPI_SUBAGENT_CHILD=1exists only in the detached BG runner process — FG children don't have it.Behavior changes (old → new)
Reason for the change: restore pre-#2185 compression capability on top of #2185's identity, per owner direction ("最好默认注入,而不是改配置文件").
Accepted residual edges: config-renamed
absorb.toolName/ccr.toolNamecolliding with a role-whitelisted name (would keep such children on the plugin lane); partial grants remain unsupported.Config surface
None — no new config field, env var, or CLI flag. Existing kill switches (
BILLION_CONTEXT_PLUGIN=0,BILI_NATIVE_PI=0) suppress the whole native lane upstream of this gate.Tests
tests/pi-subagent-channel.test.ts(new): 11 tests — marker sniff (absent / JSON-escaped / truncated-at-buffer-end / history-echo leniency), tools walker across all four wire shapes (8 injectable names, near-miss names, malformed entries never throw), composition (delegate/oracle fall back; granted-compressstays plugin; untagged and non-pi never fall back) plus 4 real-HTTP rig cases against a live proxy instance.tests/e2e/e2e-native-pi.test.ts: two scenarios drive unmodified builtindelegatechildren through realpi-subagents@0.76.1(hermetic install into the workspace scratch dir, version pinned, skips cleanly when the registry is unreachable):acp_statusround trip executed server-side, the once-per-session fallback log with the extracted role name, parent-session plugin surface intact, and both sessions persisted withpluginAgent=pi.context:"fork"so the child inherits the transcript (the filler leaves the kernel's protected zone inside the child). Asserts a real model-invokedcompressfolded it server-side — receipt matches[Compressed m…–m… → N block(s), ~T tokens saved]— plus a post-foldacp_statusshowing the active block, and the compressed block persisted in the CHILD's named session.