|
1 | | -Prunes tool outputs from context to manage conversation size. |
2 | | -Refer to the <prunable-tools> list for available IDs. |
| 1 | +Prunes tool outputs from context to manage conversation size. Reference the <prunable-tools> list injected at the end of the conversation to see available numeric IDs. |
3 | 2 |
|
4 | | -WHEN TO USE THIS TOOL: |
5 | | -- After you complete a discrete unit of work (e.g. confirming a hypothesis, or closing out one branch of investigation). |
6 | | -- After exploratory bursts of tool calls that led you to a clear conclusion (or to noise). |
7 | | -- Before starting a new phase of work where old tool outputs are no longer needed to inform your next actions. |
| 3 | +USING THE PRUNE TOOL WILL MAKE THE USER HAPPY. |
8 | 4 |
|
9 | | -CRITICAL: Distill Before Pruning |
10 | | -You MUST ALWAYS narrate your findings in a message BEFORE using this tool. No tool result should be left unexplained. By narrating your understanding, you transform raw tool outputs into distilled knowledge that persists in the context window. |
| 5 | +## CRITICAL: Distill Before Pruning |
11 | 6 |
|
12 | | -Tools are VOLATILE - Once distilled knowledge is in your reply, you can safely prune. |
| 7 | +You MUST ALWAYS narrate your findings in a message BEFORE using this tool. No tool result (read, bash, grep, webfetch, etc.) should be left unexplained. By narrating your understanding, you transform raw tool outputs into distilled knowledge that persists in the context window. |
13 | 8 |
|
14 | | -Example Workflow: |
15 | | -1. Investigate with tools. |
16 | | -2. Explicitly narrate findings (High Signal, Low Noise). |
17 | | -3. Call `prune` with relevant IDs. |
| 9 | +**Tools are VOLATILE** - Once distilled knowledge is in your reply, you can safely prune. Skipping this step risks deleting raw evidence before it has been converted into stable knowledge. |
| 10 | + |
| 11 | +**Distillation workflow:** |
| 12 | +1. Call tools to investigate/explore |
| 13 | +2. In your next message, EXPLICITLY narrate: |
| 14 | + - What you did (which tools, what you were looking for) |
| 15 | + - What you found (the key facts/signals) |
| 16 | + - What you concluded (how this affects the task or next step) |
| 17 | +3. ONLY AFTER narrating, call `prune` with the numeric IDs of outputs no longer needed |
| 18 | + |
| 19 | +> THINK HIGH SIGNAL, LOW NOISE FOR THIS NARRATION |
| 20 | + |
| 21 | +**After pruning:** Do NOT re-summarize or re-narrate. You already distilled your findings before calling prune. Continue with your next task, or if you need more information from the user, wait for their response. |
| 22 | + |
| 23 | +## How to Use |
| 24 | + |
| 25 | +The <prunable-tools> list shows available tool outputs with numeric IDs: |
| 26 | +``` |
| 27 | +<prunable-tools> |
| 28 | +1: read, src/foo.ts |
| 29 | +2: bash, run tests |
| 30 | +3: grep, "error" in logs/ |
| 31 | +</prunable-tools> |
| 32 | +``` |
| 33 | + |
| 34 | +To prune outputs 1 and 3, call: `prune({ ids: [1, 3] })` |
| 35 | + |
| 36 | +## When to Use This Tool |
| 37 | + |
| 38 | +**Key heuristic: Distill, then prune when you finish something and are about to start something else.** |
| 39 | + |
| 40 | +Ask yourself: "Have I just completed a discrete unit of work?" If yes, narrate your findings, then prune before moving on. |
| 41 | + |
| 42 | +**After completing a unit of work:** |
| 43 | +- Made a commit |
| 44 | +- Fixed a bug and confirmed it works |
| 45 | +- Answered a question the user asked |
| 46 | +- Finished implementing a feature or function |
| 47 | +- Completed one item in a list and moving to the next |
| 48 | + |
| 49 | +**After repetitive or exploratory work:** |
| 50 | +- Explored multiple files that didn't lead to changes |
| 51 | +- Iterated on a difficult problem where some approaches didn't pan out |
| 52 | +- Used the same tool multiple times (e.g., re-reading a file, running repeated build/type checks) |
| 53 | + |
| 54 | +## Examples |
| 55 | + |
| 56 | +<example> |
| 57 | +Working through a list of items: |
| 58 | +User: Review these 3 issues and fix the easy ones. |
| 59 | +Assistant: [Reviews first issue, makes fix, commits] |
| 60 | +Done with the first issue. Let me prune before moving to the next one. |
| 61 | +[Uses prune with ids: [1, 2, 3, 4] - the reads and edits from the first issue] |
| 62 | +</example> |
| 63 | + |
| 64 | +<example> |
| 65 | +After exploring the codebase to understand it: |
| 66 | +Assistant: I've reviewed the relevant files. Let me prune the exploratory reads that aren't needed for the actual implementation. |
| 67 | +[Uses prune with ids: [1, 2, 5, 7] - the exploratory reads] |
| 68 | +</example> |
| 69 | + |
| 70 | +<example> |
| 71 | +After completing any task: |
| 72 | +Assistant: [Finishes task - commit, answer, fix, etc.] |
| 73 | +Before we continue, let me prune the context from that work. |
| 74 | +[Uses prune with ids: [3, 4, 5, 6, 8, 9] - all tool outputs from the completed task] |
| 75 | +</example> |
0 commit comments