基于 Jev System One 分流、动态工具裁剪与子代理路由的智能 Token 优化插件。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:JessenReinhart/dsh-tokenslash
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
TokenSlash
Keep the context that matters. Drop the overhead that doesn't.
TokenSlash is a Cordis plugin for DeepSeek Harness (DSH) that makes agent context more deliberate. It uses lightweight, structured decisions to select task-relevant tools and prompt sections, keep tool output manageable, and help agents route work without permanently losing access to capabilities.
Your agent should spend its context solving the task, not rereading the descriptions of tools it will never call.
What it does
| Capability | What you get |
|---|---|
| Task-aware prompt pruning | Selects relevant tool schemas and prompt sections for the current task. |
| Output and observation hygiene | Compacts oversized tool results and can mask older observations to keep context focused. |
| Subagent routing | Uses structured decisions to select model tiers and decide when a fork can run with less parent context. |
| Tool recovery | Lets an agent inspect a pruned tool's schema or unlock that tool for the current turn. |
| Workflow guardrails | Optional goal, turn-completion, and tool-safety hooks. |
| Visibility | In-chat savings telemetry, prune statistics, history, and a settings UI. |
TokenSlash is configurable rather than one-size-fits-all. Tool pruning supports normal, extreme, and off modes; tools can be pinned, and individual modules can be enabled or disabled.
Quick start
Install from GitHub using the DSH plugin manager:
dsh plugin add github:jessenreinhart/dsh-tokenslash
Then open the DSH settings for TokenSlash, choose a triage provider, and configure the model and module switches for your setup.
- Default preset: 9Router Proxy
- Other presets: OpenCode Zen, TypeSafe Jev, OpenRouter, Inception Labs (Mercury Decide), LocalJev, and a custom endpoint
- Runtime: Node.js 20+
The provider is used for narrow, structured decisions. It is not the conversational model that writes code or answers general questions.
Built-in agent tools
TokenSlash adds focused utilities that help an agent use its existing tools more efficiently.
| Tool | Use it for |
|---|---|
| tokenslash_index | Get a structural outline of a file: signatures, exports, symbols, and line ranges. Use it to locate the relevant part before requesting a larger read. |
| tokenslash_batch | Run independent tool calls in parallel, or run calls sequentially when order matters. |
| tokenslash_peek | Inspect the schema of a pruned tool, or unlock it so the agent can use it during the current turn. |
| tokenslash_diagnose | Classify errors and test failures, suggest files to inspect, or rank candidate tests by relevance. |
| tokenslash_triage | Ask the configured decision engine a narrow probability or multiple-choice question. |
A note on triage
The triage engine is a micro-decision engine, not a chat model. Use it for decisions such as:
- Is this task suitable for a cheaper subagent model?
- Can this fork proceed without the parent's full conversation history?
- Which tool group is relevant to this prompt?
- Is this test failure likely to be flaky?
Do not use it to write code, inspect files, search the web, or answer open-ended questions. Keep those jobs with the main agent and its normal tools.
How pruning stays reversible
- Read the task. TokenSlash evaluates the current prompt with the configured decision provider.
- Keep the useful surface. Relevant tool groups and prompt sections stay available; irrelevant schemas can be pruned.
- Recover on demand. The agent can call tokenslash_peek to inspect or unlock a tool that turns out to be needed.
- Fail open. The default configuration favors preserving normal tool access when triage is unavailable or fails.
That last point matters: pruning should reduce clutter, not strand an agent halfway through a task.
Configuration
Most users can configure TokenSlash from the DSH settings UI. The main controls include:
| Setting | Purpose |
|---|---|
| Provider / model | Select a supported decision endpoint and model. |
| Tool pruning mode | normal for conservative pruning, extreme for more aggressive pruning, or off to disable tool pruning. |
| Pinned tools | Keep named tools available regardless of the pruning decision. |
| Fail open | Preserve tool access when the decision provider cannot be used. |
| Modules | Toggle routing, fork decoupling, prompt pruning, output compaction, observation masking, prefix-cache alignment, and guardrails. |
See docs/TRIAGE.md for provider and decision-format details, and docs/COMPATIBILITY.md for the tested DSH/Cordis host contracts.
Benchmarks and measurement
Token savings depend on the task, available tool set, DSH runtime, and decision provider. A pruning pass can add overhead when most tools are still relevant, so there is no fixed savings percentage promised by this project.
The repository includes the benchmark harnesses and raw result files so you can inspect the measurements and compare them with your own workload:
- Single-turn benchmark
- Multi-turn benchmark
- Latest single-turn result
- Latest multi-turn result
- Benchmark methodology and handoff notes
Development
Requires Node.js 20 or later.
npm install
npm test
The test command runs the project's Node.js test suite.
Project links
License
MIT © Jessen Reinhart
链接
同类插件
bowenliang123/dsh-context★ 5364
DSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
Han-1413141/dsh-cost-meter★ 737
会话与当日 API 费用统计、预算图框(已用%)、官方余额、历史看板,支持峰谷计价与官方价格一键同步。
wssfk12138/dsh-damage-pulse★ 290
在 DSH Web 界面追踪 DeepSeek Token 用量、单次与会话费用及账户余额,并显示缓存感知的扣费动画。
zh667/TokenLedger★ 205
侧边栏用量面板:把 Token 归属到实际服务该请求的中转站,站点从已有的 provider 配置中读出,无需额外配置;含今日/本月/累计三窗口、按站点与模型下钻、一年活跃度热力图,以及 New API / Sub2API / DeepSeek 余额。
Ychris12138/dsh-usage-stats★ 192
多供应商用量看板:按供应商/模型统计 Token 与日期下钻,统一展示账户余额,并追踪 OpenCode Go / Z.ai 订阅额度。
PolinniZhong/dsh-personal-center★ 115
DeepSeek Harness 个人中心:跨会话用量统计(按供应商/模型分别统计,自动读取已配置模型)、按模型成本估算、全局自定义指令、数据驱动的桌面宠物(位图/矢量皮肤)与会话状态概览,纯本地离线运行。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。