Repository navigation
feat(compaction): L2 history snip — drop stale tool scaffolding (M4.2… - #27
Merged
Merged
Conversation
… / v4) Layer 2 of the v4 pipeline: a deterministic stage that drops stale tool SCAFFOLDING. In the stale zone (outside the root task and the recent window) it snips oversized tool_result content to a tiny marker — the dominant token cost of old tool turns — while leaving tool_use blocks (tiny), prose/reasoning text, and user turns alone. Pairing is always safe (blocks are snipped in place, never removed) and the artifactPath is preserved so the full output stays restorable. The layer separation is the point: L2 reclaims only the cheap, low-value tool apparatus; prose/reasoning is intentionally untouched because that is L5's job (semantic recap). The cascade is now [spill, snip, reclaim]. Because L1 spill and L2 snip both target tool scaffolding, a fixture whose whale is a stale tool_result would get reclaimed before the semantic layer runs — so the semantic-compaction eval task and the M3.2c query integration test now seed an assistant PROSE whale instead, which L1/L2 skip and only L5 can condense. That is the correct layer separation and keeps the eval fingerprint unchanged (prose replaces tool_result; scripted usage is the same). - core: snipStaleToolScaffolding + SnipScaffoldingOptions (context.ts); query loop inserts the snip stage between spill and reclaim. - tests: 2 new L2 unit tests (snips stale tool_result, leaves prose/tool_use/ root/recent; preserves artifactPath in the marker); two compaction fixtures retargeted to prose whales. - docs: CLAUDE.md query-loop step 7 lists L2; v4 roadmap M4.2 delivered. 232 tests pass (+2); all 10 eval tasks green, fingerprint unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
… / v4)
Layer 2 of the v4 pipeline: a deterministic stage that drops stale tool SCAFFOLDING. In the stale zone (outside the root task and the recent window) it snips oversized tool_result content to a tiny marker — the dominant token cost of old tool turns — while leaving tool_use blocks (tiny), prose/reasoning text, and user turns alone. Pairing is always safe (blocks are snipped in place, never removed) and the artifactPath is preserved so the full output stays restorable.
The layer separation is the point: L2 reclaims only the cheap, low-value tool apparatus; prose/reasoning is intentionally untouched because that is L5's job (semantic recap). The cascade is now [spill, snip, reclaim].
Because L1 spill and L2 snip both target tool scaffolding, a fixture whose whale is a stale tool_result would get reclaimed before the semantic layer runs — so the semantic-compaction eval task and the M3.2c query integration test now seed an assistant PROSE whale instead, which L1/L2 skip and only L5 can condense. That is the correct layer separation and keeps the eval fingerprint unchanged (prose replaces tool_result; scripted usage is the same).
232 tests pass (+2); all 10 eval tasks green, fingerprint unchanged.