opencode-context-warningOpenCode plugin that warns agents about context window consumption and nudges handoff
1
328
近 7 天 3
34.2
生态多维模型
2 个月前
2026-06-07
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-context-warning@0.1.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-context-warning@0.1.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-context-warningopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode plugin that warns agents about context window consumption and nudges handoff
Installation
npm install opencode-context-warning
Features
- Monitors the LLM context window token usage during the session.
- Provides customizable warnings (e.g., at 70% capacity) to prompt the agent to summarize.
- Forces sub-agent handoffs when context approaches maximum limits (e.g., 90%).
- Prevents degradation of reasoning quality caused by bloated context windows.
Usage
This is a plugin for OpenCode.
You can easily enable this plugin globally by adding it to your opencode.json (or opencode.jsonc) configuration file under the plugins array.
{
"plugins": [
"opencode-context-warning"
]
}
Once added to your configuration, OpenCode will automatically load and activate the plugin whenever it starts.
Alternatively, if you are configuring OpenCode programmatically via the SDK, you can register it like this:
import { configureAgent } from '@opencode-ai/sdk';
import plugin from 'opencode-context-warning';
const agent = configureAgent({
plugins: [
plugin({
// Provide configuration options here
})
]
});