The design philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” When using third-party models (such as GPT or Qwen-thinking), models often do not adapt well to certain internal mechanisms of DSH, leading to compaction failures, sandbox permission escalation errors, or abnormal tool calls. dsh-model-compat-guard is a third-party model compatibility guard plugin that resolves these frequent compatibility issues by intercepting and repairing specific types of requests.

Core Features

This plugin intervenes in the request stream through DSH’s plugin mechanism, mainly fixing the following four issues:

  1. Compaction truncation in thinking models
    The root cause is that the default maxTokens limit in dsh-compaction-basic is 8192, while the thinking tokens of thinking models count toward the same output budget and can easily exhaust the limit. The plugin intercepts requests where purpose === "compaction", raises maxTokens to 32768 (configurable), and lowers the reasoning effort to the cheapest level supported by the model, avoiding truncation errors.

  2. Sandbox permission escalation request failures
    When the sandbox executor is mounted, the tool schema globally advertises the sandbox_permissions field, while the actual mode is resolved per session. When a model requests escalation in the danger-full-access mode, it can fail because no broader mode can be found and justification must be non-empty, resulting in fail-closed behavior. The plugin parses ctx.sandboxPolicy, strips escalation requests that are guaranteed to fail (sandbox_permissions + justification), and executes according to the current mode.

  3. Missing tool descriptions
    Tools such as bash and run_code mark description as required, but models often omit it. The plugin intercepts the tools/execute pipeline and checks the schema before strict validation: if the required description is missing, it automatically synthesizes one (for example, for bash it uses the first line of the command, and for run_code it uses the first line of valid code).

  4. Frequent Code Mode run_code errors
    The TypeScript programs generated by models may have incomplete syntax (such as unpaired quotes) or misuse bash results (treating them as strings rather than structured objects). The plugin detects Code Mode requests (when only the run_code tool is present), appends a discipline block at the end of the system prompt, and standardizes how tool return values are read.

Installation and Activation

Installing the plugin requires specifying the pinned version v0.4.0. After installation, restart the DSH process for the configuration to take effect.

dsh plugin --profile web add github:782042369/dsh-model-compat-guard#v0.4.0

Uninstall command:

dsh plugin --profile web remove dsh-model-compat-guard

Configuration and Typical Usage

The plugin can be configured in ~/.dsh/compat-guard.json. The default configuration covers common scenarios and can be used with zero configuration.

Configuration file example (~/.dsh/compat-guard.json):

{
  "compactionMaxTokens": 32768,
  "compactionEffort": "auto",
  "compactionPurposes": ["compaction"],
  "fillDescription": true,
  "descriptionTools": ["bash", "run_code", "subagent", "subagent_fork", "workflow"],
  "codeDiscipline": "off",
  "stripEscalation": "redundant",
  "unknownPolicy": "preserve",
  "modelInfoTtlMs": 300000,
  "modelInfoTimeoutMs": 5000,
  "logFixes": true
}

Configuration options:
* compactionMaxTokens: token limit for compaction requests, default 32768.
* compactionEffort: reasoning effort level; "auto" selects the cheapest level, while "keep" leaves it unchanged.
* stripEscalation: escalation stripping policy; "redundant" (default, strips only guaranteed-to-fail requests), "always" (also strips legitimate escalation requests), "off".
* codeDiscipline: Code Mode discipline; "off" (recommended to use the native ~/.dsh/AGENTS.md), "auto", "always".
* fillDescription: whether to automatically fill in missing tool descriptions, default true.

Test command:

node test/smoke.mjs

Applicable Scenarios and Notes

This plugin is suitable for scenarios where thinking models such as GPT and Qwen-thinking are used in DSH, or where Code Mode errors are encountered.

  • Runtime environment: Only Node.js >= 20.0.0 is supported.
  • Permissions: The plugin runs with the permissions of the current DSH process; it is recommended to review the GitHub source code before installation.
  • License: MIT license.

Summary

dsh-model-compat-guard resolves compatibility issues for third-party models in the DSH environment by intercepting and repairing the request stream. It can run without complex configuration and is suitable for developers who need to reliably use thinking models or Code Mode.

GitHub Repository