Skip to content

Commit 0a6a80a

Browse files
committed
refactor: simplify and unify prune.ts check ordering
- 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
1 parent 9204bd2 commit 0a6a80a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/messages/prune.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ const pruneToolOutputs = (state: SessionState, logger: Logger, messages: WithPar
3232
if (!state.prune.toolIds.includes(part.callID)) {
3333
continue
3434
}
35-
// Skip write/edit (protected) and question (output contains answers we want to keep)
36-
if (part.tool === "write" || part.tool === "edit" || part.tool === "question") {
35+
if (part.state.status !== "completed") {
3736
continue
3837
}
39-
if (part.state.status === "completed") {
40-
part.state.output = PRUNED_TOOL_OUTPUT_REPLACEMENT
38+
if (part.tool === "question") {
39+
continue
4140
}
41+
42+
part.state.output = PRUNED_TOOL_OUTPUT_REPLACEMENT
4243
}
4344
}
4445
}
@@ -59,8 +60,11 @@ const pruneToolInputs = (state: SessionState, logger: Logger, messages: WithPart
5960
if (part.state.status !== "completed") {
6061
continue
6162
}
63+
if (part.tool !== "question") {
64+
continue
65+
}
6266

63-
if (part.tool === "question" && part.state.input?.questions !== undefined) {
67+
if (part.state.input?.questions !== undefined) {
6468
part.state.input.questions = PRUNED_QUESTION_INPUT_REPLACEMENT
6569
}
6670
}

0 commit comments

Comments
 (0)