Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/strategies/prune-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function createPruneTool(
const sessionId = toolCtx.sessionID

if (!args.ids || args.ids.length === 0) {
logger.debug("Prune tool called but args.ids is empty or undefined: " + JSON.stringify(args))
return "No IDs provided. Check the <prunable-tools> list for available IDs to prune."
}

Expand All @@ -50,13 +51,15 @@ export function createPruneTool(
const reason = args.ids[0];
const validReasons = ["completion", "noise", "consolidation"] as const
if (typeof reason !== "string" || !validReasons.includes(reason as any)) {
logger.debug("Invalid pruning reason provided: " + reason)
return "No valid pruning reason found. Use 'completion', 'noise', or 'consolidation' as the first element."
}

const numericToolIds: number[] = args.ids.slice(1)
.map(id => parseInt(id, 10))
.filter((n): n is number => !isNaN(n))
if (numericToolIds.length === 0) {
logger.debug("No numeric tool IDs provided for pruning, yet prune tool was called: " + JSON.stringify(args))
return "No numeric IDs provided. Format: [reason, id1, id2, ...] where reason is 'completion', 'noise', or 'consolidation'."
}

Expand All @@ -73,6 +76,7 @@ export function createPruneTool(

// Validate that all numeric IDs are within bounds
if (numericToolIds.some(id => id < 0 || id >= toolIdList.length)) {
logger.debug("Invalid tool IDs provided: " + numericToolIds.join(", "))
return "Invalid IDs provided. Only use numeric IDs from the <prunable-tools> list."
}

Expand Down