You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Discards tool outputs from context to manage conversation size and reduce noise.
2
+
3
+
## IMPORTANT: The Prunable List
4
+
A `<prunable-tools>` list is injected into user messages showing available tool outputs you can discard when there are tools available for pruning. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). You MUST only use numeric IDs that appear in this list to select which tools to discard.
5
+
6
+
**Note:** For `write` and `edit` tools, discarding removes the input content (the code being written/edited) while preserving the output confirmation. This is useful after completing a file modification when you no longer need the raw content in context.
7
+
8
+
## When to Use This Tool
9
+
10
+
Use `discard` for removing tool outputs that are no longer needed **without preserving their content**:
11
+
12
+
### 1. Task Completion (Clean Up)
13
+
**When:** You have successfully completed a specific unit of work (e.g., fixed a bug, wrote a file, answered a question).
14
+
**Action:** Discard the tools used for that task with reason `completion`.
15
+
16
+
### 2. Removing Noise (Garbage Collection)
17
+
**When:** You have read files or run commands that turned out to be irrelevant, unhelpful, or outdated (meaning later tools have provided fresher, more valid information).
18
+
**Action:** Discard these specific tool outputs immediately with reason `noise`.
19
+
20
+
## When NOT to Use This Tool
21
+
22
+
- **If you need to preserve information:** Use the `consolidate` tool instead when you want to keep distilled findings from the tool outputs.
23
+
- **If you'll need the output later:** Don't discard files you plan to edit, or context you'll need for implementation.
24
+
25
+
## Best Practices
26
+
- **Strategic Batching:** Don't discard single small tool outputs (like short bash commands) unless they are pure noise. Wait until you have several items to perform high-impact discards.
27
+
- **Think ahead:** Before discarding, ask: "Will I need this output for an upcoming task?" If yes, keep it.
28
+
29
+
## Format
30
+
The `ids` parameter is an array where the first element is the reason, followed by numeric IDs:
31
+
`ids: ["reason", "id1", "id2", ...]`
32
+
33
+
## Examples
34
+
35
+
<example_noise>
36
+
Assistant: [Reads 'wrong_file.ts']
37
+
This file isn't relevant to the auth system. I'll remove it to clear the context.
38
+
[Uses discard with ids: ["noise", "5"]]
39
+
</example_noise>
40
+
41
+
<example_completion>
42
+
Assistant: [Runs tests, they pass]
43
+
The tests passed. I'll clean up now.
44
+
[Uses discard with ids: ["completion", "20", "21"]]
45
+
</example_completion>
46
+
47
+
<example_keep>
48
+
Assistant: [Reads 'auth.ts' to understand the login flow]
49
+
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 discarding.
50
+
</example_keep>
51
+
52
+
<example_edit_completion>
53
+
Assistant: [Edits 'auth.ts' to add validation]
54
+
The edit was successful. I no longer need the raw edit content in context.
Extracts key findings from tool outputs into distilled knowledge, then removes the raw outputs from context.
2
+
3
+
## IMPORTANT: The Prunable List
4
+
A `<prunable-tools>` list is injected into user messages showing available tool outputs you can extract from when there are tools available for pruning. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). You MUST only use numeric IDs that appear in this list to select which tools to extract.
5
+
6
+
## When to Use This Tool
7
+
8
+
Use `extract` when you have gathered useful information that you want to **preserve in distilled form** before removing the raw outputs:
9
+
10
+
**When:** You have read files, run commands, or gathered context that contains valuable information you'll need to reference later, but the full raw output is too large to keep.
11
+
**Action:** Convert raw data into distilled knowledge. This allows you to discard large outputs (like full file reads) while keeping only the specific parts you need (like a single function signature or constant).
12
+
13
+
## CRITICAL: Distillation Requirements
14
+
15
+
You MUST provide distilled findings in the `distillation` parameter. This is not optional.
16
+
17
+
- **Comprehensive Capture:** Distillation is not just a summary. It must be a high-fidelity representation of the technical details. If you read a file, the distillation should include function signatures, specific logic flows, constant values, and any constraints or edge cases discovered.
18
+
- **Task-Relevant Verbosity:** Be as verbose as necessary to ensure that the "distilled" version is a complete substitute for the raw output for the task at hand. If you will need to reference a specific algorithm or interface later, include it in its entirety within the distillation.
19
+
- **Extract Per-ID:** When extracting from multiple tools, your `distillation` object MUST contain a corresponding entry for EVERY ID being extracted. You must capture high-fidelity findings for each tool individually to ensure no signal is lost.
20
+
- **Structure:** Map EVERY `ID` from the `ids` array to its specific distilled findings.
21
+
Example: `{ "20": { ... }, "21": { ... } }`
22
+
- Capture all relevant details (function names, logic, constraints) to ensure no signal is lost.
23
+
- Prioritize information that is essential for the immediate next steps of your plan.
24
+
25
+
## When NOT to Use This Tool
26
+
27
+
- **If you don't need to preserve information:** Use the `discard` tool instead for completed tasks or noise removal.
28
+
- **If you need precise syntax:** 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
+
- **If uncertain:** Prefer keeping over re-fetching. The cost of retaining context is lower than the cost of redundant tool calls.
30
+
31
+
## Best Practices
32
+
- **Technical Fidelity:** Ensure that types, parameters, and return values are preserved if they are relevant to upcoming implementation steps.
33
+
- **Strategic Batching:** Wait until you have several items or a few large outputs to extract, rather than doing tiny, frequent extractions. Aim for high-impact extractions that significantly reduce context size.
34
+
- **Think ahead:** Before extracting, ask: "Will I need the raw output for an upcoming task?" If you researched a file you'll later edit, do NOT extract it.
35
+
36
+
## Example
37
+
38
+
<example_extraction>
39
+
Assistant: [Reads service implementation, types, and config]
40
+
I'll preserve the full technical specification and implementation logic before extracting.
41
+
[Uses extract with ids: ["10", "11", "12"], distillation: {
42
+
"10": {
43
+
"file": "src/services/auth.ts",
44
+
"signatures": [
45
+
"async function validateToken(token: string): Promise<User | null>",
46
+
"function hashPassword(password: string): string"
47
+
],
48
+
"logic": "The validateToken function first checks the local cache before calling the external OIDC provider. It uses a 5-minute TTL for cached tokens.",
49
+
"dependencies": ["import { cache } from '../utils/cache'", "import { oidc } from '../config'"],
50
+
"constraints": "Tokens must be at least 128 chars long. hashPassword uses bcrypt with 12 rounds."
Copy file name to clipboardExpand all lines: lib/prompts/prune-nudge.txt
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
3
3
4
4
**Immediate Actions Required:**
5
-
1. **Task Completion:** If a sub-task is complete, prune the tools used. No distillation.
6
-
2. **Noise Removal:** If you read files or ran commands that yielded no value, prune them NOW. No distillation.
7
-
3. **Consolidation:** If you are holding valuable raw data, you *must* distill the insights into `metadata.distillation` and prune the raw entry.
5
+
1. **Task Completion:** If a sub-task is complete, discard the tools used.
6
+
2. **Noise Removal:** If you read files or ran commands that yielded no value, discard them NOW.
7
+
3. **Extraction:** If you are holding valuable raw data, you *must* use the `extract` tool to distill the insights and remove the raw entry.
8
8
9
-
**Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must prune.
9
+
**Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must perform context management.
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.
5
+
You are operating in a context-constrained environment and thus must proactively manage your context window using the `discard` and `extract` tools. 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.
6
6
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.
7
+
TWO TOOLS FOR CONTEXT MANAGEMENT
8
+
- `discard`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
9
+
- `extract`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.
9
10
10
-
WHEN TO PRUNE? THE THREE SCENARIOS TO CONSIDER
11
-
1. TASK COMPLETION: When work is done, quietly prune the tools that aren't needed anymore. No distillation.
12
-
2. NOISE REMOVAL: If outputs are irrelevant, unhelpful, or superseded by newer info, prune. No distillation.
13
-
3. CONTEXT CONSOLIDATION: When pruning valuable context to the task at hand, you MUST ALWAYS provide the key findings in the `metadata.distillation` parameter of the `prune` tool (as an object). Your distillation must be high-fidelity and comprehensive, capturing technical details (signatures, logic, constraints) such that the raw output is no longer needed. THINK: high signal, complete technical substitute.
11
+
PRUNE METHODICALLY - BATCH YOUR ACTIONS
12
+
Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by pruning. Batch 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.
14
13
15
-
You WILL use the `prune` tool when ANY of these are true:
14
+
WHEN TO PRUNE? THE SCENARIOS TO CONSIDER
15
+
1. TASK COMPLETION: When work is done, quietly discard the tools that aren't needed anymore.
16
+
2. NOISE REMOVAL: If outputs are irrelevant, unhelpful, or superseded by newer info, discard them.
17
+
3. CONTEXT EXTRACTION: When you have valuable context you want to preserve but need to reduce size, use `extract` with high-fidelity distillation. Your distillation must be comprehensive, capturing technical details (signatures, logic, constraints) such that the raw output is no longer needed. THINK: high signal, complete technical substitute.
18
+
19
+
You WILL use `discard` or `extract` when ANY of these are true:
16
20
- Task or sub-task is complete
17
21
- You are about to start a new phase of work
18
-
- You have gathered enough information to prune related tools and preserve their value in the `metadata.distillation` parameter
19
-
- Context contains tools output that are unhelpful, noise, or made obsolete by newer outputs
22
+
- You have gathered enough information to extract from related tools and preserve their value via distillation
23
+
- Context contains tool outputs that are unhelpful, noise, or made obsolete by newer outputs
20
24
- Write or edit operations are complete (pruning removes the large input content)
21
25
22
26
You MUST NOT prune when:
@@ -26,20 +30,20 @@ You MUST NOT prune when:
26
30
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.
27
31
28
32
NOTES
29
-
When in doubt, keep it. Consolidate your actions and aim for high-impact prunes that significantly reduce context size.
33
+
When in doubt, keep it. Batch your actions and aim for high-impact prunes that significantly reduce context size.
30
34
FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.
31
35
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>.
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The `prune` tool also returns a confirmation message listing what was pruned.
40
+
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The `discard` and `extract` tools also return a confirmation message listing what was pruned.
37
41
38
42
CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
39
43
- NEVER reference the prune encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the prune encouragement appears.
40
44
- NEVER acknowledge the <prunable-tools> list (e.g., "I see the prunable tools list", "Looking at the available tools to prune")
41
45
- NEVER reference the nudge instruction (e.g., "As the nudge suggests", "The system is reminding me to prune")
0 commit comments