opencode-dcp-dynamic-limitsOpenCode plugin that syncs DCP context limits to the active model and quiets chat reminder spam.
5
30
近 7 天 6
31.1
生态多维模型
2 个月前
2026-05-27
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-dcp-dynamic-limits@0.1.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-dcp-dynamic-limits@0.1.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-dcp-dynamic-limitsopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode plugin for one specific annoyance: DCP should follow the context window of the model you are actually using.
I wrote this for my local llm-server setup, where OpenCode switches between GGUF models served by ik_llama.cpp / llama.cpp and normal cloud models. When the active model changes, DCP can be left with stale limits. That is when it starts pruning at the wrong time, or worse, keeps dropping dcp-system-reminder messages into the chat.
This plugin runs on real chat requests, figures out the active model context, and updates the DCP config before DCP needs it.
Install
npm install -g opencode-dcp-dynamic-limits
Add it after DCP in your OpenCode config:
{
"plugin": [
"@tarquinen/opencode-dcp@latest",
"opencode-dcp-dynamic-limits"
]
}
DCP needs to load first. This plugin only adjusts DCP's config.
llm-server
The main target is llm-server:
llm-server model.gguf --port 8081 --ctx-size 262144
Point OpenCode at that local OpenAI-compatible endpoint as usual. The plugin will read the active provider/model and, for llama.cpp-style backends, use the running server's context instead of guessing from a static number.
It also works with plain llama.cpp-style servers, Ollama-style local providers, and cloud models from the OpenCode model manifest.
What It Changes
The plugin writes both common DCP config files when they exist:
~/.config/opencode/dcp.jsonc
~/.opencode/dcp.jsonc
It updates:
activeModelminContextLimitmaxContextLimit- notification/nudge settings that keep reminders out of the chat
It ignores non-chat calls like the title agent, so a title-generation request cannot shrink your DCP limits.
Context Rules
For local llama.cpp-style servers:
- prefer runtime
--ctx-size - fall back to
/v1/modelsmetadata - treat
--parallelslot size as diagnostics, not the full context window
For cloud models:
- use OpenCode's model manifest context
The DCP limit is set to 85% of the detected context. Quiet mode sets minContextLimit equal to maxContextLimit, which avoids the repeated soft-warning zone while still letting DCP prune at the hard limit.
The quiet settings are:
{
"pruneNotificationType": "toast",
"compress": {
"nudgeForce": "soft",
"nudgeFrequency": 50,
"iterationNudgeThreshold": 50
}
}
Development
npm install
npm test
npm pack
License
MIT