From c258918b3cbca7d540485f31d0888c22a51631b9 Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Thu, 11 Dec 2025 11:45:31 -0500 Subject: [PATCH 1/2] Fix case-sensitive tool ID comparison in pruning logic Previously, tool call IDs were compared using case-sensitive includes() checks, which could cause re-processing of already pruned tools if the same ID appeared with different casing from different providers. This change normalizes IDs to lowercase before comparison using a Set for efficient O(1) lookups instead of O(n) array includes() calls. --- lib/core/janitor.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/janitor.ts b/lib/core/janitor.ts index 55772acf..27bbd858 100644 --- a/lib/core/janitor.ts +++ b/lib/core/janitor.ts @@ -116,7 +116,9 @@ async function runWithStrategies( const { toolCallIds, toolOutputs, toolMetadata } = parseMessages(messages, state.toolParameters) const alreadyPrunedIds = state.prunedIds.get(sessionID) ?? [] - const unprunedToolCallIds = toolCallIds.filter(id => !alreadyPrunedIds.includes(id)) + // Normalized set for filtering to avoid re-processing already pruned tools with different casing + const alreadyPrunedLower = new Set(alreadyPrunedIds.map(id => id.toLowerCase())) + const unprunedToolCallIds = toolCallIds.filter(id => !alreadyPrunedLower.has(id)) const gcPending = state.gcPending.get(sessionID) ?? null @@ -145,7 +147,7 @@ async function runWithStrategies( ) } - const finalNewlyPrunedIds = llmPrunedIds.filter(id => !alreadyPrunedIds.includes(id)) + const finalNewlyPrunedIds = llmPrunedIds.filter(id => !alreadyPrunedLower.has(id.toLowerCase())) if (finalNewlyPrunedIds.length === 0 && !gcPending) { return null From 56c2305c86f9369ab0e3c31b7671837b30357a2e Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Thu, 11 Dec 2025 11:45:45 -0500 Subject: [PATCH 2/2] v0.4.17 - Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index cb2d1dc3..a6c3dcde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@tarquinen/opencode-dcp", - "version": "0.4.16", + "version": "0.4.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@tarquinen/opencode-dcp", - "version": "0.4.16", + "version": "0.4.17", "license": "MIT", "dependencies": { "@ai-sdk/openai-compatible": "^1.0.28", diff --git a/package.json b/package.json index 0606f04e..ffb7bb1a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@tarquinen/opencode-dcp", - "version": "0.4.16", + "version": "0.4.17", "type": "module", "description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context", "main": "./dist/index.js",