Skip to content

Commit dfd5270

Browse files
authored
Merge pull request #139 from Opencode-DCP/fix/empty-prunable-tools-list
fix: skip inserting prunable tools list when empty
2 parents ef3b8a1 + ff959c3 commit dfd5270

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/messages/prune.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const buildPrunableToolsList = (
3333
logger.debug(`Prunable tool found - ID: ${numericId}, Tool: ${toolParameterEntry.tool}, Call ID: ${toolCallId}`)
3434
})
3535

36+
if (lines.length === 0) {
37+
return ""
38+
}
39+
3640
return `<prunable-tools>\nThe 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 outputs. Keep the context free of noise.\n${lines.join('\n')}\n</prunable-tools>`
3741
}
3842

@@ -52,6 +56,9 @@ export const insertPruneToolContext = (
5256
}
5357

5458
const prunableToolsList = buildPrunableToolsList(state, config, logger, messages)
59+
if (!prunableToolsList) {
60+
return
61+
}
5562

5663
let nudgeString = ""
5764
if (state.nudgeCounter >= config.strategies.pruneTool.nudge.frequency) {

0 commit comments

Comments
 (0)