Repository navigation
feat: mechanically preserve subagent session ids in compression blocks (#481) - #482
ranxianglei wants to merge 3 commits into
Conversation
When a fold range contains opencode subagent dispatch tool messages whose content carries ses_... session ids, extract those ids from the folded originals and force-append them to the compression block summary as a machine appendix line ([acp-preserved:subagent-session] ...). The model never transcribes the id, so fidelity no longer depends on summary-writing quality. Inserted at the single block-creation site in applySingleRange (covers T1 folds and T2/T3 distillation uniformly) plus applyRefolds so refold-in-place cannot drop ids either. Source texts are live folded tool messages plus consumed blocks' summaries (tier distillation carries ids forward through summaries on pruned hosts). A transparency note is surfaced via result.notes when an appendix is appended.
Mechanical assertions per #481 acceptance criteria: whatever the model summary outputs, the full ses_ string exists verbatim in the stored block summary across fresh T1 folds, T2 distillation propagation, and refold-in-place; plus byte-identity pins (no ids / ids already present), prose-narrowing pin, dedup/order, and prefix-collision safety.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-482Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr482.tgz
npm install ./packageThis comment is automatically updated on each push. |
Reviewed PR #482 (head CI: all green on head — Direction (root cause): correct. Chain billion-context#1563 → bug issue (now living at billion-context#1702): the model transcribes opencode subagent Code review (
Regression review — existing behaviors on the touched paths:
Behavior change (flagged per owner policy): the stored block-summary format gains an opt-in machine line Tests (15 new, Diff cleanliness: 5 files, +684/−7, every line on-purpose (new module, barrel export, the two insertion points + notes wiring, one module-map doc line, tests). No unrelated churn, no mass whitespace, no lock/generated files. Clean. ✓ Two non-blocking caveats for the owner:
Verdict: code correct, well-tested, clean diff, CI green, direction sound, behavior change properly disclosed. This is a 中文摘要:审核了 PR #482(机械保真:折叠时由代码从工具消息中提取 opencode 子代理 |
What
Root-cause fix for #481 (parent: ranxianglei/billion-context#1563): when a fold range contains opencode subagent dispatch tool messages whose content carries
ses_...session ids, the kernel now mechanically extracts those ids from the folded originals and force-appends them to the compression block summary as a machine appendix line ([acp-preserved:subagent-session] <id>, <id>). The model never transcribes the id, so fidelity no longer depends on summary-writing quality.How
src/preserved-ids.ts: extractor registry (DEFAULT_FIDELITY_EXTRACTORS= word-boundary-anchoredses_[A-Za-z0-9]+, soses_ab/ses_abcdefstay distinct), source-text selection (tool-call / tool-result messages only — the directed dispatch-pair scope), dedup-preserving extraction, and an appendix builder that skips ids already present verbatim in the model summary.applySingleRange(covers T1 folds, lean-pack folds, and T2/T3 distillation uniformly) plusapplyRefolds(refold-in-place must not drop ids either). Source texts = live folded tool messages + consumed blocks' summaries (tier distillation carries ids forward through summaries on pruned hosts).result.notes(same channel as resolveBoundaries 静默交换反向引用,参数错误被伪装成内容错误 #310 reversal notes).Behavior change (flagged per owner policy)
[acp-preserved:subagent-session] ...— only when folded tool content containsses_ids missing from the model summary. No prompt / summary-writing rules changed; when nothing is extracted the output is byte-identical (pinned by tests). Cost: tens of bytes per affected fold. Side benefit: blocks become searchable by session id.Scope notes
Tests
tests/preserved-ids.test.ts(15 new) implements the issue's mechanical assertions: whatever the model summary outputs, the fullses_string exists verbatim in the stored block summary across fresh T1 folds, T2 distillation propagation, and refold-in-place; plus byte-identity pins (no ids / ids already present), prose-narrowing pin, dedup/order, and prefix-collision safety. On rebased head: typecheck clean, 1217/1217 tests pass, build OK, prettier clean.中文摘要:修复折叠摘要抄丢 opencode 子代理
ses_session id 的根因——折叠提交时由代码从被折叠工具消息中机械提取 id 并强制写入压缩块附录(模型不经手),T1/T2/refold 全通道覆盖,无论模型摘要写什么,id 逐字存活。Fixes #481