From 0a6a80aad27f95cb7ee5d9c2c623d565d5ce4b18 Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Tue, 13 Jan 2026 01:43:04 -0500 Subject: [PATCH] refactor: simplify and unify prune.ts check ordering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove redundant write/edit checks (already protected via config) - Use consistent continue pattern for tool-specific filtering - Standardize check ordering: type → toolIds → status → tool-specific --- lib/messages/prune.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/messages/prune.ts b/lib/messages/prune.ts index 8b95e45..f224ce1 100644 --- a/lib/messages/prune.ts +++ b/lib/messages/prune.ts @@ -32,13 +32,14 @@ const pruneToolOutputs = (state: SessionState, logger: Logger, messages: WithPar if (!state.prune.toolIds.includes(part.callID)) { continue } - // Skip write/edit (protected) and question (output contains answers we want to keep) - if (part.tool === "write" || part.tool === "edit" || part.tool === "question") { + if (part.state.status !== "completed") { continue } - if (part.state.status === "completed") { - part.state.output = PRUNED_TOOL_OUTPUT_REPLACEMENT + if (part.tool === "question") { + continue } + + part.state.output = PRUNED_TOOL_OUTPUT_REPLACEMENT } } } @@ -59,8 +60,11 @@ const pruneToolInputs = (state: SessionState, logger: Logger, messages: WithPart if (part.state.status !== "completed") { continue } + if (part.tool !== "question") { + continue + } - if (part.tool === "question" && part.state.input?.questions !== undefined) { + if (part.state.input?.questions !== undefined) { part.state.input.questions = PRUNED_QUESTION_INPUT_REPLACEMENT } }