Skip to content

fix(child-session): pi-intercom 同装时 subagent_spawn 预检必挂——intercom 未进 CHILD_EXCLUDED_TOOL_NAMES #483

Closed

Description

@Matt-qwq

问题

@tt-a1i/openpi 与 pi-intercom 同时启用时,任何 subagent_spawn(含不带 agent_type 的普通子代理)都在首个模型请求前预检必挂:

Child tool preflight failed: requested tool "intercom" is unavailable after
child extensions initialized. Check the Agent Type tools list and child
extension loading.

#128 确立的 child exclusion 规则本身存在且应保留;本 Issue 是它的补缺:包被正确排除,工具名却漏进继承 allowlist,把「子会话不可用 intercom」变成「整个委托通道不可用」。

复现

  • 环境:@tt-a1i/openpi 0.7.0(实测);0.8.0 与 main 当前状态同样存在(2026-09-08 复核);pi-intercom 经 settings.json 同装。
  • 步骤:任意调用一次子代理即可,如
subagent_spawn({ name: "probe", prompt: "Reply OK" })

带或不带 agent_type 都失败;失败发生在扩展绑定后、模型收到提示词之前。

根因

extensions/shared/child-session.ts:

  • blockedPackageSources() 会把 pi-intercom 包整体从子会话的 settings/资源中剔除(其把会话身份存在 process.env,而 OpenPI children 是同进程并发 Session,加载它会串号——该排除属于真实运行时安全边界,#128 的「必须保留」项)。
  • 但 CHILD_EXCLUDED_TOOL_NAMES 没有收录 "intercom"。
  • subagents/index.ts 用 inheritedChildToolAllowlist(pi.getActiveTools(), …) 构造子代理 allowlist:凡是父会话激活、又不在排除表的工具都会被继承。intercom 在父会话激活且不在表内,于是进了子代理的请求清单。
  • bindChildSessionExtensions() 在扩展初始化后做预检:子会话没有 pi-intercom 包,永远无法提供 intercom,预检报错、spawn 终止。

即:包按 parent-only 处理了,工具名没有;边界检查把一次有意的排除升级成了整条委托通道的硬失败。

用户影响

  • pi-intercom 与 OpenPI 常见同装(一个管跨会话协调、一个管委托),同装即无法使用任何子代理;#128 让 OpenPI 不再主动安装 pi-intercom,但用户自行同装仍会命中。
  • 连带影响:OpenPI 的回归测试与 release 检查无法覆盖「顶层 Session 已装 intercom」的组合。

建议范围

最小修复——把 intercom 加进排除表:

// pi-intercom:包已被 blockedPackageSources 从子会话剔除,
// 继承 allowlist 不得泄漏其工具名
"intercom",

结构修复(更彻底)——给 pi.registerTool 增加 parent-only 声明能力,inheritedChildToolAllowlist 据此丢弃「所属包被从子会话剔除」的工具,替代手维护名单。

回归测试——在 drift guard / agent-types 测试中加一类用例:模拟某包被从 children 剔除、但其工具名在父会话激活,断言 spawn 不把该工具名带进 allowlist、且预检通过。

验收标准

  • 同装 pi-intercom 时,普通 subagent_spawn 与带 agent_type 的 spawn 均通过预检、正常执行。
  • 子会话仍无法加载/调用 intercom(#128 的隔离边界不回退)。
  • CHILD_EXCLUDED_TOOL_NAMES 含 intercom(或结构性方案令继承逻辑等价生效)。
  • 新增回归用例:被剔除包的激活工具名不进子 allowlist。
  • bun run check、bun run test 通过。

证据

Activity

  1. naivezip commented on Sep 8, 2026

    @naivezip
    Contributor

    我来认领这个issue

  2. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    Collaborator

    新证据(print-mode + 双树)

    源码对照,未安装、未运行 pi-intercom。研究记录(本工作树,未提交):docs/research/EXPERIMENT_CHILD_SESSION_2026-09-09.md。

    本 Issue 的挂起:对 0.8.1 成立,对本工作树默认 spawn 不成立

    inheritedChildToolAllowlist(pi.getActiveTools(), …) + blockedPackageSources() 在 @tt-a1i/openpi 0.8.1 / origin/main 0d17f45 存在。父会话激活 intercom → 继承 allowlist 点名该工具 → child settings 已摘包 → 预检把有意的排除升级成整条委托失败。Direct 与 Workflow 都投影父 active tools。这个根因句是对的。

    当前文档/实验对照的工作树是 a9b40f0(package.json 仍写 0.4.0):没有这两个函数,默认 subagent_spawn 不投影父 active tools。无 agent_type 时不设 allowlist,预检跳过。同装 intercom 不会在这条默认路径上预检必挂。过滤器只认 node_modules/pi-intercom 路径;git/local 安装漏过(#128 评论要求的三种 source,0.8.1 已做,此树未做)。

    PR #494 的测试布局是 tests/extensions/...,不能按路径 cherry-pick 进 a9b40f0。

    加 "intercom" 到排除表:能停挂起,不是身份根因

    0.8.1 上这是正确的 可见性 补丁。它不改变下面的运行时事实:

    • Direct / Workflow child 都是 bindChildSessionExtensions({ mode: "print" })。
    • Pi noOpUIContext:hasUI === false,confirm() 恒为 false,select/input/custom 为 undefined。
    • OpenPI 不发射 subagents:child:session-created,也 不设 PI_SUBAGENT_PARENT_SESSION 或任何 PI_INTERCOM_* / PI_SUBAGENT_*。

    因此 child 不能把确认弹到唯一 parent TUI。confirm() === false 是「无人可答」,不是「用户拒绝」。权限 ask 的转发在 #497,通道必须归 OpenPI、按 child id 寻址;不要用 intercom / contact_supervisor 当父子桥。

    为什么 intercom 仍必须 parent-only(即使预检修好)

    pi-intercom 0.13.0 在 session_start 写入进程级 process.env.PI_INTERCOM_SESSION_ID,shutdown 时按 该实例启动时 看到的值 restore。同进程并发 child 共享一份 env:后启动的 child 覆盖父身份,先退出的 child 把 env 恢复成错误的 sibling id。contact_supervisor 还靠一组 PI_SUBAGENT_*;OpenPI 从不设置。

    另外:工具路径 send 用 confirmSend && ctx.hasUI。print-mode 下 hasUI 为假 → 跳过确认并发送(fail-open)。outbox 路径才会 confirmation_unavailable。把包放进 child「好让它问人」会得到静默跨会话 send,不是 parent 对话框。

    漂移守卫

    本包工具未分类 → child-session.test.ts fail-closed。社区工具名 不进 这张扫描表。在 a9b40f0 把 "intercom" 写进 CHILD_EXCLUDED_TOOL_NAMES 会触发「排除表名字必须仍被本包注册」。#494 改守卫是改合同,不是一行名单。结构性修复仍是:继承投影丢掉「所属包已被 child 剔除」的工具,而不是为每个社区包手写一个排除名。

    不改 #128 的隔离结论。不引入新安装器。

  3. tt-a1i commented on Sep 9, 2026

    @tt-a1i
    Collaborator

    补一条:#483 的结构性修复 ≠ 第三方名录 / firewall

    不改本 Issue 的根因句(0.8.1 inherit 点名 intercom + blockedPackageSources 摘包 → 预检把有意排除升级成委托失败)。本对照树 a9b40f0 默认 spawn 不投影父 active,这条挂起在那边不成立。

    后续研究(未提交):docs/research/EXPERIMENT_THIRD_PARTY_CHILD_FILTER_2026-09-09.md。家在 #169 的「未分类 child fail-closed」,不是本票长出包黑名单。

    • PR fix(child-session): dynamically exclude blocked package tools from child inheritance (#483) #494 加 "intercom" 能停 这一次 0.8.1 挂起。它必须同时改双向漂移守卫(本包未注册的名字不能待在 CHILD_EXCLUDED_TOOL_NAMES)。不要把「排除表可以任意塞社区名」写成新合同。
    • 本 Issue 已经写过的结构性项——inherit 丢掉「所属包已被 child 剔除」的工具名——才对下一包可扩展。那是过滤器的 inherit 卫生层,不是 OpenPI 策展 dap/mcp/eval。
    • 用户自装 pi-dap / mcp-adapter / eval / browser 在两棵树上都会 load 进 child(资源闸只特判 intercom)。那是泄漏,不是本 Issue 的挂起;不要用再加一串排除名来「顺手修」。

    本轮未 pi install、未实现、未开新 Ideas。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions