Skip to content

Commit a295538

Browse files
move tool description to prompt file
1 parent c5c33d6 commit a295538

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed

index.ts

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async function isSubagentSession(client: any, sessionID: string): Promise<boolea
1616
}
1717

1818
const TOOL_SYNTH_INSTRUCTION = loadPrompt("synthetic")
19+
const TOOL_CONTEXT_PRUNING_DESCRIPTION = loadPrompt("context_pruning")
1920

2021
const plugin: Plugin = (async (ctx) => {
2122
const { config, migrations } = getConfig(ctx)
@@ -248,50 +249,7 @@ const plugin: Plugin = (async (ctx) => {
248249

249250
tool: config.strategies.onTool.length > 0 ? {
250251
context_pruning: tool({
251-
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.
252-
253-
USING THE CONTEXT_PRUNING TOOL WILL MAKE THE USER HAPPY.
254-
255-
## When to Use This Tool
256-
257-
**Key heuristic: Prune when you finish something and are about to start something else.**
258-
259-
Ask yourself: "Have I just completed a discrete unit of work?" If yes, prune before moving on.
260-
261-
**After completing a unit of work:**
262-
- Made a commit
263-
- Fixed a bug and confirmed it works
264-
- Answered a question the user asked
265-
- Finished implementing a feature or function
266-
- Completed one item in a list and moving to the next
267-
268-
**After repetitive or exploratory work:**
269-
- Explored multiple files that didn't lead to changes
270-
- Iterated on a difficult problem where some approaches didn't pan out
271-
- Used the same tool multiple times (e.g., re-reading a file, running repeated build/type checks)
272-
273-
## Examples
274-
275-
<example>
276-
Working through a list of items:
277-
User: Review these 3 issues and fix the easy ones.
278-
Assistant: [Reviews first issue, makes fix, commits]
279-
Done with the first issue. Let me prune before moving to the next one.
280-
[Uses context_pruning with reason: "completed first issue, moving to next"]
281-
</example>
282-
283-
<example>
284-
After exploring the codebase to understand it:
285-
Assistant: I've reviewed the relevant files. Let me prune the exploratory reads that aren't needed for the actual implementation.
286-
[Uses context_pruning with reason: "exploration complete, starting implementation"]
287-
</example>
288-
289-
<example>
290-
After completing any task:
291-
Assistant: [Finishes task - commit, answer, fix, etc.]
292-
Before we continue, let me prune the context from that work.
293-
[Uses context_pruning with reason: "task complete"]
294-
</example>`,
252+
description: TOOL_CONTEXT_PRUNING_DESCRIPTION,
295253
args: {
296254
reason: tool.schema.string().optional().describe(
297255
"Brief reason for triggering pruning (e.g., 'task complete', 'switching focus')"

lib/prompts/context_pruning.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
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.
2+
3+
USING THE CONTEXT_PRUNING TOOL WILL MAKE THE USER HAPPY.
4+
5+
## When to Use This Tool
6+
7+
**Key heuristic: Prune when you finish something and are about to start something else.**
8+
9+
Ask yourself: "Have I just completed a discrete unit of work?" If yes, prune before moving on.
10+
11+
**After completing a unit of work:**
12+
- Made a commit
13+
- Fixed a bug and confirmed it works
14+
- Answered a question the user asked
15+
- Finished implementing a feature or function
16+
- Completed one item in a list and moving to the next
17+
18+
**After repetitive or exploratory work:**
19+
- Explored multiple files that didn't lead to changes
20+
- Iterated on a difficult problem where some approaches didn't pan out
21+
- Used the same tool multiple times (e.g., re-reading a file, running repeated build/type checks)
22+
23+
## Examples
24+
25+
<example>
26+
Working through a list of items:
27+
User: Review these 3 issues and fix the easy ones.
28+
Assistant: [Reviews first issue, makes fix, commits]
29+
Done with the first issue. Let me prune before moving to the next one.
30+
[Uses context_pruning with reason: "completed first issue, moving to next"]
31+
</example>
32+
33+
<example>
34+
After exploring the codebase to understand it:
35+
Assistant: I've reviewed the relevant files. Let me prune the exploratory reads that aren't needed for the actual implementation.
36+
[Uses context_pruning with reason: "exploration complete, starting implementation"]
37+
</example>
38+
39+
<example>
40+
After completing any task:
41+
Assistant: [Finishes task - commit, answer, fix, etc.]
42+
Before we continue, let me prune the context from that work.
43+
[Uses context_pruning with reason: "task complete"]
44+
</example>

0 commit comments

Comments
 (0)