Repository navigation
fix: hold remembered anchor snapshot against auxiliary <=2-message views (#1307) - #1308
ranxianglei wants to merge 1 commit into
Conversation
…ews (#1307) Host auxiliary prompts (DSH auto-review / classifier / title-gen) share the main session key but send no tools and <=2 messages with a NORMAL output budget, so isSideRequest()'s budget<=200 test misses them and they run the full pipeline. rememberPluginMessages then unconditionally overwrote the established anchor snapshot with the tiny view; the plugin compress tool reads its refs from that snapshot, so every other ref dangled and compress failed deterministically with "Requested range(s) cannot be anchored". Guard the write point: skip the overwrite when the incoming view is <=2 messages and strictly smaller than the established snapshot. A genuine main turn always carries the full history, so this never fires for one. Accepted cost: a native-compaction shrink to <=2 is deferred one turn and self-heals on the next normal request. Root-cause pipeline isolation (routing these requests to passthrough) is deliberately out of scope here: it collides with #1075's locked-in behavior (auxiliary single-message requests consuming exactly one ref) and the orphan-GC sub-layer is ambiguous to gate by size alone. Tracked separately.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1308Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1308.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR review complete — mergeable. I did not redo the work; I pulled ① Original issue (#1307) — direction gate: passThe bug report carries deterministic prod evidence (163/163 compress failures at ctx==1 vs 62/62 otherwise; §3.5 A/B where guarded-only copy makes compress succeed). This PR implements exactly the issue's recommended Fix A (guard at the write point where the unconditional ② Regression audit — existing behaviors on touched paths
Edge cases checked: fresh session ( ③ Code reviewGuard condition, log line format, and the ④ Test validity — teeth confirmed, red-state independently reproducedAssertions are exact (snapshot lengths, log containment, forwarded-once count), not tautologies. I reproduced the red-state locally myself: disabling the guard → exactly the 2 new tests fail (unit + anthropic-wire e2e), 14 others still pass; restoring → 16/16 green. The e2e exercises the real pipeline path (full request → prepare → remember) on an established session, which is what pins the regression. ⑤ Diff cleanliness & CI3 files, +106/−3, single commit, every line serves the fix/tests/seam. CI: all 11 checks green (test matrix ubuntu/windows × node 22/24, e2e codex, hermetic registry, pi lane, version-guard, build-artifact). Local: typecheck clean, target suite 16/16, build success. Remaining known gaps are out of scope by design and tracked: the orphan-GC deactivation layer (3 consecutive aux requests can silently deactivate blocks) and the #1075/#1307 policy contradiction — both in #1309 pending owner decision. Merge is yours to make. 中文摘要:修复了辅助请求(auto-review/classifier/title-gen,≤2 条消息+正常预算)冲掉 plugin 会话锚点快照导致 |
|
Superseded by #1312 — the owner's implementation fixes the same root cause in |
What
rememberPluginMessagesnow holds the established anchor snapshot when an incoming view is ≤2 messages and strictly smaller than the snapshot already stored for the session, instead of overwriting it.Why — #1307
Host auxiliary prompts (DSH auto-review / classifier / title-gen) share the main conversation's session key but send no tools and ≤2 messages with a normal output budget. So
isSideRequest()'smax_tokens<=200test misses them and they run the full pipeline. The pipeline unconditionally callsrememberPluginMessages, which overwrote the main session's anchor snapshot with this 1-message view. The plugincompresstool reads its refs from that snapshot, so every other ref dangled andcompressfailed deterministically:Author's prod log: 163/163 compress failures when the last-seen context was 1 message, 62/62 success otherwise.
Fix (write-point guard)
Guard the write point rather than classifying requests upstream: skip the overwrite when
incoming.length <= 2 && previousLength > incoming.length. A genuine main turn always carries the full history, so this never fires for one. A matching info log line makes the skip observable (remembered snapshot kept (N msgs > M): …). This is the minimal fix validated by the author's own §3.5 A/B experiment (a guarded-only copy madecompresssucceed).Behavior change (flagged per review policy)
Regression tests (
tests/side-request-isolation.test.ts)Both tests fail without the guard (verified by disabling it) and pass with it.
Pre-flight
npm run typecheck: cleannpm test: 2561 tests, 0 fail, 10 skippednpm run build: successOut of scope (deferred — needs owner decision)
The root-cause fix would route these auxiliary requests to the existing side-passthrough branch (no refs / usage / nudge / orphan-GC / snapshot update). That is deliberately not done here because:
byRaw 24→25). Any size/shape-based passthrough for this shape breaks that test; the zero-overlap discriminator has the same collision.proxy-orphan-gc.test.tscases use 1–2-message visible sets to model genuine client-deletion orphaning.Recommend a follow-up issue to design a unified auxiliary-request isolation policy across #1075 / #1307 / orphan-GC.
Fixes #1307