john-walks-slow/dsh-set-model

Per-agent model switching for DeepSeek Harness: set_model / list_models agent tools with provider whitelist and token-budget guardrails, plus plan-mode model staging and cache-safe active-model context.

Project Overview项目介绍

dsh-set-model is a purpose-built DeepSeek Harness plugin (a cordis plugin targeting DSH 0.1.2-rc.1) that gives the root Agent two tools — set_model({ provider?, model?, reasoningEffort?, reason }) and list_models({ provider? }) — so it can autonomously switch provider, model and reasoning effort by task difficulty, with reason required because each switch invalidates the session KV cache. The plugin writes model/selection events into the session (the same channel used by the GUI model selector, so the Web UI state stays in sync), and appends one cache-safe line to the Runtime Context snapshot each step, such as [Current active model: deepseek/deepseek-chat · reasoning: low] or, in Plan mode, [Current active model: deepseek/deepseek-reasoner · reasoning: high] [Plan Mode Active], letting the model self-check without an extra tool call.

It is intended for users who want the Agent to keep cheap high-throughput settings for routine work yet escalate to a high-reasoning model such as deepseek-reasoner when facing hard concurrent or multi-step reasoning tasks, with no manual config toggling in between. Plan mode handles the escalation automatically: on /plan on the plugin snapshots the current daily model and switches to the configured planModel; on exit_plan_mode approval or /plan off it restores the original model when autoRestorePlanModel is true (default), and any failure only emits a warn, never interrupting the step. Installation is dsh plugin --profile web add dsh-set-model, or add github:john-walks-slow/dsh-set-model for source, where the first run is intercepted by pnpm ≥10 and the prompted package must be added to ~/.dsh/profiles/web/pnpm-workspace.yaml under allowBuilds before rerunning.

Dependencies are pinned to @deepseek-ai/cordis 4.0.2, @deepseek-ai/dsh-agent, dsh-llm, dsh-session, dsh-tools 0.1.2-rc.1, zod ^3.24.2, and Node ≥ 22.5; the plugin performs no external network calls and no direct filesystem writes, routing all model resolution through DSH core ctx.llm.resolveCallConfig. Safety guardrails reject switches when the session token pressure exceeds the target model contextWindow (prompting the user to compact, e.g. via clear_mind), honour the allowedProviders whitelist, validate every candidate combination through DSH's adapter registry, and restrict the tools to the root Agent only — set enableAgentTools: false to disable them globally. License is MIT; local dev is npm install && npm run build && npm test, and releases run npm run release followed by the WebAuthn fingerprint script, with npm view dsh-set-model version as the post-publish check.

dsh-set-model 是为 DeepSeek Harness(DSH / cordis plugin)打造的动态模型与思考深度切换插件,通过 set_model 与 list_models 两个工具让根 Agent 按任务难度自主切换 provider、model 与 reasoningEffort,并把当前活跃模型以 cache-safe 追加方式注入 Runtime Context 快照尾部,供模型随时自查。插件通过 model/selection 事件写入会话,与 Web UI 模型选择器复用同一机制,切换自下一个 step 生效;进入 Plan 模式自动升至 planModel,退出后按 autoRestorePlanModel(默认开启)恢复原模型,全程零人工干预。

典型场景是日常任务保持高性价比档位,遇到疑难并发或多步推理时一键升级到 deepseek-reasoner 等高智力档位。安装仅需 dsh plugin --profile web add dsh-set-model 或从 GitHub 源码 add github:john-walks-slow/dsh-set-model;首次 pnpm ≥10 会被拦截,需把构建包名加入 ~/.dsh/profiles/web/pnpm-workspace.yaml 的 allowBuilds 后重跑。配置通过 Settings 命名空间 dsh-set-model 在 Web Settings UI 实时生效,支持 allowedProviders 白名单、enableAgentTools: false 关闭工具以及仅根 Agent 注册。

依赖 @deepseek-ai/cordis 4.0.2、@deepseek-ai/dsh-agent、dsh-llm、dsh-session、dsh-tools 0.1.2-rc.1(与 dsh 0.1.2-rc.1 锁定对齐)、zod ^3.24.2,Node ≥ 22.5,无外部网络请求与文件系统写入。当会话 token 水位超过目标模型 contextWindow 时切换被拒并提示先压缩上下文(如 clear_mind);自动切换失败仅 warn 降级,工具校验失败返回明确错误。License 为 MIT,开发使用 npm install && npm run build && npm test,发版通过 npm run release 打包后用 WebAuthn 指纹脚本发布。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add dsh-set-model

把 john-walks-slow/dsh-set-model 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-set-model

简体中文 · English

为 DeepSeek Harness(DSH / cordis plugin)提供动态模型与思考深度切换的插件:Agent 通过 set_model / list_models 工具按任务难度自主切换 provider、model 与 reasoningEffort,插件把活跃模型注入运行时上下文,并随 Plan 模式自动升降级模型。

攻坚疑难问题时升到高推理档位,日常执行保持高性价比档位——不再需要用户手动改配置。

模型看到什么

插件通过 systemPrompt.context 在每个 step 的 Runtime Context 快照尾部注入一行当前活跃模型(cache-safe 追加,模型随时自查、无需调用工具):

[Current active model: deepseek/deepseek-chat · reasoning: low]

处于 Plan 模式时附带状态标记:

[Current active model: deepseek/deepseek-reasoner · reasoning: high] [Plan Mode Active]

工具:set_model

set_model({ provider?, model?, reasoningEffort?, reason }) —— reason 必填(每次切换都会使会话 KV cache 失效,工具说明要求 Agent 给出理由、避免频繁切换):

{ "model": "deepseek-reasoner", "reasoningEffort": "high", "reason": "疑难并发问题排查,需要深度推理" }

工具返回:

Model successfully switched to deepseek/deepseek-reasoner · reasoning: high. Effective from the next step.
Reason: 疑难并发问题排查,需要深度推理

工具:list_models

list_models({ provider? }) 列出已注册 Providers 与模型能力(推理档位、上下文窗口):

# Available Providers & Models:

## Provider: deepseek
- **deepseek-reasoner** (DeepSeek Reasoner) | Reasoning: [low, high, max] | Context: 128000
- **deepseek-chat** (DeepSeek Chat) | Context: 128000

切换自下一个 step 生效:插件向会话写入 model/selection 事件(与 GUI 模型选择器同一机制),Web UI 状态同步。

Plan 模式自动升降级

插件监听 agent/pre-step 的 Plan 投影状态变迁,零人工干预:

  • 进入 Plan 模式(/plan on):暂存当前日常模型,自动切换到配置的 planModel(高智力规划模型);
  • 退出 Plan 模式(exit_plan_mode 批准 / /plan off):自动恢复进入前的日常模型(autoRestorePlanModel,默认开启);
  • 自动切换失败仅 warn 降级,绝不打断 step。

安全护栏

  • Provider 白名单:allowedProviders 非空时,白名单外的切换请求直接拒绝;

  • 上下文窗口护栏:当前会话 token 水位超过目标模型 contextWindow 时拒绝切换,并提示先压缩上下文(如 clear_mind):

    Current session token pressure (70000 tokens) exceeds target model context window (65536 tokens).
    Please compact context (e.g. clear_mind) before switching to this model.
    
  • 路由校验:候选组合经 DSH 核心 ctx.llm.resolveCallConfig 校验(provider 适配器存在、模型合法、reasoningEffort 受支持),非法组合返回明确错误,不写入任何会话状态;

  • 仅根 Agent:工具只注册给根 Agent(subagent 不提供自主调模);enableAgentTools: false 可整体关闭。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-bridge 下一个 Next dsh-plugin-kit →