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
This document explains how opencode's TUI determines which tool arguments are displayed to users and how to design custom plugin tools that keep certain arguments hidden.
4
+
5
+
## Key Files
6
+
7
+
All rendering logic is located in the opencode reference repository:
However, plugin-defined tools cannot currently register custom TUI renderers from outside the opencode core package, so the `GenericTool` fallback and the `input()` filter are the primary mechanisms for controlling visibility.
152
+
153
+
## Summary
154
+
155
+
| Goal | Strategy |
156
+
|------|----------|
157
+
| Show argument in TUI | Use `string`, `number`, or `boolean`|
158
+
| Hide argument from TUI | Use `array`, `object`, or `record`|
159
+
| Hide structured data | Wrap in a single `object` or `record` argument |
160
+
| Clean TUI output | Ensure all top-level args are non-primitives |
Copy file name to clipboardExpand all lines: lib/prompts/prune-nudge.txt
+3-3Lines changed: 3 additions & 3 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. **Garbage Collect:** If you read files or ran commands that yielded no value, prune them NOW. Do not summarize them.
6
-
2. **Task Cleanup:** If a sub-task is complete, prune the tools used.
7
-
3. **Consolidate:** If you are holding valuable raw data, you *must* distill the insights into your narrative and prune the raw entry.
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.
8
8
9
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.
Copy file name to clipboardExpand all lines: lib/prompts/prune-system-prompt.txt
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,14 @@ PRUNE METHODICALLY - CONSOLIDATE YOUR ACTIONS
8
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.
9
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 and provide a summary in the `distillation` parameter (as an object).
12
-
2. NOISE REMOVAL: If outputs are irrelevant, unhelpful, or superseded by newer info, prune IMMEDIATELY. No distillation - gun it down
13
-
3. CONTEXT CONSOLIDATION: When pruning valuable context to the task at hand, you MUST ALWAYS provide the key findings in the `distillation` parameter of the `prune` tool (as an object). Be surgical and strategic in what you extract. THINK: high signal, low noise
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). Be surgical and strategic in what you extract. THINK: high signal, low noise
14
14
15
15
You WILL use the `prune` tool when ANY of these are true:
16
16
- Task or sub-task is complete
17
17
- 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 `distillation` parameter
18
+
- You have gathered enough information to prune related tools and preserve their value in the `metadata.distillation` parameter
19
19
- Context contains tools output that are unhelpful, noise, or made obsolete by newer outputs
20
20
- Write or edit operations are complete (pruning removes the large input content)
21
21
@@ -26,7 +26,7 @@ You MUST NOT prune when:
26
26
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
27
28
28
NOTES
29
-
When in doubt, keep it. Prune frequently yet remain strategic and consolidate your actions.
29
+
When in doubt, keep it. Consolidate your actions and aim for high-impact prunes that significantly reduce context size.
30
30
FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.
31
31
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>.
Prunes tool outputs from context to manage conversation size and reduce noise. For `write` and `edit` tools, the input content is pruned instead of the output.
1
+
Prunes tool outputs from context to manage conversation size and reduce noise.
2
2
3
3
## IMPORTANT: The Prunable List
4
4
A `<prunable-tools>` list is injected into user messages showing available tool outputs you can prune 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 prune.
@@ -7,58 +7,63 @@ A `<prunable-tools>` list is injected into user messages showing available tool
7
7
8
8
## CRITICAL: When and How to Prune
9
9
10
-
You must use this tool in three specific scenarios. The rules for distillation (summarizing findings) differ for each. **You must specify the reason as the first element of the `ids` array** to indicate which scenario applies.
10
+
You must use this tool in three specific scenarios. The rules for distillation (summarizing findings) differ for each. **You must provide a `metadata` object with a `reason` and optional `distillation`** to indicate which scenario applies.
**When:** You have successfully completed a specific unit of work (e.g., fixed a bug, wrote a file, answered a question).
14
14
**Action:** Prune the tools used for that task.
15
-
**Distillation:** Use the `distillation` parameter (as an object) to provide a final confirmation that the task is complete (e.g., `{ "status": "Tests passed, file updated" }`).
15
+
**Distillation:** FORBIDDEN. Do not summarize completed work.
**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).
19
19
**Action:** Prune these specific tool outputs immediately.
20
-
**Distillation:** NOT REQUIRED for noise.
20
+
**Distillation:** FORBIDDEN. Do not summarize noise.
**When:** You have gathered useful information. Prune frequently as you work (e.g., after reading a few files), rather than waiting for a "long" phase to end.
23
+
**When:** You have gathered useful information. Wait until you have several items or a few large outputs to prune, rather than doing tiny, frequent prunes. Aim for high-impact prunes that significantly reduce context size.
24
24
**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).
25
-
**Distillation:** MANDATORY. Use the `distillation` parameter (MUST be an object) to explicitly summarize the key findings from *every* tool you plan to prune.
25
+
**Distillation:** MANDATORY. You MUST provide the distilled findings in the `metadata.distillation` parameter of the `prune` tool (as an object).
26
26
- **Extract specific value:** If you read a large file but only care about one function, record that function's details.
- Capture all relevant details (function names, logic, constraints).
29
-
- Once distilled into the `distillation` object, the raw tool output can be safely pruned.
27
+
- **Consolidate:** When pruning multiple tools, your distillation object MUST aggregate findings from ALL of them. Ensure you capture any information necessary to solve the current task.
28
+
- Structure: Map the `ID` from the `<prunable-tools>` list to its distilled findings.
- Capture all relevant details (function names, logic, constraints) to ensure no signal is lost.
31
+
- Prioritize information that is essential for the immediate next steps of your plan.
32
+
- Once distilled into the `metadata` object, the raw tool output can be safely pruned.
30
33
- **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.
31
34
- **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.
32
35
33
36
## Best Practices
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.
36
-
- **Be surgical:** You can mix strategies. Prune noise without comment, while distilling useful context in the same turn.
37
-
- **Verify:** Ensure you have captured what you need before deleting useful raw data.
38
-
- **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*.
37
+
- **Strategic Consolidation:** Don't prune single small tool outputs (like short bash commands) unless they are pure noise. Instead, wait until you have several items or large outputs to perform high-impact prunes. This balances the need for an agile context with the efficiency of larger batches.
38
+
- **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.
39
39
40
40
## Examples
41
41
42
42
<example_noise>
43
43
Assistant: [Reads 'wrong_file.ts']
44
44
This file isn't relevant to the auth system. I'll remove it to clear the context.
45
-
[Uses prune with ids: ["noise", "5"]]
45
+
[Uses prune with ids: ["5"], metadata: { "reason": "noise" }]
46
46
</example_noise>
47
47
48
48
<example_consolidation>
49
49
Assistant: [Reads 5 different config files]
50
50
I'll preserve the configuration details and prune the raw reads.
0 commit comments