Skip to content

feat(delegate): auto stand-down acp_delegate when pi-subagents is detected (#415) - #416

Merged
ranxianglei merged 3 commits into
masterfrom
2026-09-13_third-party-subagent-standdown
Sep 14, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-09-13_third-party-subagent-standdown

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

What

Issue #415:检测到第三方 subagent(pi-subagents)时自动停用 acp_delegate + 强制开启配置 + 压缩启用提醒。

按 #415 的 review 意见修订为作用域区分设计,并 rebase 到 master @ 0ebecee(含 #412 快捷键可配置化 / #414 / #409 opt-out 文档与测试)。

行为(优先级矩阵,已锁进测试)

条件 结果
delegate.enabled: false(显式,含布尔简写) 关 —— 显式配置永远赢
delegate.forceEnable: true 或 env PI_ACP_DELEGATE_FORCE_ENABLE=true 开 —— 无视检测结果
检测到项目级 pi-subagents(<cwd>/.pi/npm 或项目内 extensions) 关(stand down)+ 结构化日志 delegate-auto-disabled(含命中的安装路径)+ 每进程一次醒目提醒(TUI notify / headless console.error),指向 /acp-subagents
仅检测到用户级(全局)安装 保持启用 + 一条 delegate-user-scope-detected 警告日志(不打 TUI 通知)——避免一次全局安装让所有项目失去 acp_delegate
未检测 正常注册

改动

  • src/setup-subagent-tools.ts:新增 findPiSubagentsInstalls(agentDir, cwd) 返回 {user[], project[]};原 findPiSubagentsInstall 改用共享 helper,优先级语义不变(/acp-subagents 命令继续用它)
  • src/config.ts:DelegateConfig.forceEnable → DelegatePolicy.forceEnable;新增 resolveForceEnable(env, cfg)——env > 配置值,坏值回退配置值并告警(与其他 delegate 字段的 env 约定一致)
  • src/index.ts:session_start 检测门控(enabled && !forceEnable):项目级命中 → runtime.delegateStoodDown = true + 结构化日志 + 一次性提醒;仅用户级命中 → 只记警告。工具/快捷键注册门与 wireSystemPrompt 门都引用该标志(与 fix(delegate): configurable fleet-inspector shortcut + move default off ctrl+alt+f (#412) #414 的 DelegatePolicy 驱动注册合并)
  • src/runtime.ts:delegateStoodDown 标志
  • 测试:tests/config.test.ts +5(默认值 / env 优先 / 坏值回退 / 显式关赢过 forceEnable);tests/integration.test.ts +5(项目级 stand-down 全链路:工具+快捷键+提示段+提醒 / 仅用户级保持启用 / forceEnable 保留 / 显式关赢过 forceEnable / 无检测回归)。快捷键断言改跟 DEFAULT_FLEET_SHORTCUT(Extension shortcut conflict: ctrl+alt+f hard-coded in both billion-context-pi (ACP) and pi-subagents #412 把默认键挪到 ctrl+alt+d)
  • 文档:README(+zh-CN) install 段(作用域语义 + forceEnable);CONFIGURATION(+zh-CN) delegate.forceEnable 节(含生效时机:提示段按 turn 立即消失、工具移除需新会话——沿用 [docs] delegate 开关已存在但不可发现:README 只引导「卸载 pi-subagents」,缺少「保留自己的 subagent」路径 #409 表述)+ env 表行 + 每-env-var 小节;CHANGELOG

验证

  • npm run typecheck ✓
  • npm test:813 pass / 0 fail ✓
  • npm run build ✓(dist 自包含)

前提核对(review 第 1 条)

核对了当前 pi-subagents@0.67.0(npm latest):自我描述为 "single-agent delegation and scripted multi-agent workflows";子代理是普通 Pi 会话(前台跑在父进程内、后台跑在 detached runner 里),README/文档中没有任何自带上下文压缩/裁剪机制 → 不存在竞争性的上下文管理器,重叠纯粹在委派系统(fleet 检查器 / spawn 路径 / inspector 快捷键,即 #412)。自动 stand-down + 提醒跑 /acp-subagents 接上压缩的正当性成立。

Closes #415

@ranxianglei

Copy link
Copy Markdown
Owner Author

解决冲突

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

冲突已解决并推送到分支 2026-09-13_third-party-subagent-standdown(merge commit be63a20,master dd183bd 合入)。

Conflicts (3 files):

  • src/index.ts (wireSystemPrompt, ~line 646): master's prompt-pack surface resolution (resolveActivePack/mergeSurface/setPrompts risk gate, buildAcpSystemPrompt(runtime.prompts, merged.promptSections), merged.delegatePrompt) and this PR's stand-down gate touched the same block. Kept the full prompt-pack logic and folded in the gate: const delegate = resolveDelegate(runtime.adapter).enabled && !runtime.delegateStoodDown; — so a stood-down session gets no delegate section regardless of which pack's delegatePrompt is active.
  • src/runtime.ts (return object, ~line 572): master refactored the inline nudge-tracking arrows to named function refs (markNudgeShown, …) and added deriveChildState: deriveChild; HEAD had added the delegateStoodDown flag + getter/setter. Took master's structure and re-added let delegateStoodDown = false; with its accessors. Interface field AcpRuntime.delegateStoodDown was already auto-merged.
  • CHANGELOG.md: both sides appended entries under Unreleased — kept both, stand-down entry on top.

Everything else auto-merged cleanly.

Verification (on the merged tree):

  • npm run typecheck ✅
  • npm ci (picks up master's bumps: package 0.1.68, acp-kernel 0.0.66) + npm run build ✅
  • npm test: 797 tests — 794 pass / 0 fail / 3 pre-existing skips ✅
  • Merge commit diff vs master is exactly the PR's original 10 files — no stray changes.

PR should now show as mergeable.


中文摘要:把 master(含 prompt-pack、宿主多会话 #364/#367 等 57 个提交)合入 PR 分支,解决了 src/index.ts / src/runtime.ts / CHANGELOG.md 三处冲突——prompt-pack 新逻辑与 delegate stand-down 门控在 wireSystemPrompt 中叠加共存;typecheck/build/测试(797 例,0 失败)全部通过,已推送,可以合并。

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Extension Artifact

Branch: 2026-09-13_third-party-subagent-standdown (9e17740)

Option A — Install from npm PR tag (recommended)

pi install npm:billion-context-pi@pr-416

Each push to this PR publishes a new version under the pr-416 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pi-pr416.tgz
pi install ./package

This comment is automatically updated on each push.

ework-agent added 2 commits September 13, 2026 17:32
…scope warn-only) + PI_ACP_DELEGATE_FORCE_ENABLE env + priority-matrix tests (#415 review)
@ranxianglei
ranxianglei force-pushed the 2026-09-13_third-party-subagent-standdown branch from be63a20 to 5a761b4 Compare September 13, 2026 09:45
@ranxianglei

Copy link
Copy Markdown
Owner Author

冲突了

Only CHANGELOG.md conflicted: keep both Unreleased entries (this PR's
delegate stand-down entry first, then master's toolOutputMaxBytes 50KB
default from #421). Also normalized a formatting typo in master's entry
(leading space -> proper '- ' bullet).

src/index.ts / src/config.ts / CONFIGURATION*.md auto-merged cleanly;
delegate stand-down gate intact in session_start, shortcut registration,
and wireSystemPrompt.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

又同步了一次:master 在分支 rebase 之后又前进了(8eba367 = v0.1.69 release + #434 status-surface-meta + #426 toolOutputMaxBytes 50KB + #427 rule-slot overrides),已合入并推送,merge commit 9e17740。

Conflict: CHANGELOG.md only. Both sides appended to the Unreleased section — kept both entries (this PR's delegate stand-down entry first, then master's toolOutputMaxBytes 50KB entry from #421). While resolving I also normalized a formatting typo in master's entry (it started with a bare space instead of a - bullet) — that's the only non-merge line in this commit.

Everything else auto-merged cleanly:

  • src/index.ts: stand-down gate intact at all three sites — session_start detection (src/index.ts:247), shortcut registration guard (src/index.ts:255, delegatePolicy.enabled && !runtime.delegateStoodDown), and wireSystemPrompt (src/index.ts:677).
  • src/config.ts, CONFIGURATION.md(+zh-CN), README(+zh-CN) auto-merged.

Verification on the merged tree:

  • npm ci (package 0.1.69, acp-kernel 0.0.69) ✅
  • npm run typecheck ✅
  • npm run build ✅
  • npm test: 817 tests — 814 pass / 0 fail / 3 pre-existing skips ✅

PR 现在应该显示可合并了。


中文摘要:master 又前进了(v0.1.69 等 4 个 PR),再次合入分支,仅 CHANGELOG.md 冲突(双方各加了一条 Unreleased 条目,两条都保留,顺手把 master 那条的列表符号格式修正);typecheck/build/测试(817 例,0 失败)全过,已推送 9e17740,可以合并。

@ranxianglei
ranxianglei merged commit ebdfcd4 into master Sep 14, 2026
9 checks passed
HangxiangMa pushed a commit to HangxiangMa/billion-context-pi that referenced this pull request Sep 21, 2026
…party-subagent-standdown

feat(delegate): auto stand-down acp_delegate when pi-subagents is detected (ranxianglei#415)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] 检测到第三方 subagent(pi-subagents)时自动停用 acp_delegate + 强制开启配置 + 压缩启用提醒

1 participant