dsh-set-model: Enabling Agents to Autonomously Switch Models and Reasoning Depth per Task

Preface

Running agents in DeepSeek Harness (DSH), the common practice is to fix a single model for the whole session, or to manually change the provider, model, and thinking intensity in the GUI. When a task switches from “editing copy, running tests” to “production incidents, architecture planning,” you either keep burning cost on a high-reasoning model, or you remember to say “use deep thinking” in your prompt — the experience isn’t coherent.

The dsh-set-model plugin introduced below (maintainer john-walks-slow) is a “model reasoning” plugin in the DSH / cordis ecosystem (roughly 3 stars on GitHub, current package version 0.3.0). Through Jev decisions or Agent tool calls, it switches model presets and reasoning tiers according to task scenarios, and supports automatic Plan mode escalation/de-escalation plus a Web settings page. Community directory: SkillHub plugin page.

What is this

In one sentence: write “which model to use when, and how deep to think” into policies and tiers, then let Jev decide every round or let the Agent call tools to execute.

The plugin writes to the same model/selection mechanism as the GUI model selector, so the Web UI state stays in sync. The three capability switches are independent: you can enable only Jev, only the tools, a combination, or turn them all off.

Three independent switches

Switch Default Function
enableModelTools true Injects set_model / list_models; can switch to any registered provider / model / thinking intensity
enablePresetTools false Injects switch_preset / list_presets; can only switch among tiers declared in presets
jevEnabled false TypeSafe Jev decides the tier at the first step of each round, without relying on the tools above

The tier tools only constrain the Agent’s tool surface; manual model switching in the GUI is not intercepted by the plugin and can serve as a manual fallback. None of the three switches changes existing GUI behavior either.

Core capabilities

Policy prompt policyPrompt

The same policyPrompt has two readers:

  • Agent: when at least one of enableModelTools or enablePresetTools is true, it enters the system prompt as a ## Model policy section.
  • Jev: when jevEnabled is true, it is sent with each round’s decision request (state.policy), participating in the judgment together with the user’s latest instruction and the previous reply.

When both readers are disabled, this configuration is not read, and the plugin only logs a warning.

Example:

policyPrompt: |
  规划与疑难排查一律先切 deep;日常实现、改文件、跑测试用 daily。

After tier tools are enabled, the Agent also sees a tier list auto-generated from presets’ id / name / when; each tier’s when is also Jev’s judgment basis.

Model tiers presets

Declare a set of “model + thinking intensity” tiers in the profile. Leaving both provider / model empty means keeping the current model and only adjusting reasoningEffort. When presets is not configured, three built-in tiers low / medium / high are provided (none bound to a specific model).

Runtime context

The plugin writes the currently active model into the Runtime Context snapshot via systemPrompt.context (reusing the snapshot when the content is unchanged, which helps the cache). The model can always see something like:

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

When Plan mode is active, [Plan Mode Active] is appended; preset: xx only appears when a tier is hit.

Agent tools

Free model switching (enableModelTools):

  • set_model({ provider?, model?, reasoningEffort?, reason }) — reason is required; each switch invalidates the session KV cache, so the tool description requires the Agent to give a reason and avoid frequent switching.
  • list_models({ provider? }) — lists registered providers and model capabilities.

Tier mode (enablePresetTools):

  • switch_preset({ preset, reason }) — preset is a tier id from the configuration; the switch takes effect from the next step.
  • list_presets({}) — lists allowed tiers, applicable stages, and the currently active tier.

The tools are only registered to the root Agent; subagents do not get autonomous model switching. Turning off both tool switches disables the entire tool surface.

Plan mode auto-escalation

The plugin listens to the Plan projection of agent/pre-step:

  1. Entering Plan (/plan on): stash the current model; prefer switching to the tier specified by planPreset, otherwise switch to planModel.
  2. Exiting Plan (approving exit_plan_mode or /plan off): with the default autoRestorePlanModel: true, restore the model from before entering.
  3. Automatic switching failures only warn and do not interrupt the step.

Jev auto tier switching

When jevEnabled: true, the first step of each round calls TypeSafe Jev (part of the OpenRouter Decisions API system): it combines the latest user instruction (aligned with not-yet-submitted input), the previous reply (tail-truncated to 2000 characters), presets, and keep to select a tier; if confidence is below jevConfidenceThreshold (default 0.7), nothing changes.

Credentials can be configured via the settings page or the environment variables JEV_API_KEY / JEV_BASE_URL / JEV_MODEL; the README describes each decision taking about 200–300ms. During Plan mode Jev actively yields; failures only warn and do not block the conversation. Jev is decoupled from the two tool switches and can be enabled alone.

Safety guardrails

  • When allowedProviders is non-empty, switches to providers outside the whitelist are rejected; non-compliant entries are also discarded during tier loading, with error logs.
  • When the session token count exceeds the target model’s contextWindow, switching is rejected, with a prompt to compress the context first (e.g., clear_mind).
  • Supports 7 levels of thinking depth off | minimal | low | medium | high | xhigh | max; if the target model doesn’t support a level, it is clamped to the nearest supported one; non-reasoning models automatically strip thinking depth; validated again through DSH’s ctx.llm.resolveCallConfig.
  • Configuration diagnostics (duplicate tier ids, missing provider/model, planPreset pointing to a nonexistent tier, etc.) are written to the host log without taking down the whole plugin tree.

Installation and activation

The README fetched does not provide a single-line dsh plugin add … command; activation relies on the loader entry in the profile and Web settings. The settings namespace is the loader entry id: set-model; after saving, the host re-applies it immediately without a restart.

Add an entry in the profile’s cordis.patch.yml (or the user layer written via the settings page), e.g.:

- id: set-model
  name: dsh-set-model
  config:
    enableModelTools: true
    enablePresetTools: false
    jevEnabled: false
    presets:
      - id: daily
        name: 日常执行
        when: 常规实现、修改、测试
        provider: deepseek
        model: deepseek-chat
        reasoningEffort: low
      - id: deep
        name: 深度攻坚
        when: 疑难排查、架构设计
        provider: deepseek
        model: deepseek-reasoner
        reasoningEffort: max
    policyPrompt: |
      线上事故排查一律先切 deep。
    planPreset: deep
    autoRestorePlanModel: true

Visual maintenance path: Settings → Dynamic Model. You can edit the tier table, policy prompt, tool switches and allowedProviders, Plan targets, the Jev switch and API, etc.; fields must be marked as volatile to appear in the DSH settings form (the plugin follows the DSH settings system conventions).

Before installing or upgrading the plugin package, verify the source code and LICENSE yourself at the GitHub repository; the plugin runs with the permissions of the current DSH process.

Typical usage

1. Let the Agent switch only between tiers

Suitable for deployments that want to limit the model-switching scope and avoid arbitrary provider switching:

  1. Set enablePresetTools: true, and disable enableModelTools as needed.
  2. Write good presets and policyPrompt.
  3. The Agent calls switch_preset during planning or troubleshooting phases, e.g.:
{ "preset": "deep", "reason": "疑难并发问题排查,需要深度推理" }

2. Adjust only thinking depth on the same model

Fill in only reasoningEffort in the tiers, leaving provider / model empty. Jev or switch_preset will keep daily tasks at low and escalate tricky ones to max on the current model, without switching endpoints.

3. Enable Jev, less manual and tool usage

  1. Configure complete presets (it’s recommended that every tier has a when; otherwise Jev may find insufficient information and the plugin will warn).
  2. Set jevEnabled: true, and configure jevApiKey or environment variables.
  3. The user just sends new instructions each round; on a hit, the host log shows something like:
dsh-set-model: [Jev] auto-switched session <id> to preset "deep" (deepseek/deepseek-reasoner · reasoning: max) with confidence 0.87

4. Separate Plan from daily

Set planPreset: deep (or planModel), keep daily conversations on the daily tier; entering /plan on auto-escalates the tier, and after exiting, autoRestorePlanModel restores it.

Applicable scenarios and caveats

Suitable for: teams whose task types vary greatly within the same DSH session and want automatic or semi-automatic balance between cost and reasoning depth; scenarios already using Plan mode that want a stronger model by default during the planning phase; multi-provider deployments needing provider whitelists and context window guardrails.

Caveats:

  • Plugin capabilities depend on DSH’s model catalog and routing; on switching failures or Jev unavailability, consult the logs, and the current tier remains unchanged.
  • Frequent set_model invalidates the KV cache; as a policy, prefer tiers + Jev, and attach a clear reason for tool switching.
  • SkillHub is a community directory site, with no official affiliation with DeepSeek / High-Flyer (幻方); stars and versions should be taken from the GitHub / npm package at the time you install.

Conclusion

dsh-set-model distills “task type → model and thinking depth” into configurable tiers and policies, optionally letting Jev execute automatically every round, or letting the Agent execute autonomously via set_model / switch_preset; Plan mode also supports automatically stashing and restoring the model.

  • Directory page: https://www.skillhub.cn/plugins/john-walks-slow/dsh-set-model
  • Source code and full configuration docs: https://github.com/john-walks-slow/dsh-set-model
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye