From ff959c3110c38a0b772477fcde04631a64f4d368 Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Mon, 15 Dec 2025 12:59:00 -0500 Subject: [PATCH] fix: skip inserting prunable tools list when empty --- lib/messages/prune.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/messages/prune.ts b/lib/messages/prune.ts index ce022f3..7361b74 100644 --- a/lib/messages/prune.ts +++ b/lib/messages/prune.ts @@ -33,6 +33,10 @@ const buildPrunableToolsList = ( logger.debug(`Prunable tool found - ID: ${numericId}, Tool: ${toolParameterEntry.tool}, Call ID: ${toolCallId}`) }) + if (lines.length === 0) { + return "" + } + return `\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` } @@ -52,6 +56,9 @@ export const insertPruneToolContext = ( } const prunableToolsList = buildPrunableToolsList(state, config, logger, messages) + if (!prunableToolsList) { + return + } let nudgeString = "" if (state.nudgeCounter >= config.strategies.pruneTool.nudge.frequency) {