Repository navigation
[PR] fix(pi): inject acp_delegate appendix via appendSystemPrompt (order-independent, #2531) - #2536
Closed
ranxianglei wants to merge 2 commits into
Closed
ranxianglei wants to merge 2 commits into
ranxianglei wants to merge 2 commits into
Conversation
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2763-pr.2536.6a1f3c4This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2536.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Owner
Author
|
继续 看上面消息 |
added 2 commits
October 10, 2026 09:33
…endent, #2531) Injecting the acp_delegate appendix by returning a full { systemPrompt } replacement from before_agent_start forces the prompt on pi >= 0.87 (a returned systemPrompt maps to forceSystemPrompt, whose buildSystemPromptState returns only the forced text and silently drops every other extension's structured appendSystemPrompt — load-order dependent, #2531 / billion-context-pi#630). Compose through systemPromptOptions.appendSystemPrompt instead when the event exposes the newer getter shape; keep the byte-identical replacement fallback for pi <= 0.86. Detection is by event shape (accessor vs data property on systemPrompt), not version number, so it holds across the whole supported range. Idempotent per options object. Covers both deployment modes: bili's native pi lane (src/agent/pi-subagents.ts) and the standalone factory (pi-subagents/).
ranxianglei
force-pushed
the
2026-10-09_pi-delegate-append-order-independent
branch
from
October 10, 2026 01:40
5d83b4d to
a6e0935
Compare
Owner
Author
[bot] 🏷 继续完成本 PR 的核验与收尾。结论:已 rebase 到当前 master、修复版本冲突、CI 26/26 全绿,可合并(merge 由人执行)。 本轮做了什么
结构化八问
行为变更披露(有意变更):pi ≥ 0.87 上,acp_delegate 附录注入方式由「强制替换系统提示(会丢弃其他扩展的 append)」变为「经 判定:可合并——rebase 至最新 master、guard 冲突已解、CI 全绿、mergeable。请 owner 自行 merge:#2536 |
Owner
Author
|
(ai: zhipuai-lb/glm-5.3) 孤儿票清理:空挑验证——分支对 master 已无独立提交(内容已全部落地)。关单;误判请 reopen。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
On pi >= 0.87 the
before_agent_startevent exposessystemPromptas a live getter, and returning{ systemPrompt }from a handler maps toforceSystemPrompt. Pi'sbuildSystemPromptState()returns only the forced text whenforceSystemPromptis set — so every other extension's structuredappendSystemPromptaddendum is silently dropped. Coexistence became load-order dependent: it only worked when this extension loaded last (so our getter read had already captured their append into the forced text).The acp_delegate injection did exactly this anti-pattern in two places:
src/agent/pi-subagents.ts— bili native pi lane wiringpi-subagents/src/index.ts— standalone factoryBoth returned a full
{ systemPrompt }replacement built fromevent.systemPrompt.Verified against real pi tarballs: 0.83.0 uses a plain data-property + consumes the returned replacement directly (safe, no drop); 0.87.1 / 0.99.0 / 1.1.0 use the getter + forceSystemPrompt path (the drop). Runtime pi is the user's install (peerDep
*, not pinned), so the fix must hold across the whole range.Fix
New helper
injectSystemPromptAppendix(event, block)(inpi-subagents/src/compat.ts, exported from the package):systemPrompt): compose throughevent.systemPromptOptions.appendSystemPrompt(idempotent guard), return nothing → no force → all extensions' appends survive, order-independent.{ systemPrompt }replacement as before.Detection is by event shape (accessor vs data property), not version number, so it holds across every published pi version. Used by both deployment sites.
Behavior change (intended)
forceSystemPrompt) — drops other extensions' appends unless we load lastappendSystemPrompt— coexists with third-party appends, order-independentThis is the fix, not a regression: the old behavior was the load-order-dependent data loss reported in #2531.
Package version
billion-context-pi-subagentsbumped 0.1.3 → 0.1.4 (Pi-Subagents Boundary rule: any change underpi-subagents/src/**requires a version bump).Tests
pi-subagents/tests/system-prompt-composition.test.ts(6 cases: older string/array → replacement; newer getter → mutates append + returns undefined; idempotency; prior-append preservation; missing-options no-op).tests/pi-subagents-wiring.test.tsdriving the real host handler with a getter event (asserts prior harness append preserved + ACP_DELEGATE appended, idempotent). Existing old-path test still green.All green on rebased master: root typecheck, pi-subagents typecheck, wiring 17/17, unit 6/6, pi-subagents suite 229/229.
Scope
References #2531 (migrated from billion-context-pi#630). This fixes the in-repo instance of the mechanism — the acp_delegate surface in the vendored
pi-subagents/and its bili host wiring. The primary reported subject, the standalonebillion-context-pipackage'sbuildAcpSystemPrompt, lives in the external repo ranxianglei/billion-context-pi (open PR #631 there) and is out of scope for this PR.