Skip to content

Commit e576934

Browse files
committed
fix: remove orphaned prune origin tracking from dev-only commits
1 parent 30a1b56 commit e576934

5 files changed

Lines changed: 0 additions & 61 deletions

File tree

lib/commands/sweep.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff 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

lib/state/utils.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff 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-
279258
export function resetOnCompaction(state: SessionState): void {
280259
state.toolParameters.clear()
281260
state.prune.tools = new Map<string, number>()

lib/strategies/deduplication.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff 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
}

lib/strategies/purge-errors.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff 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)`,

lib/strategies/supersede-writes.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)