Repository navigation
feat(recommend): structure-aware range selection (#344) - #345
ranxianglei wants to merge 2 commits into
Conversation
Keep candidate ranges out of in-progress turns and out of segments that cannot fold alone: - computeOpenTurnMemberIds excludes turns holding a tool-call with no tool-result anywhere (live or partially-complete burst) from the compressible set; - per-contiguous-segment foldability refinement re-runs the integrity gate per segment until stable, so no advertised range splits a call/result pair or a reasoning/call turn across an interior gap. Triggers (decideNudge) untouched; config schema unchanged; self-contained histories converge in one no-op pass (byte-identical output); deterministic.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-345Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr345.tgz
npm install ./packageThis comment is automatically updated on each push. |
[bot] 🏷 Reviewed PR #345 (branch Diff & base. Single commit on top of current master ( Technical verification (traced, not just read):
Tests. All 10 new tests map to the #344 acceptance list (open tail, partial burst, sequential live call, 2 legacy pins, interior-gap sandwich, merged-batch boundary, double-run determinism). Ran locally on node 22.23.2: One fix pushed during review — Interaction with #343 — agrees with the description: this sits upstream of merging (message-list level), #343 fixes Ready to merge — per repo rules I can't merge myself. Please merge when you're happy: #345 中文摘要:核对了 diff(单 commit、仅 recommend.ts + 新测试,基于最新 master)并本地复跑 typecheck/879 测试/build 全绿;逐条验证了开放轮次排除与段内可折叠性两个启发式的正确性与收敛性;review 中直接补了一个 commit 把新增代码按仓库 prettier 风格格式化(未动 master 既有漂移),新 head CI 已绿——可以合并。 |
Closes #344
What
Pressure compression now picks candidate ranges that respect content structure, per #344 (from billion-context#1122: keep usage-band triggers, improve which ranges fold under pressure). Two deterministic heuristics in
buildCompressibleRanges, no side-model, no config change:computeOpenTurnMemberIds(messages): a tool-call with no tool-result anywhere in the array marks its whole turn group (reasoning run + burst + paired results) as a gap. A live tail turn or a partially-complete parallel burst is no longer folded mid-sequence; range endpoints stop before it. The triggering user message stays compressible (no wire-level pairing constraint on user messages; recent-zone defaults already protect the tail).computeIntegrityWithdrawalsuntil stable (hard cap 8 passes; every productive pass removes ≥1 message so real sessions converge in a few). Withdrawn members become gaps. This closes the case the whole-set screen cannot see: a call/result pair or a reasoning/call turn split by an interior gap (protected tool, zone edge), where today's code advertises ranges the apply-side fold gate always empties.What is deliberately unchanged
decideNudgeusage-band/pressure branches untouched (issue item 3).recommendedRanges; status surfaces stay consistent because refinement happens insidebuildCompressibleRanges.Acceptance mapping (#344)
tests/recommend-structure-aware.test.ts(open tail, partial burst, sequential call→result→live-call variant).applyCompression.Verification (rebased head, node 22)
npm run typecheck✅npm test✅ 879/879 (incl. 10 new)npm run build✅format:checknot part of CI (ci.yml runs typecheck/test/build); note: prettier 3.9.6 (resolves from the unpinned^3.3.0) flags 115 files on pristine master — pre-existing drift, left untouched here to keep the diff clean.Interaction with PR #343
#343 fixes
mergeRangesToThreshold(batching never bridges block gaps). This work sits upstream of merging, at the message-list level, so the two compose: this PR guarantees each pre-merge segment is individually foldable, #343 guarantees batches don't span block gaps. If #343 merges first I'll rebase this onto it.中文摘要:实现了结构感知的压缩范围选择——进行中(未闭合)的工具调用轮次不再被纳入可压缩候选,段内切分点保证每个推荐范围单独可折叠;触发条件与配置 schema 未动,自洽历史输出与现状逐字节一致,879 项测试全绿,可以合并。