Skip to content

Commit 42f3116

Browse files
authored
Merge pull request #115 from Tarquinen/fix/case-insensitive-tool-id-matching
Fix case-sensitive tool ID comparison in pruning logic
2 parents 8d30228 + 56c2305 commit 42f3116

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/core/janitor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ async function runWithStrategies(
116116
const { toolCallIds, toolOutputs, toolMetadata } = parseMessages(messages, state.toolParameters)
117117

118118
const alreadyPrunedIds = state.prunedIds.get(sessionID) ?? []
119-
const unprunedToolCallIds = toolCallIds.filter(id => !alreadyPrunedIds.includes(id))
119+
// Normalized set for filtering to avoid re-processing already pruned tools with different casing
120+
const alreadyPrunedLower = new Set(alreadyPrunedIds.map(id => id.toLowerCase()))
121+
const unprunedToolCallIds = toolCallIds.filter(id => !alreadyPrunedLower.has(id))
120122

121123
const gcPending = state.gcPending.get(sessionID) ?? null
122124

@@ -145,7 +147,7 @@ async function runWithStrategies(
145147
)
146148
}
147149

148-
const finalNewlyPrunedIds = llmPrunedIds.filter(id => !alreadyPrunedIds.includes(id))
150+
const finalNewlyPrunedIds = llmPrunedIds.filter(id => !alreadyPrunedLower.has(id.toLowerCase()))
149151

150152
if (finalNewlyPrunedIds.length === 0 && !gcPending) {
151153
return null

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/package.json",
33
"name": "@tarquinen/opencode-dcp",
4-
"version": "0.4.16",
4+
"version": "0.4.17",
55
"type": "module",
66
"description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context",
77
"main": "./dist/index.js",

0 commit comments

Comments
 (0)