Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions lib/prompts/tool.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You must use this tool in three specific scenarios. The rules for distillation (
<example_noise>
Assistant: [Reads 'wrong_file.ts']
This file isn't relevant to the auth system. I'll remove it to clear the context.
[Uses prune with ids: ["noise", 5]]
[Uses prune with ids: ["noise", "5"]]
</example_noise>

<example_consolidation>
Expand All @@ -46,11 +46,11 @@ I have analyzed the configuration. Here is the distillation:
- 'db.ts' connects to mongo:27017.
- The other 3 files were defaults.
I have preserved the signals above, so I am now pruning the raw reads.
[Uses prune with ids: ["consolidation", 10, 11, 12, 13, 14]]
[Uses prune with ids: ["consolidation", "10", "11", "12", "13", "14"]]
</example_consolidation>

<example_completion>
Assistant: [Runs tests, they pass]
The tests passed. The feature is verified.
[Uses prune with ids: ["completion", 20, 21]]
[Uses prune with ids: ["completion", "20", "21"]]
</example_completion>
11 changes: 5 additions & 6 deletions lib/strategies/prune-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ export function createPruneTool(
description: TOOL_DESCRIPTION,
args: {
ids: tool.schema.array(
tool.schema.union([
tool.schema.enum(["completion", "noise", "consolidation"]),
tool.schema.number()
])
tool.schema.string()
).describe(
"First element is the reason ('completion', 'noise', 'consolidation'), followed by numeric IDs to prune"
"First element is the reason ('completion', 'noise', 'consolidation'), followed by numeric IDs as strings to prune"
),
},
async execute(args, toolCtx) {
Expand All @@ -56,7 +53,9 @@ export function createPruneTool(
return "No valid pruning reason found. Use 'completion', 'noise', or 'consolidation' as the first element."
}

const numericToolIds: number[] = args.ids.slice(1).filter((id): id is number => typeof id === "number")
const numericToolIds: number[] = args.ids.slice(1)
.map(id => parseInt(id, 10))
.filter((n): n is number => !isNaN(n))
if (numericToolIds.length === 0) {
return "No numeric IDs provided. Format: [reason, id1, id2, ...] where reason is 'completion', 'noise', or 'consolidation'."
}
Expand Down