Skip to content

fix(child-session): exclude intercom from child tool allowlist (#483) - #494

Open
naivezip wants to merge 1 commit into
openpi-dev:mainfrom
naivezip:develop
Open

fix(child-session): exclude intercom from child tool allowlist (#483)#494
naivezip wants to merge 1 commit into
openpi-dev:mainfrom
naivezip:develop

Conversation

@naivezip

@naivezip naivezip commented Sep 8, 2026

Copy link
Copy Markdown

Problem

Fixes #483.
@tt-a1i/openpipi-intercom 同时启用时,任何 subagent_spawn(含不带 agent_type 的普通子代理)及 Workflow 子会话均在首个模型请求前预检必挂:

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

根因在于:child-session.tsblockedPackageSources() 已正确将 pi-intercom 从子会话的配置/资源中剔除(防止 process.env 会话身份在同进程并发子会话间串号),但 CHILD_EXCLUDED_TOOL_NAMES 未收录 "intercom"。导致 inheritedChildToolAllowlist(pi.getActiveTools(), ...) 将父会话中激活的 intercom 漏入子代理的请求工具清单,而子会话未加载该包,最终导致 bindChildSessionExtensions() 预检抛错、启动中断。

Value

修复 OpenPI 与常用跨会话协调扩展 pi-intercom 同装时的子会话委托功能,使普通 subagent_spawn、指定 agent_type 的子代理以及 Workflow 均能顺利通过预检并正常执行,同时完整保留 #128 确立的并发安全隔离边界。

Approach

  • extensions/shared/child-session.tsCHILD_EXCLUDED_TOOL_NAMES 中增加 "intercom",使 inheritedChildToolAllowlisteffectiveChildToolAllowlistchildToolPolicy 始终将 intercom 排除在子会话工具之外。
  • 更新 tests/extensions/shared/child-session.test.ts 中的漂移保护测试(drift guard),排除被安全策略屏蔽的第三方包工具,并断言 CHILD_EXCLUDED_TOOL_NAMES 包含 "intercom"
  • 更新 tests/extensions/shared/tool-surface.test.ts,在比较 OpenPI 包工具目录与子会话策略时过滤非 OpenPI 所有的第三方屏蔽工具 "intercom"
  • 更新 tests/extensions/subagents/agent-types.test.ts,确保在 agent-type 中声明 intercom 时正确报告为 parent-only 工具并忽略。
  • tests/extensions/shared/child-session.test.ts 中增加回归用例:模拟父会话激活 intercom,断言继承与显式 allowlist 均丢弃 intercom,且子会话预检正常通过。

Validation

  • node --test --experimental-strip-types tests/extensions/shared/child-session.test.ts:20/20 通过(包含漂移保护、工具继承、及新增的被剔除包工具回归测试)。
  • node --test --experimental-strip-types tests/extensions/shared/tool-surface.test.ts:9/9 通过。
  • node --test --experimental-strip-types tests/extensions/subagents/agent-types.test.ts:22/22 通过。
  • node --test --experimental-strip-types tests/extensions/subagents/index.test.ts:16/16 通过。
  • node --test --experimental-strip-types tests/extensions/subagents/pi-backend.test.ts:5/5 通过。
  • node --test --experimental-strip-types tests/extensions/workflows/runner.test.ts:26/26 通过。
  • node scripts/check-config-contract.mjs:通过(15 个持久化字段契约检查)。
  • node scripts/check-discipline-ledger.mjs:通过(12 行 Discipline Ledger 检查)。
  • npx biome formatnpx biome lint --error-on-warnings:通过,无警告或错误。
  • git diff upstream/main..HEAD:确认仅变更与 Issue fix(child-session): pi-intercom 同装时 subagent_spawn 预检必挂——intercom 未进 CHILD_EXCLUDED_TOOL_NAMES #483 相关的 4 个文件(61 行新增,5 行修改)。

Impact

  • 用户可见行为:同装 pi-intercom 时子代理和 Workflow 正常启动,不再报预检错误。
  • 模型可见上下文/工具:子代理上下文不再出现 intercom 工具定义。
  • Runtime/lifecycle:保持 fail-closed 隔离边界不变,子会话不加载 pi-intercom
  • 持久化配置/数据:无变更。
  • 兼容性与风险:极低,仅完善了已在 blockedPackageSources 中被排除包的工具名单过滤。

…i-dev#483)

pi-intercom is excluded from child sessions via blockedPackageSources to prevent concurrent process.env session cross-wiring, but its tool was not included in CHILD_EXCLUDED_TOOL_NAMES.

As a result, inheritedChildToolAllowlist leaked "intercom" into child sessions when active in the parent session, causing subagent_spawn and workflow runs to fail preflight checks.

Add "intercom" to CHILD_EXCLUDED_TOOL_NAMES so child allowlists consistently exclude it, update drift guard and tool-surface tests, and add regression coverage for child preflight pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:subagents Subagent delegation, skills, or tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant