File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -219,21 +219,11 @@ export async function handleSweepCommand(ctx: SweepCommandContext): Promise<void
219219 }
220220
221221 const tokensSaved = getTotalToolTokens ( state , newToolIds )
222- const originMessageId = getLastUserMessage ( messages ) ?. info . id || ""
223- if ( ! originMessageId ) {
224- logger . warn ( "Sweep prune origin unavailable - missing user message" )
225- }
226222
227223 // Add to prune list
228224 for ( const id of newToolIds ) {
229225 const entry = state . toolParameters . get ( id )
230226 state . prune . tools . set ( id , entry ?. tokenCount ?? 0 )
231- if ( originMessageId ) {
232- state . prune . origins . set ( id , {
233- source : "sweep" ,
234- originMessageId,
235- } )
236- }
237227 }
238228 state . stats . pruneTokenCounter += tokensSaved
239229 state . stats . totalPruneTokens += state . stats . pruneTokenCounter
Original file line number Diff line number Diff line change @@ -255,27 +255,6 @@ export function collectTurnNudgeAnchors(messages: WithParts[]): Set<string> {
255255 return anchors
256256}
257257
258- export function loadPruneOriginMap ( obj ?: Record < string , PruneOrigin > ) : Map < string , PruneOrigin > {
259- if ( ! obj || typeof obj !== "object" ) {
260- return new Map ( )
261- }
262-
263- const entries : [ string , PruneOrigin ] [ ] = [ ]
264- for ( const [ toolId , origin ] of Object . entries ( obj ) ) {
265- if (
266- origin &&
267- typeof origin === "object" &&
268- typeof origin . source === "string" &&
269- typeof origin . originMessageId === "string" &&
270- origin . originMessageId . length > 0
271- ) {
272- entries . push ( [ toolId , origin ] )
273- }
274- }
275-
276- return new Map ( entries )
277- }
278-
279258export function resetOnCompaction ( state : SessionState ) : void {
280259 state . toolParameters . clear ( )
281260 state . prune . tools = new Map < string , number > ( )
Original file line number Diff line number Diff line change @@ -83,21 +83,11 @@ export const deduplicate = (
8383 }
8484
8585 state . stats . totalPruneTokens += getTotalToolTokens ( state , newPruneIds )
86- const decisionMessageId = getLastUserMessage ( messages ) ?. info . id || ""
8786
8887 if ( newPruneIds . length > 0 ) {
89- if ( ! decisionMessageId ) {
90- logger . warn ( "Deduplication prune origin unavailable - missing user message" )
91- }
9288 for ( const id of newPruneIds ) {
9389 const entry = state . toolParameters . get ( id )
9490 state . prune . tools . set ( id , entry ?. tokenCount ?? 0 )
95- if ( decisionMessageId ) {
96- state . prune . origins . set ( id , {
97- source : "deduplication" ,
98- originMessageId : decisionMessageId ,
99- } )
100- }
10191 }
10292 logger . debug ( `Marked ${ newPruneIds . length } duplicate tool calls for pruning` )
10393 }
Original file line number Diff line number Diff line change @@ -76,20 +76,10 @@ export const purgeErrors = (
7676 }
7777
7878 if ( newPruneIds . length > 0 ) {
79- const decisionMessageId = getLastUserMessage ( messages ) ?. info . id || ""
80- if ( ! decisionMessageId ) {
81- logger . warn ( "Purge errors prune origin unavailable - missing user message" )
82- }
8379 state . stats . totalPruneTokens += getTotalToolTokens ( state , newPruneIds )
8480 for ( const id of newPruneIds ) {
8581 const entry = state . toolParameters . get ( id )
8682 state . prune . tools . set ( id , entry ?. tokenCount ?? 0 )
87- if ( decisionMessageId ) {
88- state . prune . origins . set ( id , {
89- source : "purgeErrors" ,
90- originMessageId : decisionMessageId ,
91- } )
92- }
9383 }
9484 logger . debug (
9585 `Marked ${ newPruneIds . length } error tool calls for pruning (older than ${ turnThreshold } turns)` ,
Original file line number Diff line number Diff line change @@ -105,20 +105,10 @@ export const supersedeWrites = (
105105 }
106106
107107 if ( newPruneIds . length > 0 ) {
108- const decisionMessageId = getLastUserMessage ( messages ) ?. info . id || ""
109- if ( ! decisionMessageId ) {
110- logger . warn ( "Supersede writes prune origin unavailable - missing user message" )
111- }
112108 state . stats . totalPruneTokens += getTotalToolTokens ( state , newPruneIds )
113109 for ( const id of newPruneIds ) {
114110 const entry = state . toolParameters . get ( id )
115111 state . prune . tools . set ( id , entry ?. tokenCount ?? 0 )
116- if ( decisionMessageId ) {
117- state . prune . origins . set ( id , {
118- source : "supersedeWrites" ,
119- originMessageId : decisionMessageId ,
120- } )
121- }
122112 }
123113 logger . debug ( `Marked ${ newPruneIds . length } superseded write tool calls for pruning` )
124114 }
You can’t perform that action at this time.
0 commit comments