Repository navigation
fix(pi-subagents): persist delegate completion notifications via turn_end steering (#2546) - #2550
Conversation
…_end steering (#2546) The busy-tier commit appended the notification to the `context` event's outgoing message list — request-local by design: pi restores the original state afterward, so the message lived in exactly one request and vanished from later ones. On stateful upstreams that resume live sessions by comparing the echoed transcript this dropped the session off its cache (full history replay); the model also lost the runId/result-path from its own history. Commit at `turn_end` instead — the moment a turn's tool execution finishes, right before the agent loop drains steering for the next LLM call — and send ONE merged notification through sendUserMessage(steer), the same persisted carrier the idle tier already used. Delivery timing is unchanged (next LLM call after completion); the final ownership re-check is equally fresh (claims can only happen inside tool execution, which ends before turn_end), so the #2301 post-commit race stays closed and #2320's mid-task timing holds. A failed send keeps the batch scheduled for the next boundary. pi-subagents 0.1.3 -> 0.1.4
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2729-pr.2550.ba1afcfThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2550.tgz
npm install -g packageInstall instructions are refreshed on each push. |
PR #2550 审查结论(独立复核) 这是我先前开的 PR(#2546 thread 已给出首轮结论)。本轮按 review 规范做独立复核:拉分支通读 diff、逐项清点既有行为、核对测试牙齿、独立查 CI。base 已是当前 master(merge-base == master head,非 stale);单提交、5 文件,全部落在 delegate 通知机制内,diff 干净无跑题、无空白/重排噪音。 结构化八问
测试有效性:单测( CI(独立查 head 81fdd84):关键门禁全绿—— 判定:方向正确、根因修复、既有行为逐项保持、测试有牙、diff 干净、载荷 e2e 已绿。待最后 2 个 Windows 矩阵 job 转绿即可合并。我不代合,请 owner 自行 merge:#2550 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.194-master.063e567 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2546
Problem
While the parent was mid-task, the pi plugin delivered async
acp_delegatecompletion notifications through pi's request-localcontextevent (commitAtContextBoundary): one merged user message appended to the outgoing message list of exactly ONE request — pi restores the original state afterward. The message was never written to the session, so:Fix
Commit at
turn_endinstead — the moment a turn's tool execution finishes, right before the agent loop drains steering for the next LLM call — and send ONE merged notification throughsendUserMessage(steer), the same persisted carrier the idle tier already used. Both tiers now share one mechanism, differing only in trigger point.Why everything the
contextboundary provided is preserved:turn_end; no await between check and enqueue.turn_endor the idle flush), mirroring the idle tier's recovery discipline.The old assistant-message gate is gone by design:
turn_endfires only for this host's real agent-loop turns, and steering delivery is session-global (there is no per-call message list that auxiliary calls could consume).Behavior change (intended — this is the fix)
pendingMessageCountmay transiently be 1 during the task (between theturn_endcommit and the loop's drain, one macrotask apart); it was 0 before. Quiescence still requires it back to 0.Tests
pi-subagents/tests/delegate-context-notify.test.ts→delegate-turn-end-notify.test.ts: busy-tier tests now driveturn_endand assert on captured steering sends; new test: a failed send keeps the batch scheduled and recoverable via the undelivered-runs path. Idle-tier tests unchanged.tests/e2e/e2e-delegate-notify.test.ts(real pi RPC lane, deterministic fake upstream):notifCount(tests/e2e/fake-upstream-chat.mjs): user messages carrying an[acp_delegatenotification per request;notifCount >= 1) — pins the acp_delegate completion notifications are injected via pi's request-local context event, so they vanish from later requests and break stateful upstream sessions #2546 persistence property (the buggy path shows it in exactly one row);maxPending == 0→maxPending <= 1: transient steering parking is now the mechanism itself; stacking above 1 would mean double-queued notifications.pi-subagents 0.1.3 → 0.1.4 (CI-enforced version discipline).