dsh-session-shield: Preventing Malformed Tool Calls from Causing Session Log Loading Failures

Preface

DeepSeek Harness (DSH) occasionally encounters situations where model outputs produce malformed tool calls during model invocation, such as an empty id, an empty name, or arguments that is not a string. DSH is lenient during runtime validation but strict during decoding. Once a corrupt event is persisted to disk, the session log becomes unloadable, and the sidebar displays stored session ... is corrupt.

The following introduces a plugin that intercepts and repairs these issues before the log is persisted to disk.

Plugin Overview

This is a DeepSeek Harness plugin maintained by hbgdjb and licensed under MIT. It hooks into DSH’s official llm/stream waterfall and intercepts all model calls through a single hook.

Core Features

  • Automatic Malformed Call Repair: Intercepts and replaces malformed tool calls. An empty id generates call-guard-<token>-<index>, an empty name is replaced with guard_malformed_tool_call, and invalid arguments are converted to a JSON string.
  • Valid Calls Pass Through Unchanged: Valid tool calls are left unmodified.
  • Zero Dependencies & Zero Configuration: No additional dependencies, no client-side code, no file writes—effective immediately after installation.

Installation

Install via the plugin manager’s install_bundle, or through the installation entry point in Settings → Plugins.

  1. Installation Package (Recommended Distribution): Provide the absolute path to the .tgz file.
  2. Source Directory: Provide the absolute path to the directory after unzipping the source zip.
  3. Registry/Git: Install using the package name or repository URL once published.

Configuration & Activation

After successful installation, configure in the profile’s cordis.patch.yml:

- id: session-shield
  enabled: true

Verify that the configuration is active:

dsh --profile <profile> --dump-config

The output should include the # == dsh-session-shield section and the - id: session-shield line. Finally, restart DSH to apply the changes.

Verification & Notes

  • Environment Requirements: Requires DeepSeek Harness 0.1.x (Web).
  • Log Behavior: Plugin logs are output to an in-memory buffer and do not appear in manager.log. Therefore, it is normal not to see an “armed” log entry at startup.
  • Security: The plugin runs with the permissions of the current DSH process. Please review the source code and license (MIT) before installation.

Conclusion

dsh-session-shield resolves the session log corruption issue by intercepting and repairing malformed tool calls at the stream processing stage. This is a lightweight, zero-configuration plugin suitable for all developers using DSH 0.1.x.

Catalog Page | GitHub Repository

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

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

Xiaoye