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
Copy file name to clipboardExpand all lines: README.md
+26-12Lines changed: 26 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,29 +19,39 @@ Add to your OpenCode config:
19
19
20
20
Using `@latest` ensures you always get the newest version automatically when OpenCode starts.
21
21
22
+
> **Note:** If you use OAuth plugins (e.g., for Google or other services), place this plugin last in your `plugin` array to avoid interfering with their authentication flows.
23
+
22
24
Restart OpenCode. The plugin will automatically start optimizing your sessions.
23
25
24
26
## How Pruning Works
25
27
26
-
DCP uses multiple strategies to reduce context size:
28
+
DCP uses multiple tools and strategies to reduce context size:
29
+
30
+
### Tools
31
+
32
+
**Discard** — Exposes a `discard` tool that the AI can call to remove completed or noisy tool content from context.
33
+
34
+
**Extract** — Exposes an `extract` tool that the AI can call to distill valuable context into concise summaries before removing the tool content.
35
+
36
+
### Strategies
27
37
28
38
**Deduplication** — Identifies repeated tool calls (e.g., reading the same file multiple times) and keeps only the most recent output. Runs automatically on every request with zero LLM cost.
29
39
30
40
**Supersede Writes** — Prunes write tool inputs for files that have subsequently been read. When a file is written and later read, the original write content becomes redundant since the current file state is captured in the read result. Runs automatically on every request with zero LLM cost.
31
41
32
-
**Discard Tool** — Exposes a `discard` tool that the AI can call to remove completed or noisy tool outputs from context. Use this for task completion cleanup and removing irrelevant outputs.
33
-
34
-
**Extract Tool** — Exposes an `extract` tool that the AI can call to distill valuable context into concise summaries before removing the raw outputs. Use this when you need to preserve key findings while reducing context size.
42
+
**Purge Errors** — Prunes tool inputs for tools that returned errors after a configurable number of turns (default: 4). Error messages are preserved for context, but the potentially large input content is removed. Runs automatically on every request with zero LLM cost.
35
43
36
-
**On Idle Analysis** — Uses a language model to semantically analyze conversation context during idle periods and identify tool outputs that are no longer relevant.
44
+
**On Idle Analysis** — Uses a language model to semantically analyze conversation context during idle periods and identify tool outputs that are no longer relevant. Disabled by default (legacy behavior).
37
45
38
-
Your session history is never modified. DCP replaces pruned outputs with a placeholder before sending requests to your LLM.
46
+
Your session history is never modified—DCP replaces pruned content with placeholders before sending requests to your LLM.
39
47
40
48
## Impact on Prompt Caching
41
49
42
50
LLM providers like Anthropic and OpenAI cache prompts based on exact prefix matching. When DCP prunes a tool output, it changes the message content, which invalidates cached prefixes from that point forward.
43
51
44
-
**Trade-off:** You lose some cache read benefits but gain larger token savings from reduced context size. In most cases, the token savings outweigh the cache miss cost—especially in long sessions where context bloat becomes significant.
52
+
**Trade-off:** You lose some cache read benefits but gain larger token savings from reduced context size and performance improvements through reduced context poisoning. In most cases, the token savings outweigh the cache miss cost—especially in long sessions where context bloat becomes significant.
53
+
54
+
**Best use case:** Providers that count usage in requests, such as Github Copilot and Google Antigravity have no negative price impact.
45
55
46
56
## Configuration
47
57
@@ -100,6 +110,14 @@ DCP uses its own config file:
100
110
"supersedeWrites": {
101
111
"enabled":true,
102
112
},
113
+
// Prune tool inputs for errored tools after X turns
114
+
"purgeErrors": {
115
+
"enabled":true,
116
+
// Number of turns before errored tool inputs are pruned
117
+
"turns":4,
118
+
// Additional tools to protect from pruning
119
+
"protectedTools": [],
120
+
},
103
121
// (Legacy) Run an LLM to analyze what tool calls are no longer relevant on idle
104
122
"onIdle": {
105
123
"enabled":false,
@@ -127,11 +145,7 @@ When enabled, turn protection prevents tool outputs from being pruned for a conf
127
145
By default, these tools are always protected from pruning across all strategies:
0 commit comments