Skip to content

Commit 594072a

Browse files
committed
Improve pruning guidance to prevent premature context loss
1 parent 852b6bd commit 594072a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/prompts/synthetic.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ You WILL use the `prune` tool when ANY of these are true:
1818
- You have distilled enough information in your messages to prune related tools
1919
- Context contains tools output that are unhelpful, noise, or made obsolete by newer outputs
2020

21+
You MUST NOT prune when:
22+
- The tool output will be needed for upcoming implementation work
23+
- The output contains files or context you'll need to reference when making edits
24+
25+
Pruning that forces you to re-call the same tool later is a net loss. Only prune when you're confident the information won't be needed again.
26+
2127
NOTES
22-
When in doubt, prune out. Prune often yet remain strategic about it.
28+
When in doubt, keep it. Prune often yet remain strategic about it.
2329
FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.
2430

2531
</instruction>

lib/prompts/tool.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ You must use this tool in three specific scenarios. The rules for distillation (
2525
- Narrative format: "I found X in file Y..."
2626
- Capture all relevant details (function names, logic, constraints).
2727
- Once distilled into your response history, the raw tool output can be safely pruned.
28+
- **Know when distillation isn't enough:** If you'll need to edit a file, grep for exact strings, or reference precise syntax, keep the raw output. Distillation works for understanding; implementation often requires the original.
29+
- **Prefer keeping over re-fetching:** If uncertain whether you'll need the output again, keep it. The cost of retaining context is lower than the cost of redundant tool calls.
2830

2931
## Best Practices
3032
- **Don't wait too long:** Prune frequently to keep the context agile.
3133
- **Be surgical:** You can mix strategies. Prune noise without comment, while distilling useful context in the same turn.
3234
- **Verify:** Ensure you have captured what you need before deleting useful raw data.
35+
- **Think ahead:** Before pruning, ask: "Will I need this output for an upcoming task?" If you researched a file you'll later edit, or gathered context for implementation, do NOT prune it—even if you've distilled findings. Distillation captures *knowledge*; implementation requires *context*.
3336

3437
## Examples
3538

@@ -54,3 +57,8 @@ Assistant: [Runs tests, they pass]
5457
The tests passed. The feature is verified.
5558
[Uses prune with ids: ["completion", "20", "21"]]
5659
</example_completion>
60+
61+
<example_keep>
62+
Assistant: [Reads 'auth.ts' to understand the login flow]
63+
I've understood the auth flow. I'll need to modify this file to add the new validation, so I'm keeping this read in context rather than distilling and pruning.
64+
</example_keep>

0 commit comments

Comments
 (0)