Skip to content

Commit 296ed70

Browse files
committed
more cleanup
1 parent e2c92d8 commit 296ed70

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

lib/core/janitor.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ async function runWithStrategies(
139139
const alreadyPrunedIds = state.prunedIds.get(sessionID) ?? []
140140
const unprunedToolCallIds = toolCallIds.filter(id => !alreadyPrunedIds.includes(id))
141141

142-
// Get pending GC stats (accumulated since last notification)
143142
const gcPending = state.gcPending.get(sessionID) ?? null
144143

145-
// If nothing to analyze and no GC activity, exit early
146144
if (unprunedToolCallIds.length === 0 && !gcPending) {
147145
return null
148146
}
@@ -170,23 +168,20 @@ async function runWithStrategies(
170168

171169
const finalNewlyPrunedIds = llmPrunedIds.filter(id => !alreadyPrunedIds.includes(id))
172170

173-
// If AI pruned nothing and no GC activity, nothing to report
174171
if (finalNewlyPrunedIds.length === 0 && !gcPending) {
175172
return null
176173
}
177174

178175
// PHASE 2: CALCULATE STATS & NOTIFICATION
179176
const tokensSaved = await calculateTokensSaved(finalNewlyPrunedIds, toolOutputs)
180177

181-
// Get current session stats, initializing with proper defaults
182178
const currentStats = state.stats.get(sessionID) ?? {
183179
totalToolsPruned: 0,
184180
totalTokensSaved: 0,
185181
totalGCTokens: 0,
186182
totalGCTools: 0
187183
}
188184

189-
// Update session stats including GC contribution
190185
const sessionStats: SessionStats = {
191186
totalToolsPruned: currentStats.totalToolsPruned + finalNewlyPrunedIds.length,
192187
totalTokensSaved: currentStats.totalTokensSaved + tokensSaved,
@@ -195,7 +190,6 @@ async function runWithStrategies(
195190
}
196191
state.stats.set(sessionID, sessionStats)
197192

198-
// Send unified notification (handles all scenarios)
199193
const notificationSent = await sendUnifiedNotification(
200194
ctx.notificationCtx,
201195
sessionID,
@@ -210,12 +204,10 @@ async function runWithStrategies(
210204
currentAgent
211205
)
212206

213-
// Clear pending GC stats after notification (whether sent or not - we've consumed them)
214207
if (gcPending) {
215208
state.gcPending.delete(sessionID)
216209
}
217210

218-
// If we only had GC activity (no AI pruning), return null but notification was sent
219211
if (finalNewlyPrunedIds.length === 0) {
220212
if (notificationSent) {
221213
logger.info("janitor", `GC-only notification: ~${formatTokenCount(gcPending?.tokensCollected ?? 0)} tokens from ${gcPending?.toolsDeduped ?? 0} deduped tools`, {

0 commit comments

Comments
 (0)