Skip to content

Stop stripping tool results from turns compaction chose to keep - #361

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-5595-strip-kept-turns
Aug 7, 2026
Merged

Stop stripping tool results from turns compaction chose to keep#361
TheGreatAxios merged 2 commits into
mainfrom
cl-5595-strip-kept-turns

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

createPruningCompactor applied stripResultContent to both anchorTurns and recentTurns — the exact turns compaction decided to keep — not just the discarded middle. A file edit pulled forward as an anchor, or one sitting two turns back in the live recent window, had its tool_result content replaced with a [... chars omitted from context; source unchanged.] stub. Anchors exist specifically to survive pruning because they're load-bearing; hollowing them out right after selecting them defeats the point.

Judgment call

Stripping kept turns was never a coherent design: recentTurns is documented in the same function as turns that "keep live base64 so a just-pasted screenshot still reaches the model," which only makes sense if the rest of the turn's content also survives. The discarded middle (summarizedTurns) already loses its content wholesale, folded into the [Compacted prior context] summary — there was no scenario where a second, per-turn stripping pass over the kept turns was doing useful work. So this deletes stripResultContent and its stub-building machinery (buildCallIndex, buildResultStub, stripTurnResults, ToolCallInfo) rather than gating it behind a flag. Genuine tool errors were never touched by this path (stripTurnResults already skipped isError === true blocks) and remain untouched now that the whole path is gone.

Net change: -85/+16 lines — pure removal plus a version bump on the compactor record.

Test plan

  • Added two failing tests reproducing the bug (tool_result content lost from a recent-window turn, and from an anchored turn pulled forward from the discarded middle) — both failed against the old code, both pass now
  • bun run typecheck
  • bun run build
  • bun run test — 3984 pass, 1 pre-existing unrelated failure (lsp-availability.test.ts, environment-dependent, fails identically on origin/main)

Anchors and recent turns are pulled forward or held back specifically
because they matter; stubbing their tool_result content right after
undermines the reason they survived pruning. Deletes stripResultContent
and the stub-building machinery it required rather than gating it off,
since the discarded middle already loses its content wholesale via the
summary and never needed a second stripping pass.
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

CL-5595

@TheGreatAxios
TheGreatAxios merged commit 967ba4e into main Aug 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant