@@ -228,7 +228,7 @@ export class Janitor {
228228 // Filter LLM results to only include IDs that were actually candidates
229229 // (LLM sometimes returns duplicate IDs that were already filtered out)
230230 const rawLlmPrunedIds = result . object . pruned_tool_call_ids
231- llmPrunedIds = rawLlmPrunedIds . filter ( id =>
231+ llmPrunedIds = rawLlmPrunedIds . filter ( id =>
232232 prunableToolCallIds . includes ( id . toLowerCase ( ) )
233233 )
234234
@@ -263,7 +263,7 @@ export class Janitor {
263263
264264 // Calculate which IDs are actually NEW (not already pruned)
265265 const finalNewlyPrunedIds = Array . from ( expandedPrunedIds ) . filter ( id => ! alreadyPrunedIds . includes ( id ) )
266-
266+
267267 // finalPrunedIds includes everything (new + already pruned) for logging
268268 const finalPrunedIds = Array . from ( expandedPrunedIds )
269269
@@ -338,16 +338,16 @@ export class Janitor {
338338 const shortenedPath = this . shortenSinglePath ( pathPart )
339339 return `${ prefix } in ${ shortenedPath } `
340340 }
341-
341+
342342 return this . shortenSinglePath ( input )
343343 }
344-
344+
345345 /**
346346 * Shorten a single path string
347347 */
348348 private shortenSinglePath ( path : string ) : string {
349349 const homeDir = require ( 'os' ) . homedir ( )
350-
350+
351351 // Strip working directory FIRST (before ~ replacement) for cleaner relative paths
352352 if ( this . workingDirectory ) {
353353 if ( path . startsWith ( this . workingDirectory + '/' ) ) {
@@ -358,7 +358,7 @@ export class Janitor {
358358 return '.'
359359 }
360360 }
361-
361+
362362 // Replace home directory with ~
363363 if ( path . startsWith ( homeDir ) ) {
364364 path = '~' + path . slice ( homeDir . length )
@@ -375,7 +375,7 @@ export class Janitor {
375375 const workingDirWithTilde = this . workingDirectory . startsWith ( homeDir )
376376 ? '~' + this . workingDirectory . slice ( homeDir . length )
377377 : null
378-
378+
379379 if ( workingDirWithTilde && path . startsWith ( workingDirWithTilde + '/' ) ) {
380380 return path . slice ( workingDirWithTilde . length + 1 )
381381 }
@@ -396,15 +396,15 @@ export class Janitor {
396396 if ( prunedIds . length === 0 ) return messages
397397
398398 const prunedIdsSet = new Set ( prunedIds . map ( id => id . toLowerCase ( ) ) )
399-
399+
400400 return messages . map ( msg => {
401401 if ( ! msg . parts ) return msg
402-
402+
403403 return {
404404 ...msg ,
405405 parts : msg . parts . map ( ( part : any ) => {
406- if ( part . type === 'tool' &&
407- part . callID &&
406+ if ( part . type === 'tool' &&
407+ part . callID &&
408408 prunedIdsSet . has ( part . callID . toLowerCase ( ) ) &&
409409 part . state ?. output ) {
410410 // Replace with the same placeholder used by the global fetch wrapper
@@ -427,20 +427,20 @@ export class Janitor {
427427 */
428428 private async calculateTokensSaved ( prunedIds : string [ ] , toolOutputs : Map < string , string > ) : Promise < number > {
429429 const outputsToTokenize : string [ ] = [ ]
430-
430+
431431 for ( const prunedId of prunedIds ) {
432432 const output = toolOutputs . get ( prunedId )
433433 if ( output ) {
434434 outputsToTokenize . push ( output )
435435 }
436436 }
437-
437+
438438 if ( outputsToTokenize . length > 0 ) {
439439 // Use batch tokenization for efficiency (lazy loads gpt-tokenizer)
440440 const tokenCounts = await estimateTokensBatch ( outputsToTokenize )
441441 return tokenCounts . reduce ( ( sum , count ) => sum + count , 0 )
442442 }
443-
443+
444444 return 0
445445 }
446446
@@ -501,7 +501,7 @@ export class Janitor {
501501 const toolText = totalPruned === 1 ? 'tool' : 'tools'
502502
503503 let message = `🧹 DCP: Saved ~${ tokensFormatted } tokens (${ totalPruned } ${ toolText } pruned)`
504-
504+
505505 // Add session totals if there's been more than one pruning run
506506 if ( sessionStats . totalToolsPruned > totalPruned ) {
507507 message += ` │ Session: ~${ formatTokenCount ( sessionStats . totalTokensSaved ) } tokens, ${ sessionStats . totalToolsPruned } tools`
@@ -536,15 +536,15 @@ export class Janitor {
536536
537537 const toolText = deduplicatedIds . length === 1 ? 'tool' : 'tools'
538538 let message = `🧹 DCP: Saved ~${ tokensFormatted } tokens (${ deduplicatedIds . length } duplicate ${ toolText } removed)`
539-
539+
540540 // Add session totals if there's been more than one pruning run
541541 if ( sessionStats . totalToolsPruned > deduplicatedIds . length ) {
542542 message += ` │ Session: ~${ formatTokenCount ( sessionStats . totalTokensSaved ) } tokens, ${ sessionStats . totalToolsPruned } tools`
543543 }
544544 message += '\n'
545545
546546 // Group by tool type
547- const grouped = new Map < string , Array < { count : number , key : string } > > ( )
547+ const grouped = new Map < string , Array < { count : number , key : string } > > ( )
548548
549549 for ( const [ _ , details ] of deduplicationDetails ) {
550550 const { toolName, parameterKey, duplicateCount } = details
@@ -603,7 +603,7 @@ export class Janitor {
603603 const tokensFormatted = formatTokenCount ( tokensSaved )
604604
605605 let message = `🧹 DCP: Saved ~${ tokensFormatted } tokens (${ totalPruned } tool${ totalPruned > 1 ? 's' : '' } pruned)`
606-
606+
607607 // Add session totals if there's been more than one pruning run
608608 if ( sessionStats . totalToolsPruned > totalPruned ) {
609609 message += ` │ Session: ~${ formatTokenCount ( sessionStats . totalTokensSaved ) } tokens, ${ sessionStats . totalToolsPruned } tools`
@@ -615,7 +615,7 @@ export class Janitor {
615615 message += `\n📦 Duplicates removed (${ deduplicatedIds . length } ):\n`
616616
617617 // Group by tool type
618- const grouped = new Map < string , Array < { count : number , key : string } > > ( )
618+ const grouped = new Map < string , Array < { count : number , key : string } > > ( )
619619
620620 for ( const [ _ , details ] of deduplicationDetails ) {
621621 const { toolName, parameterKey, duplicateCount } = details
@@ -652,15 +652,15 @@ export class Janitor {
652652 }
653653 }
654654 }
655-
655+
656656 // Handle any tools that weren't found in metadata (edge case)
657657 const foundToolNames = new Set ( toolsSummary . keys ( ) )
658658 const missingTools = llmPrunedIds . filter ( id => {
659659 const normalizedId = id . toLowerCase ( )
660660 const metadata = toolMetadata . get ( normalizedId )
661661 return ! metadata || ! foundToolNames . has ( metadata . tool )
662662 } )
663-
663+
664664 if ( missingTools . length > 0 ) {
665665 message += ` (${ missingTools . length } tool${ missingTools . length > 1 ? 's' : '' } with unknown metadata)\n`
666666 }
0 commit comments