Repository navigation
Replies: 3 comments
|
zero-loss pruning(spill-copy-on-prune)——压缩时保留完整工具结果的副本,比直接剪枝稳(剪了还能找回)。 和 compaction 的"summary 后仍可回溯"理念一致,第 14 章上下文/成本管理可作参考:https://github.com/Electricitysheep/dsh-handbook/blob/main/docs/14-cost.md |
|
Thanks for the reference — the traceability principle is exactly the insight here. We benchmarked this with 19 live sessions (glm-5.3 + deepseek-v4-flash): the prune tier saves 72–88% uncached prefill tokens while the spill copy makes the pruned middle recoverable via |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Proposal: Zero-loss pruning (spill-copy-on-prune)
Context
DeepSeek Harness's
compaction-tool-result-pruner(threshold 8192, head 4096, tail 1024) andspill-policy(maxInlineBytes 50000) are independent mechanisms:[... tool result middle pruned ...]— no recovery path.The prune tier's permanent loss is by design but unnecessary — the spill infrastructure already exists.
Proposal
Merge the tiers: when the prune tier fires, also write the full output to a spill file (same
ctx.spillStore), and include the file path + exact elided span[start, end)in the marker. The middle is dropped from context (same context savings) but recoverable from disk (zero information loss).Marker upgrade
Current:
[... tool result middle pruned ...]Proposed (with spill copy):
The short prefix at position 0 survives compaction serialization (which truncates tool results to 2000 chars). The full marker in the middle gives exact offsets for precise recovery. The model uses these to
greporsed -n 'START,ENDp'the spill file.Recovery-loop prevention
readresults targeting a file inside the spill directory should pass through untouched — otherwise reading a spill file to recover the pruned middle would re-prune it (infinite loop).Evidence
Benchmarked with 19 live sessions (glm-5.3 + deepseek-v4-flash) using a pi extension implementing this design:
Key finding: a deepseek-v4-flash model, given a 30K fake test log with an AssertionError at position 12K (in the pruned middle), recovered the correct root cause by
grep-ing the spill file forFAIL|AssertionErrorthensed-ing the exact lines. Zero hallucination — the marker's omission count made the loss legible.Implementation notes
This is a plugin-level change in dsh's architecture — the pruner plugin would call
ctx.spillStorebefore dropping the middle. No core changes needed (everything is a plugin). Thedsh-plugintopic exists for this kind of contribution.Config:
pruneSpillCopy: boolean(default true; false reverts to current permanently-lossy behaviour for disk-constrained environments).Files
~/.pi/agent/extensions/tool-result-pruner/— 32 tests, tsc clean/tmp/pi-bench/— prompts, driver, analyzer, 19 session transcriptsAll reactions