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
Add auto and smart pruning modes with dedicated deduplication phase
- Add pruningMode config option: 'auto' (fast, zero LLM cost) or 'smart' (comprehensive, max savings)
- Extract deduplication logic into dedicated deduplicator module
- Phase 1 (both modes): Automatic duplicate removal based on tool+parameter signature
- Phase 2 (smart mode only): LLM analysis for intelligent obsolete detection
- Update notifications to show separate sections for duplicates vs LLM-pruned tools
- Update README with mode comparison and example notification formats
- Add todowrite/todoread to default protected tools (stateful operations)
Copy file name to clipboardExpand all lines: README.md
+73-49Lines changed: 73 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,23 @@ Automatically reduces token usage in OpenCode by removing obsolete tool outputs
6
6
7
7
## What It Does
8
8
9
-
When your OpenCode session becomes idle, this plugin analyzes your conversation and identifies tool outputs that are no longer relevant (superseded file reads, old errors that were fixed, exploratory searches, etc.). These obsolete outputs are pruned from future requests to save tokens and reduce costs.
9
+
This plugin automatically optimizes token usage by identifying and removing redundant or obsolete tool outputs from your conversation history. It operates in two modes:
- Phase 1: Automatic duplicate removal (same as auto mode)
21
+
- Phase 2: AI analysis to identify obsolete outputs (superseded information, dead-end exploration, etc.)
22
+
- Maximum token savings
23
+
- Small LLM cost for analysis (reduced by deduplication first)
24
+
25
+
When your session becomes idle, the plugin analyzes your conversation and prunes tool outputs that are no longer relevant, saving tokens and reducing costs.
10
26
11
27
## Installation
12
28
@@ -27,84 +43,92 @@ Restart OpenCode. The plugin will automatically start optimizing your sessions.
27
43
28
44
## Configuration
29
45
30
-
The plugin supports both global and project-level configuration:
46
+
### Available Options
31
47
32
-
-**Global:**`~/.config/opencode/dcp.jsonc` - Applies to all OpenCode sessions
33
-
-**Project:**`.opencode/dcp.jsonc` - Applies only to the current project
48
+
-**`enabled`** (boolean, default: `true`) - Enable/disable the plugin
49
+
-**`debug`** (boolean, default: `false`) - Enable detailed logging to `~/.config/opencode/logs/dcp/YYYY-MM-DD.log`
50
+
-**`model`** (string, optional) - Specific model for analysis (e.g., `"anthropic/claude-haiku-4-5"`). Uses session model or smart fallbacks when not specified.
51
+
-**`showModelErrorToasts`** (boolean, default: `true`) - Show notifications when model selection falls back
- Override settings per-project (e.g., disable for sensitive projects, use different models)
66
-
- Commit project config to version control for team consistency
67
-
68
-
### Creating Project-Level Config
69
-
70
-
To create a project-specific configuration:
71
-
72
-
1. Create `.opencode` directory in your project root (if it doesn't exist)
73
-
2. Create `dcp.jsonc` file inside `.opencode/`
74
-
3. Add your project-specific settings
72
+
The global config is automatically created on first run. Create project configs manually to override settings per-project:
75
73
76
74
```bash
77
-
# In your project directory
78
75
mkdir -p .opencode
79
76
cat > .opencode/dcp.jsonc << 'EOF'
80
77
{
81
-
// Project-specific DCP settings
82
78
"debug": true,
83
-
"protectedTools": ["task", "read"]
79
+
"pruningMode": "auto"
84
80
}
85
81
EOF
86
82
```
87
83
88
-
The global config (`~/.config/opencode/dcp.jsonc`) is automatically created on first run. Project configs are opt-in and must be created manually.
84
+
After modifying configuration, restart OpenCode for changes to take effect.
85
+
86
+
### Choosing a Pruning Mode
89
87
90
-
### Configuration Options
88
+
**Use Auto Mode (`"auto"`) when:**
89
+
- Minimizing costs is critical (zero LLM inference for pruning)
90
+
- You have many repetitive tool calls (file re-reads, repeated commands)
91
+
- You want predictable, deterministic behavior
92
+
- You're debugging or testing and need consistent results
91
93
92
-
-**`enabled`** (boolean, default: `true`)
93
-
Enable or disable the plugin without removing it from your OpenCode configuration.
94
+
**Use Smart Mode (`"smart"`) when:**
95
+
- You want maximum token savings (recommended for most users)
96
+
- Your workflow has both duplicates and obsolete exploration
97
+
- You're willing to incur small LLM costs for comprehensive pruning
98
+
- You want the plugin to intelligently identify superseded information
94
99
95
-
-**`debug`** (boolean, default: `false`)
96
-
Enable detailed debug logging. Logs are written to `~/.config/opencode/logs/dcp/YYYY-MM-DD.log`.
100
+
**Example notification formats:**
97
101
98
-
-**`model`** (string, optional)
99
-
Optional: Specify a model to use for analysis in "provider/model" format (e.g., `"anthropic/claude-haiku-4-5"`). When not specified, the plugin uses the current session model or falls back to authenticated providers in priority order.
0 commit comments