dsh-glm-mode: DSH Coding Agent Preset and Guard Mechanism for GLM Models

When developing agents with DeepSeek Harness (DSH), targeted tuning based on the characteristics of different models is a common requirement. For models like zhipuai/glm-5.3-flash, directly using general presets can easily lead to issues such as inference long tails or tool call spinning. dsh-glm-mode is a dedicated plugin designed for such models, aiming to provide an out-of-the-box preset scheme and protection mechanisms.

Plugin Overview

This is a DSH coding Agent preset plugin tailor-made for zhipuai/glm-5.3-flash. It includes Programmatic Tool Calls (PTC), GLM-specific auto-compaction, and dual protection against reasoning death loops and tool spinning. The plugin is maintained by hoyyang and licensed under the MIT license.

Core Features

The plugin mainly solves the stability and efficiency issues of GLM series models in complex tasks:

  • PTC Programmatic Tool Calls: Integrates the full tool catalog into Code Mode, where the model writes TypeScript programs to combine multi-step operations. Compared with traditional methods, this reduces round trips and input tokens.
  • Thinking Death Loop Guard: Targets the long reasoning degradation (e.g., repeating thinking for tens of thousands of tokens in a single step) that GLM-5.3-flash may exhibit at high reasoning levels, detecting sentence-level repetition in the background. Once triggered, it truncates early, reuses the output token limit chain, and recovers operation by injecting a “continue” message.
  • Tool Spinning Guard: Prevents the model from hallucinating top-level tools and firing placeholder calls consecutively in PTC mode. Upon detecting consecutive placeholder calls, it injects correction messages through official decision channels, bringing the model back on track without interrupting the normal flow.
  • GLM-Specific Auto-Compaction: For 1M context scenarios, automatically compresses at a 75% threshold / 22% retention ratio, supporting seamless continuation with in-place summarization.
  • Native Multimodal: The preset declares support for text+image input and can directly process screenshots.

Installation and Activation

Installation

dsh plugin add dsh-glm-mode

After installation, DSH needs to be restarted or hot-reloaded.

Activation

In a new session:
1. Select “GLM Mode” in the preset selector.
2. Select zhipuai/glm-5.3-flash in the model list.
At this point, the plugin automatically takes effect, with guards working silently in the background, requiring no additional operations.

Configuration and Logs

The plugin provides default configuration located in cordis.patch.yml. Main configuration items include:

  • compactEnabled: Auto-compaction switch.
  • glmThresholdRatio / glmRetainRatio: GLM session compaction threshold and retention ratio.
  • loopGuardEnabled / spinGuardEnabled: Death loop and spinning guard switches.
  • loopGuardRepeatThreshold: Death loop detection threshold (default 8).
  • spinGuardStreakThreshold: Spinning detection threshold (default 5).

Guard trigger records are located in ~/.dsh/dsh-glm-mode/guard-events.jsonl, which can be used for troubleshooting anomalies.

Applicable Scenarios and Notes

  • Scope of Effect: The plugin only takes effect for models routed via zhipuai/glm-*; other models are unaffected.
  • Compatibility: Can coexist with Kiro mode, with the compaction strategy determined by official semantics.
  • Permission Security: The plugin runs with the current DSH process permissions; it is recommended to review the GitHub source code and license before use.

Summary

dsh-glm-mode solves the stability and efficiency issues of GLM series models in long reasoning and complex tool call scenarios. With this preset, developers can focus more on business logic rather than underlying model tuning. For more details, please refer to the GitHub repository.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye