Skip to content

Commit c636534

Browse files
committed
improve log summary: show pruned/candidates and kept count
- Change denominator from total tools to available candidates (excludes protected) - Add 'X kept' to show how many tool outputs remain unpruned - Example: 'Pruned 5/5 tools, 0 kept (~4.2K tokens)'
1 parent 275dcb2 commit c636534

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/janitor.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ export class Janitor {
129129
const deduplicatedIds = dedupeResult.duplicateIds
130130
const deduplicationDetails = dedupeResult.deduplicationDetails
131131

132+
// Calculate candidates available for pruning (excludes protected tools)
133+
const candidateCount = unprunedToolCallIds.filter(id => {
134+
const metadata = toolMetadata.get(id)
135+
return !metadata || !this.protectedTools.includes(metadata.tool)
136+
}).length
137+
132138
// ============================================================
133139
// PHASE 2: LLM ANALYSIS (only runs in "smart" mode)
134140
// ============================================================
@@ -288,11 +294,12 @@ export class Janitor {
288294
await this.stateManager.set(sessionID, allPrunedIds)
289295

290296
// Log final summary
291-
// Format: "Pruned 2/6 tools (~4.2K tokens)" or "Pruned 2/6 tools (1 duplicate, 1 llm) (~4.2K tokens)"
297+
// Format: "Pruned 5/5 tools (~4.2K tokens), 0 kept" or with breakdown if both duplicate and llm
292298
const prunedCount = finalNewlyPrunedIds.length
299+
const keptCount = candidateCount - prunedCount
293300
const hasBoth = deduplicatedIds.length > 0 && llmPrunedIds.length > 0
294301
const breakdown = hasBoth ? ` (${deduplicatedIds.length} duplicate, ${llmPrunedIds.length} llm)` : ""
295-
this.logger.info("janitor", `Pruned ${prunedCount}/${toolCallIds.length} tools${breakdown} (~${formatTokenCount(tokensSaved)} tokens)`)
302+
this.logger.info("janitor", `Pruned ${prunedCount}/${candidateCount} tools${breakdown}, ${keptCount} kept (~${formatTokenCount(tokensSaved)} tokens)`)
296303

297304
} catch (error: any) {
298305
this.logger.error("janitor", "Analysis failed", {

0 commit comments

Comments
 (0)