Documentation Index
Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
Use this file to discover all available pages before exploring further.
This is Part 2 of the OpenCode on Upsun series. If you haven’t deployed your OpenCode server yet, start with How to Host OpenCode on Upsun.Running an AI coding agent in server mode is powerful — but token costs add up quickly. Every API call sends tool schemas, conversation history, and file contents to the model. On a busy session with multiple file reads and command outputs, you can easily burn 3x the tokens you actually need. This guide walks you through installing three community plugins that significantly reduce token usage on your existing OpenCode deployment on Upsun, with minimal changes to your configuration.
Why tokens accumulate
Before diving into the fixes, it helps to understand where the waste comes from:- Tool descriptions — OpenCode ships with many built-in tools. Their full descriptions are sent with every API call, even when most tools are unused in a given step. This compounds across multi-step tasks.
- Bash output floods — Commands like
pytest,npm install, ordocker builddump hundreds of lines into the context. The model processes all of it, including passing test names, deprecation warnings, and progress bars. - Stale context — In long sessions, the model replays conversation history and re-reads files that are no longer relevant, inflating context size over time.
These plugins are community-maintained and not officially endorsed by OpenCode.Always:
Check their GitHub repositories for the latest updates and compatibility with your OpenCode version.
Test in a staging environment before deploying to production.
The plugins
Token reduction percentages are sourced from each plugin’s official documentation and may vary based on session
length, model, and usage patterns.
OpenSlimedit — tool description compression
OpenSlimedit aggressively shortens all built-in tool descriptions,
compacts file read output, and adds line-range editing support. Because tool schemas are sent with every API call,
compressing them saves thousands of input tokens per step — and this compounds across multi-step tasks.
Benchmarks show 11-45% token reduction across tested models, with zero regressions on Claude Opus 4.6. It works
by modifying descriptions of existing tools only, which avoids the model confusion that affects approaches using
custom tool schemas.
opencode-dcp — dynamic context pruning
opencode-dcp manages the conversation context
between turns. It exposes a compress tool to the model that replaces stale, closed content with high-fidelity
technical summaries before sending requests to the LLM — without modifying your actual session history.
Unlike OpenCode’s built-in compaction (which triggers statically when the context hits its limit), DCP lets the model
decide when to compress and which specific messages to target. This results in 50-70% token reduction on long
sessions.
opencode-snip — bash output filtering
opencode-snip automatically prefixes shell commands with
snip, a CLI proxy that filters command output before it reaches the LLM
context window. It handles git, go, cargo, npm, docker, and more — keeping errors and summaries while
dropping noise.
This delivers 60-90% reduction on bash-heavy sessions.
Important considerations
While these plugins are widely used and tested, they may:- Modify tool behavior:
OpenSlimeditalters tool descriptions. - Affect session history:
opencode-dcpcompresses context, which may remove details the model needs. - Introduce latency:
snipadds a small overhead to shell commands.
Installation
OpenCode loadsnpm plugins automatically via Bun at startup — no manual npm install needed for the plugins
themselves. The only exception is snip, a standalone Go binary that must be installed separately during the build.
Step 1 — Declare the plugins in opencode.json
Add the three plugins to the plugin array in your opencode.json:
opencode.json
Step 2 — Deploy
Commit and push:Terminal
snip binary during the build hook, and restart OpenCode. The three
npm plugins are fetched and cached by OpenCode on first startup.
Which plugin for which problem?
| Problem | Plugin | Reduction |
|---|---|---|
| High token cost per step (all sessions) | OpenSlimedit | 11-45% |
| Long sessions with growing context | opencode-dcp | 50-70% |
Bash-heavy sessions (npm, pytest, docker) | opencode-snip | 60-90% |
Verify the plugins are loaded
Once deployed, connect to your OpenCode instance and pressCtrl+P → View Status (System category). You should
see all three plugins listed as active.
For opencode-dcp specifically, you can check savings at any point during a session by running:
OpenCode prompt
Troubleshooting
snip binary not found at runtime
If OpenCode logs show snip: command not found, the binary was not installed correctly during the build. Check the
build output with:
Terminal
install-github-asset.sh step. The asset name pattern is snip_VERSION_linux_amd64.tar.gz — if a
new release changes the naming convention, update the pattern accordingly in your build hook.
Check installed plugin
To check installed plugins, connect to youropencode container and run the following command:
Terminal
opencode-dcp increases token usage on short sessions
DCP is most effective on sessions longer than 15-20 turns. On short sessions, the overhead of the compress tool itself can outweigh the savings. Remove it from theplugin array if your typical sessions are short:
opencode.json
A plugin causes unexpected tool behavior
Pin to a specific version instead of@latest to stabilize your deployment:
opencode.json