About this project
Dynamic Context Pruning (DCP) is a plugin for OpenCode that automatically reduces token usage by managing conversation context. It provides three core strategies: Compress replaces stale conversation content with high-fidelity technical summaries using either range mode (compressing contiguous spans) or experimental message mode (compressing individual messages). Deduplication identifies repeated tool calls with identical arguments and keeps only the most recent output. Purge Errors removes inputs from errored tool calls after a configurable number of turns while preserving error messages.
The plugin operates without modifying session history — it replaces pruned content with placeholders before sending requests to the LLM. Configuration is handled via a JSONC file with project-level overrides, supporting per-model context limits, protected file patterns, protected tools, and customizable nudge thresholds. A TUI panel (/dcp) and slash command (/dcp-compress) provide manual control. Prompt overrides are available for advanced customization.
DCP notes that pruning invalidates prompt cache prefixes, with testing showing ~85% cache hit rate vs ~90% without, but token savings typically outweigh cache miss costs. The project is in maintenance mode with new features moving to Sleev, a local proxy for multiple AI coding tools. Licensed under AGPL-3.0-or-later.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.