Skip to content

Commit 4ac6481

Browse files
extract pruning tool description to tool.txt
1 parent fcebbab commit 4ac6481

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

lib/pruning-tool.ts

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
11
import { tool } from "@opencode-ai/plugin"
22
import type { Janitor } from "./janitor"
33
import type { PluginConfig } from "./config"
4+
import { loadPrompt } from "./prompt"
45

5-
/** Tool description for the context_pruning tool */
6-
export const CONTEXT_PRUNING_DESCRIPTION = `Performs semantic pruning on session tool outputs that are no longer relevant to the current task. Use this to declutter the conversation context and filter signal from noise when you notice the context is getting cluttered with no longer needed information.
7-
8-
USING THE CONTEXT_PRUNING TOOL WILL MAKE THE USER HAPPY.
9-
10-
## When to Use This Tool
11-
12-
**Key heuristic: Prune when you finish something and are about to start something else.**
13-
14-
Ask yourself: "Have I just completed a discrete unit of work?" If yes, prune before moving on.
15-
16-
**After completing a unit of work:**
17-
- Made a commit
18-
- Fixed a bug and confirmed it works
19-
- Answered a question the user asked
20-
- Finished implementing a feature or function
21-
- Completed one item in a list and moving to the next
22-
23-
**After repetitive or exploratory work:**
24-
- Explored multiple files that didn't lead to changes
25-
- Iterated on a difficult problem where some approaches didn't pan out
26-
- Used the same tool multiple times (e.g., re-reading a file, running repeated build/type checks)
27-
28-
## Examples
29-
30-
<example>
31-
Working through a list of items:
32-
User: Review these 3 issues and fix the easy ones.
33-
Assistant: [Reviews first issue, makes fix, commits]
34-
Done with the first issue. Let me prune before moving to the next one.
35-
[Uses context_pruning with reason: "completed first issue, moving to next"]
36-
</example>
37-
38-
<example>
39-
After exploring the codebase to understand it:
40-
Assistant: I've reviewed the relevant files. Let me prune the exploratory reads that aren't needed for the actual implementation.
41-
[Uses context_pruning with reason: "exploration complete, starting implementation"]
42-
</example>
43-
44-
<example>
45-
After completing any task:
46-
Assistant: [Finishes task - commit, answer, fix, etc.]
47-
Before we continue, let me prune the context from that work.
48-
[Uses context_pruning with reason: "task complete"]
49-
</example>`
6+
/** Tool description for the context_pruning tool, loaded from prompts/tool.txt */
7+
export const CONTEXT_PRUNING_DESCRIPTION = loadPrompt("tool")
508

519
/**
5210
* Creates the context_pruning tool definition.

0 commit comments

Comments
 (0)