🎁 福利专区全网大模型免费应用 + 新用户福利 + 注册活动入口,低成本玩转 AI

工具预取加速 Liman-cmd/dsh-plugin-tool-prefetch

DeepSeek Harness
Liman-cmd5 天前有提交已提供中文文档扫描:含敏感能力

预测下一步工具调用并分层预热,降低调用延迟

29.7/100
综合分
0
GitHub 星标
—
npm 周下载
—/5
用户评分

数据截至 2026/11/2 · 周下载取自 npm 全网(含 CI / 镜像),非本站安装数;综合分由星标、活跃度与兼容性检查合成。

安装命令 · 需先装 dsh CLI 引擎
dsh plugin --profile web add Liman-cmd/dsh-plugin-tool-prefetch
该包不可直接 npm 安装,改从 GitHub 源安装(明细见下方安装检查)

状态速览

判定依据:实装验证 · 静态安装检查 · 自动扫描 · 仓库维护状态
信任档位:仅索引
是什么[目录]—
dsh 原生插件 · tool
暂无时间戳·判据 →
装得上吗[实装验证]—
本站尚未做安装检查
暂无时间戳·判据 →
安全吗[自动扫描]—
本站尚未对该插件做风险分级
暂未覆盖,不等同于无风险
数据截至 2026/11/04·判据 →
还在维护吗[仓库]✓
活跃:最近一次提交在 5 天前
暂无时间戳·判据 →
图例:✓ 通过! 需注意— 未判定 / 无数据· 「未判定」= 本站尚无数据,不代表插件有问题
档位由哪些信号合成

本站实装验证(真实安装 L4 覆盖全站;L5 为运行时冒烟或实机截图,覆盖范围小于 L4) · 验证所用 dsh 版本 · 静态安装检查 · 风险分级 · 仓库维护状态。 下方各区块是它的证据明细。

验证判据与等级说明 →
社区实装还没有人打卡 · 装过的第一个就是你
安全扫描自动 · 静态分析源码
v2.7.0
🔵 扫描:含敏感能力尚无人工评估
展开查看扫描说明与证据 ↓

静态扫描发现插件具备触达本地系统的能力:执行外部命令、读写/删除本地文件、读取剪贴板或密钥类环境变量(至少其一)。这是能力清单,不是危险判定——具体能力项与证据见下方,安装前请自行判断是否需要。

可执行外部命令读写/删除本地文件发起外部网络请求
查看扫描证据(共 27 处,展示前 24 条)
  • 写入本地文件
    index.js:38
    mkdirSync(probeDir, { recursive: true })
  • 写入本地文件
    index.js:39
    appendFileSync(
  • 执行外部命令来自配置/变量
    index.js:95
    this.proc = spawn(this.cfg.python, args, {
  • 写入本地文件
    index.js:385
    mkdirSync(dir, { recursive: true })
  • 写入本地文件
    index.js:386
    appendFileSync(
  • 读取本地文件
    index.js:400
    if (!existsSync(cfg.python) && cfg.python !== 'python' && !cfg.python.includes('/')) {
  • 写入本地文件
    index.js:409
    mkdirSync(dirname(p), { recursive: true })
  • 写入本地文件
    index.js:410
    appendFileSync(p, JSON.stringify({ ts: Date.now() / 1000, event, ...data }) + '\n')
  • 发起网络请求
    index.js:535
    .request('tools/call', { name: 'gw_register_tools', arguments: payload }, cfg.callTimeoutMs)
  • 发起网络请求
    index.js:598
    .request('tools/call', {
  • 发起网络请求
    index.js:641
    .request('tools/call', {
  • 发起网络请求
    index.js:669
    await sidecar.request(
  • 发起网络请求
    index.js:681
    const listed = await sidecar.request('tools/list', {}, cfg.initTimeoutMs)
  • 发起网络请求
    index.js:716
    .request('tools/call', { name: 'gw_apply_pending', arguments: {} }, cfg.callTimeoutMs)
  • 读取本地文件
    interceptor-smoke.mjs:43
    const lines = readFileSync(TELEMETRY, 'utf8').trim().split('\n')
  • 读取本地文件
    interceptor-smoke.mjs:91
    for (const line of readFileSync(TELEMETRY, 'utf8').trim().split('\n')) {
  • 读取本地文件
    probe-local.mjs:58
    const lines = readFileSync(logPath, 'utf8').trim().split('\n').map((l) => JSON.parse(l))
  • 删除本地文件
    probe-local.mjs:83
    try { rmSync(logPath) } catch {}
  • 读取本地文件
    session-extract-test.mjs:21
    const src = readFileSync(join(here, 'index.js'), 'utf8')
  • 读取本地文件
    session-extract-test.mjs:33
    for (const proj of readdirSync(root)) {
  • 读取本地文件
    session-extract-test.mjs:35
    if (!statSync(projDir).isDirectory()) continue
  • 读取本地文件
    session-extract-test.mjs:36
    for (const s of readdirSync(projDir)) {
  • 读取本地文件
    session-extract-test.mjs:39
    const st = statSync(p)
  • 读取本地文件
    session-extract-test.mjs:52
    const buf = readFileSync(logPath)
扫描于 2026/11/4(0 天前) · 范围 入口闭包 + 发布文件清单 · 来源 GitHub 仓库

静态扫描只反映源码中出现的调用,不构成安全背书;人工评估与自动扫描相互独立、互不覆盖。

给这个插件打分还没有人投票↓
用户评分
还没有人投票,来当第一个

DeepSeek Harness 插件:工具调用预测与预取。以 Python 边车方式拉起 CT-GNN 预测网关,把其工具原生注册到 ctx.tools——预测下一个工具调用、分层预热(L0-L3)、在线命中率遥测、训练数据自动采集。

README

由 DeepSeek 最新模型翻译生成
dsh-plugin-tool-prefetch DeepSeek Harness(dsh)插件:把 agent-tool-acceleration 的工具调用预测网关作为 Python sidecar 拉起,将其工具(gw_predict_next / gw_observe / gw_stats / gw_reset + 代理的真实上游工具)原生注册到 ctx.tools——不是 MCP 服务器配置,是正经插件:在 Settings → Plugins 可见、可启用/禁用(禁用即杀掉 sidecar)。 零 npm 依赖(纯 JS + node:child_process),预测由论文的 CT-GNN 模型提供(CPU,~15 ms/次)。
展开完整文档(README 剩余 1 节)
dsh-plugin-tool-prefetch

DeepSeek Harness(dsh)插件:把 agent-tool-acceleration 的工具调用预测网关作为 Python sidecar 拉起,将其工具(gw_predict_next / gw_observe / gw_stats / gw_reset + 代理的真实上游工具)原生注册到 ctx.tools——不是 MCP 服务器配置,是正经插件:在 Settings → Plugins 可见、可启用/禁用(禁用即杀掉 sidecar)。

零 npm 依赖(纯 JS + node:child_process),预测由论文的 CT-GNN 模型提供(CPU,~15 ms/次)。

四种模式(config.mode)

| mode | 注册工具吗 | 挂钩子吗 | 用途 |
| interceptor(随包默认)| ❌ | ✅ 自动采集+预测+预热 | 透明加速:零 token、零 agent 配合;预测发生在模型还在写 reasoning 时 |
| tools | ✅ 全部 24 个 | ❌ | v1 显式版:模型能主动调预测/遥测工具;采集需 agent 传参 |
| probe | ❌ | ✅ 只写日志 | 一次性验证:确认 dsh 会触发钩子、exec.agent 是什么形状 |
| both | 仅 gw_(7 个)| ✅ | 隐形加速 + 保留人工查询/切模型入口 |

代码内缺省值是 tools;随包的 cordis.patch.yml 显式设成 interceptor。
interceptor 若拉不起 sidecar(网关没装/路径错),钩子照常 next() 透传,只是不上报——不会挡住任何工具调用。

切换只改配置值,不用动代码:

- insert:
- id: tool-prefetch
name: dsh-plugin-tool-prefetch
config:
mode: 'interceptor' # ← 改这里 python: 'D:\...\.venv\Scripts\python.exe' repoRoot: 'D:\...\agent-tool-acceleration' gatewayConfig: 'mcp_prefetch_gateway/configs/tau_retail_gpt4o_real.yaml' sessionFrom: 'agent' # interceptor 用 exec.agent 分会话 catalogApply: true # 新增工具并入服务图(实测保序、已有预测逐位不变) catalogAllowRemovals: false # 删除会移位索引,需显式开 autoModelSwap: true # 飞轮晋升后自动应用(免重启 dsh) modelSwapPollMs: 300000 # 轮询间隔

工具目录上报(自动,无需配置)

插件在启动时取 ctx.tools.schemas()、并监听 tools/change(dsh 未过滤注册表通知,任何工具增删/权限变化都触发)增量上报实际工具集。网关据此与离线产物 diff——这是「命中率莫名下降」最常见的隐藏原因,现在会明确告警(cli health 或 gw_tool_catalog 可见)。

自动换模型(autoModelSwap)

飞轮过闸后会写网关配置,但运行中的网关是插件的子进程(不同进程),原先需重启 dsh 才生效。开着这个开关,插件定期调 gw_apply_pending,配置变了就地热切换。关掉即回到纯手动(只有显式 gw_switch_model / cli switch-model 才换)。

验证钩子 + 用户消息采集(mode: probe)

装好后重启 dsh、随便调一个工具,然后:

Get-Content D:\...\agent-tool-acceleration\mcp_prefetch_gateway\logs\probe.log -Tail 10

看到含 agentId + sessionUserFound: true 的 pre_execute 行 = 钩子可用且能从 agent.session.log 挖出用户原文。探针不改任何行为(next() 原样透传,实测 0ms)。

用户消息藏在 agent.session.log 的 user/message 事件里,而注入的 AGENTS.md / skill 列表 / 时间上下文同样是 type:user/message + role:'user',只有 data.source.kind 不同(agent-instructions / skill-catalog / time-context …)。所以筛选用白名单 source.kind === 'user',不能只看 role。详见 docs/interceptor-probe.md。

这个仓库包含什么 / 不包含什么

本仓只有「桥」(约 8 KB JS),不含预测、采集、训练的实现——它们在配套的网关项目 agent-tool-acceleration:

| 能力 | 在哪 | 本仓有吗 |
| 插件壳(拉起 sidecar、原生注册工具、转发调用)| index.js(本仓)| ✅ |
| 预测(CT-GNN / markov 冷启动)| 网关 mcp_prefetch_gateway/ | ❌ 需配套项目 |
| 数据采集(step 事件 → 遥测)| 网关 server.py + telemetry.py | ❌ 需配套项目 |
| 训练 / 再训(飞轮)| scripts/retrain_gateway.py + src/train.py | ❌ 需配套项目 |

因此:只装本插件跑不起来。 完整依赖见下节。

安装

完整依赖(缺一不可)

| 依赖 | 说明 |
| 网关项目 | agent-tool-acceleration 检出(目前私有,需权限)|
| Python 环境 | .venv + pip install -r requirements.txt(torch 等,CPU 版即可)|
| 模型产物 | data/processed/model_.pt + graph_.pkl(被 gitignore,不在任何仓里)|
| 轨迹文件 | data/processed/trajectories_.jsonl——⚠️ 不只是训练用:网关启动时要拿它拟合 BM25 词表 |
| τ-bench 环境 | data/raw/tau-bench(真实零售数据库,git clone https://github.com/sierra-research/tau-bench)|

有权限的人 → 跑 scripts/setup_gateway.ps1 一条命令备齐环境。

装插件

从 GitHub(推荐)
npx @deepseek-ai/dsh plugin --profile web add github:Liman-cmd/dsh-plugin-tool-prefetch

或本地路径(开发)
npx @deepseek-ai/dsh plugin --profile web add ./dsh-plugin-tool-prefetch

重启 dsh web;Settings → Plugins 里应出现 tool-prefetch
npx @deepseek-ai/dsh web

⚠️ 本插件未附带预训练模型的可分发形态。换成你自己的工具场景时,retail 模型不适用——需要用你自己的数据重训(见"数据飞轮"),或先跑 markov 冷启动模式(predict.mode: markov,零训练即可用)。

配置

插件默认值写在 cordis.patch.yml(指向本仓库路径)。换机器/换配置:把该行拷进你的 profile patch(~/.dsh/profiles/web/cordis.patch.yml)改值:

- insert:
- id: tool-prefetch
name: dsh-plugin-tool-prefetch
config:
python: 'D:\path\to\.venv\Scripts\python.exe'
repoRoot: 'D:\path\to\agent-tool-acceleration'
gatewayConfig: 'mcp_prefetch_gateway/configs/tau_retail_gpt4o_real.yaml'
toolPrefix: '' # 注册名前缀,避免与其他插件重名 initTimeoutMs: 60000 # sidecar 冷启动预算(torch+模型 ~20s) callTimeoutMs: 120000

行为要点

- 冷启动异步:sidecar 启动 ~20 s,不阻塞 dsh;工具就绪后自动出现。
- 真实执行 + 自动对账:代理工具真调上游(默认 τ-bench retail 真实数据库),每次调用自动写入 session 状态并对账上一条预测(_gateway.session_id 可选携带)。
- 数据飞轮:所有真实调用自动落遥测 step 事件。查看采集进度: python -m mcp_prefetch_gateway.cli status --config <gateway yaml>(会告诉你距首次可训还差几条轨迹、按近期速率预计几天);攒够后 python scripts/retrain_gateway.py ... 一键再训换模型。

要不要训 GNN? 先看任务类型(论文结论):短流程、无上下文依赖的任务, markov 计数通常就够了,GNN 未必更好;多轮、上下文相关的任务 GNN 才显著领先。
所以对很多场景,"自己的模型"这个目标本身是多余的——计数版已随使用变准。
- 与 MCP 配置互斥:若之前在 cordis.patch.yml 配过 mcp-prefetch (dsh-mcp-client 行),装本插件前删掉那行,避免 21 个工具注册两遍。

排障

| 症状 | 处置 |
| 工具一直不出现 | dsh 日志找 [tool-prefetch];多半是 python 路径/产物路径错 |
| 验证 sidecar 本身 | node dsh-plugin-tool-prefetch/smoke.mjs(不起 dsh 全链自测)|
| 想换预测模型 | 改 gatewayConfig 指向别的 configs/*.yaml |

许可

MIT。预测器与数据来自本仓库论文项目(τ-bench 数据为 Sierra 官方开源实现)。
预览分享卡片长什么样 ↓Liman-cmd/dsh-plugin-tool-prefetch
分享 · DeepSeek Harness Hub
Liman-cmd/dsh-plugin-tool-prefetch

预测下一步工具调用并分层预热,降低调用延迟

这个插件是你维护的吗?
作者本人可认领并核对本条目;认领通过后,详情页会显示「作者已认领」标记。
认领条目 →
回到顶部