Skip to content

Commit 2cf576b

Browse files
committed
fix: prevent protected tools from being pruned
1 parent cecaff1 commit 2cf576b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/prompts/tool.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Prunes tool outputs from context to manage conversation size and reduce noise.
22

33
## IMPORTANT: The Prunable List
4-
A `<prunable-tools>` list is injected into user messages showing available tool outputs you can prune. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). Use these numeric IDs to select which tools to prune.
4+
A `<prunable-tools>` list is injected into user messages showing available tool outputs you can prune. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). You MUST only use numeric IDs that appear in this list to select which tools to prune.
55

66
## CRITICAL: When and How to Prune
77

lib/strategies/prune-tool.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ export function createPruneTool(
7171
const currentAgent: string | undefined = findCurrentAgent(messages)
7272
const toolIdList: string[] = buildToolIdList(messages)
7373
const pruneToolIds: string[] = getPruneToolIds(numericToolIds, toolIdList)
74+
.filter(id => {
75+
const metadata = state.toolParameters.get(id)
76+
if (metadata && config.strategies.pruneTool.protectedTools.includes(metadata.tool)) {
77+
logger.warn("Blocked attempt to prune protected tool", { tool: metadata.tool, id })
78+
return false
79+
}
80+
return true
81+
})
7482
state.prune.toolIds.push(...pruneToolIds)
7583

7684
const toolMetadata = new Map<string, ToolParameterEntry>()

0 commit comments

Comments
 (0)