Skip to content

Commit 6532e3f

Browse files
authored
Merge pull request #172 from Opencode-DCP/feature/consolidated-pruning
Encourage consolidated pruning guidance
2 parents 3d926eb + 421eb5f commit 6532e3f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/messages/prune.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const PRUNED_TOOL_OUTPUT_REPLACEMENT = '[Output removed to save context - inform
1111
const NUDGE_STRING = loadPrompt("nudge")
1212

1313
const wrapPrunableTools = (content: string): string => `<prunable-tools>
14-
The following tools have been invoked and are available for pruning. This list does not mandate immediate action. Consider your current goals and the resources you need before discarding valuable tool inputs or outputs. Keep the context free of noise.
14+
The following tools have been invoked and are available for pruning. This list does not mandate immediate action. Consider your current goals and the resources you need before discarding valuable tool inputs or outputs. Consolidate your prunes for efficiency; it is rarely worth pruning a single tiny tool output. Keep the context free of noise.
1515
${content}
1616
</prunable-tools>`
1717
const PRUNABLE_TOOLS_COOLDOWN = `<prunable-tools>

lib/prompts/synthetic.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
ENVIRONMENT
55
You are operating in a context-constrained environment and thus must proactively manage your context window using the `prune` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to prune.
66

7-
PRUNE EARLY, PRUNE OFTEN - BUT PRUNE METHODICALLY
8-
Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by pruning. Evaluate what SHOULD be pruned before jumping the gun.
7+
PRUNE METHODICALLY - CONSOLIDATE YOUR ACTIONS
8+
Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by pruning. Consolidate your prunes for efficiency; it is rarely worth pruning a single tiny tool output unless it is pure noise. Evaluate what SHOULD be pruned before jumping the gun.
99

1010
WHEN TO PRUNE? THE THREE SCENARIOS TO CONSIDER
1111
1. TASK COMPLETION: When work is done, quietly prune the tools that aren't needed anymore
@@ -26,7 +26,7 @@ You MUST NOT prune when:
2626
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.
2727

2828
NOTES
29-
When in doubt, keep it. Prune often yet remain strategic about it.
29+
When in doubt, keep it. Prune frequently yet remain strategic and consolidate your actions.
3030
FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.
3131
There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY prune what you see in <prunable-tools>.
3232

lib/prompts/tool.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ You must use this tool in three specific scenarios. The rules for distillation (
3131
- **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.
3232

3333
## Best Practices
34-
- **Don't wait too long:** Prune frequently to keep the context agile.
34+
- **Consolidate your prunes:** Don't prune a single small tool output (like a short bash command) unless it's pure noise. Wait until you have several items or a few large outputs to prune. Aim for high-impact prunes that significantly reduce context size or noise.
35+
- **Don't wait too long:** Prune frequently to keep the context agile, but balance this with the need for consolidation.
3536
- **Be surgical:** You can mix strategies. Prune noise without comment, while distilling useful context in the same turn.
3637
- **Verify:** Ensure you have captured what you need before deleting useful raw data.
3738
- **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*.

0 commit comments

Comments
 (0)