Repository navigation
fix(pi-subagents): commit delegate completion notifications at the model's next safe boundary (#2320) - #2389
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2613-pr.2389.87c763aThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2389.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR #2389 review 结论(结构化八问) ① 是什么问题:Pi 交互模式下 ② 什么原因导致:旧实现把「投递时机」和「投递载体」耦合在 settle 事件 + ③ 影响范围与严重程度:所有 Pi 交互/RPC 会话里用 async delegate 的用户;特定条件下有问题——子任务完成而主任务仍在长跑时,结果无法及时参与当前工作(重复劳动、失败处理延迟、用户误判)。非死锁,时序级影响。standalone 与内嵌两条 lane 都受影响。 ④ 怎么修复的:两层提交,均把「所有权复查(waiter/consumed/read-suppression)挪到提交发生的同一同步段内」:
⑤ 是否有回归问题:对触碰路径的既有行为逐项清点——
⑥ 是否破坏缓存:不涉及(bili proxy 前缀缓存路径未触碰;本改动在 Pi 扩展 lane 内)。 ⑦ 是否改了设计方向:有,属 issue 内已议定的设计落地:通知提交模型从「settle 门控 + 宿主队列」转向「边界提交(busy=上下文内联 / idle=steering 起轮)」。数据流未变(结果文件仍是持久事实源)。 ⑧ 是否引入新配置:无。 行为变更披露(旧→新):
验证证据(本地定向,非全量预跑):pi-subagents 套件 223/223 过;typecheck+build 干净; 代码审查要点:宿主侧契约已对 pinned 0.83.0 源码核实—— 小发现处置:per-host 状态表的强引用枚举集 判定:可合(待 windows 两个 test job 转绿即可;唯一建议项是 PR 描述补 busy 层一次性注入的披露句)。 |
|
pull下master subagent已经复制进来了 |
…del's next safe boundary (#2320) Completion notifications were parked in Pi's host queue via sendUserMessage(deliverAs: "followUp") behind an agent_settled gate, so they stayed invisible until the main task ended even though delegate results are usually the current task's input. Two-tier commit, tracked per host: - busy: a revocable pending set is re-checked at the `context` extension event (fires before every LLM call) and one merged notification is appended to the outgoing context mid-task; nothing enters an irreversible host queue, so late wait/read suppression keeps working right up to the commit - idle: one merged steering message starts the follow-up turn Intended behavior change: old = notification delivered only after the main task ends (follow-up queue); new = delivered at the next safe boundary while the task runs, or immediately when idle. Per-host state is isolated (WeakMap); hosts without a `context` event degrade to the former settle-gated path with steering delivery instead of followUp. pi-subagents 0.1.2 -> 0.1.3. Adds tests/e2e/e2e-delegate-notify.test.ts (real pi RPC through the embedded lane, gated by ACP_TEST_E2E_NATIVE; ci-e2e-native.yml now runs it) asserting actual model-consumption timing from the upstream oracle: mid-task consumption with work remaining afterwards, and idle auto-start without further input. Unit layer: pi-subagents suite 223/223 (new delegate-context-notify.test.ts pins both tiers, merge/suppression/gate/isolation/wake semantics). Supersedes ranxianglei/billion-context-pi-subagents#9 (opened before the #2384 in-repo vendoring).
d07c13a to
b3c4039
Compare
[bot] 🏷 已 rebase 到最新 master 并推送(八问摘要) 收到同步提示后执行:
PR 状态已转干净:mergeable=True,head=b3c40395a,与 master 无冲突(当前 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.150-master.74a55c6 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2320
What & why
In Pi interactive mode, async
acp_delegatecompletion notifications were parked in the host's follow-up queue behind anagent_settledgate, so they stayed invisible until the main task ended — even though delegate results are usually the current task's input. The issue asked for delivery at the next safe boundary while the main task runs.This implements the full design agreed in the issue thread (both layers), in-repo after the #2384 vendoring:
Mechanism (
pi-subagents/src/delegate-tool.ts)Two-tier commit, tracked per host (
WeakMapstate; a host without the extension surface degrades gracefully):contextextension event, which fires before every LLM call (verified against the pinned host 0.83.0:ContextEvent.messages→ handler may returnContextEventResult.messages). At each boundary one merged notification is appended directly to the outgoing context mid-task. Because nothing enters an irreversible host queue, latewait/final-filereadsuppression keeps working right up to the commit — the post-commit staleness window of [Bug][Pi] notifyIfRead="skip" still delivers stale follow-ups after the final result was read #2301 closes at its source on this path (zero async gap between re-check and commit).Preserved unchanged: coalescing into one message per boundary, send-failure recovery via the undelivered-runs scan, usage dedup, read-suppression for completed runs only (failed runs always notify), waiter/consumed/injected ownership, session-scoped run tracking.
Gate semantics: the busy tier only appends when the context already contains an assistant message (mid-turn rebuild); contexts without one defer to the next commit point with the queue intact.
Intended behavior change (disclosed)
contexteventfollowUpsendNo new config surface. No change to other hosts' lanes (omp excluded as before; print/JSON still downgrade async→sync so no notification paths fire there).
Version
pi-subagents0.1.2 → 0.1.3 (in-repo component; CI-enforced boundary rule). Lockfile carries the one-line echo.Verification
pi-subagents/tests/delegate-context-notify.test.ts(9 cases) pins both tiers: mid-task commit into the next model call, read-before-boundary drop, failed-always-notifies, two-finishes-one-message merge, non-assistant deferral, waiter exclusion, two-host isolation, idle single/batch steering wakes.delegate-tool.test.tsgains a pin that both legacy send paths usedeliverAs: "steer".tests/e2e/e2e-delegate-notify.test.ts, same hermetic conventions ase2e-native-pi(realpi --mode rpcthrough the embedded lane against the deterministic fake upstream; gated byACP_TEST_E2E_NATIVE=1; artifacts under gitignoredtmp/). Two scenarios, asserted from the upstream request oracle:queueIdx < totalDirectiveswith bash rounds continuing afterwards, and the host queue never parks it (pendingMessageCountstays 0);Both pass locally (real pi 0.83.x) and are now wired into
ci-e2e-native.ymlalongside the native-pi suite.dist/agent/pi-native.js).Relationship to #2301
Complementary, not redundant: #7 (already on master) gates when the plugin commits; this changes where the committed bytes land. On the busy tier the notification never reaches an irreversible queue, which removes the "committed but then claimed" race window that #2301 documents; the idle tier keeps a single re-check immediately before the steering send.
Notes
e2e-native-pi's hermetic npm install of the original package) exercises different packaging but the identicaldelegate-tool.tssource; the shared mechanism is pinned by the unit layer, the embedded-lane timing by the new e2e.