Skip to content

Commit e34a9da

Browse files
committed
fix: make cooldown message dynamic based on enabled tools
1 parent 95cf48c commit e34a9da

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/messages/prune.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,24 @@ const wrapPrunableTools = (content: string): string => `<prunable-tools>
2626
The following tools have been invoked and are available for pruning. This list does not mandate immediate action. Consider your current goals and the resources you need before discarding valuable tool inputs or outputs. Consolidate your prunes for efficiency; it is rarely worth pruning a single tiny tool output. Keep the context free of noise.
2727
${content}
2828
</prunable-tools>`
29-
const PRUNABLE_TOOLS_COOLDOWN = `<prunable-tools>
30-
Pruning was just performed. Do not use the prune tool again. A fresh list will be available after your next tool use.
29+
30+
const getCooldownMessage = (config: PluginConfig): string => {
31+
const discardEnabled = config.strategies.discardTool.enabled
32+
const extractEnabled = config.strategies.extractTool.enabled
33+
34+
let toolName: string
35+
if (discardEnabled && extractEnabled) {
36+
toolName = "discard or extract tools"
37+
} else if (discardEnabled) {
38+
toolName = "discard tool"
39+
} else {
40+
toolName = "extract tool"
41+
}
42+
43+
return `<prunable-tools>
44+
Context management was just performed. Do not use the ${toolName} again. A fresh list will be available after your next tool use.
3145
</prunable-tools>`
46+
}
3247

3348
const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345"
3449
const SYNTHETIC_PART_ID = "prt_01234567890123456789012345"
@@ -90,7 +105,7 @@ export const insertPruneToolContext = (
90105

91106
if (state.lastToolPrune) {
92107
logger.debug("Last tool was prune - injecting cooldown message")
93-
prunableToolsContent = PRUNABLE_TOOLS_COOLDOWN
108+
prunableToolsContent = getCooldownMessage(config)
94109
} else {
95110
const prunableToolsList = buildPrunableToolsList(state, config, logger, messages)
96111
if (!prunableToolsList) {

0 commit comments

Comments
 (0)