@@ -25,6 +25,7 @@ export interface PruneToolNudge {
2525export interface PruneTool {
2626 enabled : boolean
2727 protectedTools : string [ ]
28+ protectedTurns : number
2829 nudge : PruneToolNudge
2930}
3031
@@ -72,6 +73,7 @@ export const VALID_CONFIG_KEYS = new Set([
7273 'strategies.pruneTool' ,
7374 'strategies.pruneTool.enabled' ,
7475 'strategies.pruneTool.protectedTools' ,
76+ 'strategies.pruneTool.protectedTurns' ,
7577 'strategies.pruneTool.nudge' ,
7678 'strategies.pruneTool.nudge.enabled' ,
7779 'strategies.pruneTool.nudge.frequency'
@@ -158,6 +160,9 @@ function validateConfigTypes(config: Record<string, any>): ValidationError[] {
158160 if ( strategies . pruneTool . protectedTools !== undefined && ! Array . isArray ( strategies . pruneTool . protectedTools ) ) {
159161 errors . push ( { key : 'strategies.pruneTool.protectedTools' , expected : 'string[]' , actual : typeof strategies . pruneTool . protectedTools } )
160162 }
163+ if ( strategies . pruneTool . protectedTurns !== undefined && typeof strategies . pruneTool . protectedTurns !== 'number' ) {
164+ errors . push ( { key : 'strategies.pruneTool.protectedTurns' , expected : 'number' , actual : typeof strategies . pruneTool . protectedTurns } )
165+ }
161166 if ( strategies . pruneTool . nudge ) {
162167 if ( strategies . pruneTool . nudge . enabled !== undefined && typeof strategies . pruneTool . nudge . enabled !== 'boolean' ) {
163168 errors . push ( { key : 'strategies.pruneTool.nudge.enabled' , expected : 'boolean' , actual : typeof strategies . pruneTool . nudge . enabled } )
@@ -240,6 +245,7 @@ const defaultConfig: PluginConfig = {
240245 pruneTool : {
241246 enabled : true ,
242247 protectedTools : [ ...DEFAULT_PROTECTED_TOOLS ] ,
248+ protectedTurns : 4 ,
243249 nudge : {
244250 enabled : true ,
245251 frequency : 10
@@ -341,6 +347,8 @@ function createDefaultConfig(): void {
341347 "enabled": true,
342348 // Additional tools to protect from pruning
343349 "protectedTools": [],
350+ // Protect tools from pruning for N turns after they are called (0 = disabled)
351+ "protectedTurns": 4,
344352 // Nudge the LLM to use the prune tool (every <frequency> tool results)
345353 "nudge": {
346354 "enabled": true,
@@ -426,6 +434,7 @@ function mergeStrategies(
426434 ...( override . pruneTool ?. protectedTools ?? [ ] )
427435 ] )
428436 ] ,
437+ protectedTurns : override . pruneTool ?. protectedTurns ?? base . pruneTool . protectedTurns ,
429438 nudge : {
430439 enabled : override . pruneTool ?. nudge ?. enabled ?? base . pruneTool . nudge . enabled ,
431440 frequency : override . pruneTool ?. nudge ?. frequency ?? base . pruneTool . nudge . frequency
@@ -452,6 +461,7 @@ function deepCloneConfig(config: PluginConfig): PluginConfig {
452461 pruneTool : {
453462 ...config . strategies . pruneTool ,
454463 protectedTools : [ ...config . strategies . pruneTool . protectedTools ] ,
464+ protectedTurns : config . strategies . pruneTool . protectedTurns ,
455465 nudge : { ...config . strategies . pruneTool . nudge }
456466 } ,
457467 supersedeWrites : {
0 commit comments