Skip to content

Commit 5ae736d

Browse files
authored
Merge pull request #132 from Opencode-DCP/refactor/remove-unused-reason-param
fix: simplify prune tool schema for OAuth plugin compatibility
2 parents 394844e + f9e47dc commit 5ae736d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/prompts/tool.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You must use this tool in three specific scenarios. The rules for distillation (
3636
<example_noise>
3737
Assistant: [Reads 'wrong_file.ts']
3838
This file isn't relevant to the auth system. I'll remove it to clear the context.
39-
[Uses prune with ids: ["noise", 5]]
39+
[Uses prune with ids: ["noise", "5"]]
4040
</example_noise>
4141

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

5252
<example_completion>
5353
Assistant: [Runs tests, they pass]
5454
The tests passed. The feature is verified.
55-
[Uses prune with ids: ["completion", 20, 21]]
55+
[Uses prune with ids: ["completion", "20", "21"]]
5656
</example_completion>

lib/strategies/prune-tool.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ export function createPruneTool(
3232
description: TOOL_DESCRIPTION,
3333
args: {
3434
ids: tool.schema.array(
35-
tool.schema.union([
36-
tool.schema.enum(["completion", "noise", "consolidation"]),
37-
tool.schema.number()
38-
])
35+
tool.schema.string()
3936
).describe(
40-
"First element is the reason ('completion', 'noise', 'consolidation'), followed by numeric IDs to prune"
37+
"First element is the reason ('completion', 'noise', 'consolidation'), followed by numeric IDs as strings to prune"
4138
),
4239
},
4340
async execute(args, toolCtx) {
@@ -56,7 +53,9 @@ export function createPruneTool(
5653
return "No valid pruning reason found. Use 'completion', 'noise', or 'consolidation' as the first element."
5754
}
5855

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

0 commit comments

Comments
 (0)