From 27207e544e1961a4494b2b217425496ee82f8caf Mon Sep 17 00:00:00 2001 From: bil9148 <2knchill@gmail.com> Date: Sun, 22 Feb 2026 18:00:19 +0100 Subject: [PATCH] fix(core): clear tool output and attachments on compaction prune prune() sets time.compacted but leaves the full output string and attachments in the part. Since toModelMessages already replaces compacted output with '[Old tool result content cleared]', the stored data is never used after compaction but still gets loaded from disk into memory on every prompt loop iteration. Clear both fields when pruning so they are not reloaded on subsequent iterations, reducing memory pressure in long sessions. --- packages/opencode/src/session/compaction.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/opencode/src/session/compaction.ts b/packages/opencode/src/session/compaction.ts index 9245426057c..7a69c1a1a32 100644 --- a/packages/opencode/src/session/compaction.ts +++ b/packages/opencode/src/session/compaction.ts @@ -91,6 +91,8 @@ export namespace SessionCompaction { for (const part of toPrune) { if (part.state.status === "completed") { part.state.time.compacted = Date.now() + part.state.output = "" + part.state.attachments = [] await Session.updatePart(part) } }