Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/fetch-wrapper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ export function installFetchWrapper(

// Run deduplication after handlers have populated toolParameters cache
const sessionId = state.lastSeenSessionId
if (sessionId && state.toolParameters.size > 1) {
if (sessionId && state.toolParameters.size > 0) {
const toolIds = Array.from(state.toolParameters.keys())
const alreadyPruned = state.prunedIds.get(sessionId) ?? []
const alreadyPrunedLower = new Set(alreadyPruned.map(id => id.toLowerCase()))
const unpruned = toolIds.filter(id => !alreadyPrunedLower.has(id.toLowerCase()))
if (unpruned.length > 1) {
const { duplicateIds } = detectDuplicates(state.toolParameters, unpruned, config.protectedTools)
if (duplicateIds.length > 0) {
state.prunedIds.set(sessionId, [...new Set([...alreadyPruned, ...duplicateIds])])
// Normalize to lowercase to match janitor's ID normalization
const normalizedIds = duplicateIds.map(id => id.toLowerCase())
state.prunedIds.set(sessionId, [...new Set([...alreadyPruned, ...normalizedIds])])
}
}
}
Expand Down