Skip to content

Commit e8e29e7

Browse files
committed
fix: preserve compress input schema when pruning
1 parent 47017dc commit e8e29e7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/messages/prune.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const PRUNED_TOOL_OUTPUT_REPLACEMENT =
99
"[Output removed to save context - information superseded or no longer needed]"
1010
const PRUNED_TOOL_ERROR_INPUT_REPLACEMENT = "[input removed due to failed tool call]"
1111
const PRUNED_QUESTION_INPUT_REPLACEMENT = "[questions removed - see output for user's answers]"
12-
const PRUNED_COMPRESS_INPUT_REPLACEMENT =
13-
"[compress content removed - topic retained for reference]"
12+
const PRUNED_COMPRESS_SUMMARY_REPLACEMENT =
13+
"[summary removed to save context - see injected compressed block]"
1414

1515
export const prune = (
1616
state: SessionState,
@@ -109,8 +109,9 @@ const pruneToolInputs = (state: SessionState, logger: Logger, messages: WithPart
109109
continue
110110
}
111111
if (part.tool === "compress" && part.state.status === "completed") {
112-
if (part.state.input?.content !== undefined) {
113-
part.state.input.content = PRUNED_COMPRESS_INPUT_REPLACEMENT
112+
const content = part.state.input?.content
113+
if (content && typeof content === "object" && "summary" in content) {
114+
content.summary = PRUNED_COMPRESS_SUMMARY_REPLACEMENT
114115
}
115116
continue
116117
}

0 commit comments

Comments
 (0)