dsh-verify-gate: Stopping the Model Before It Clocks Out

Introduction

In the DeepSeek Harness (DSH) agent loop, safety review (dsh-experimental-auto-review) and loop prompts already handle a fair number of issues, but the “completion boundary” is still missing a guard. The model writes code, reads it back, decides it looks fine, and declares “done”—never running a single test or type check along the way. In real sessions, this path is extremely common.

dsh-verify-gate sits exactly at that step. Before the model says “I’m done,” it checks whether code files were modified in the current turn and whether any checks were actually run. If the answer is “yes” and “no,” respectively, it injects a reminder into the model’s next-step context: go run the checks, or explain why they aren’t needed.

What It Is

dsh-verify-gate is a “completion gate” plugin for DeepSeek Harness, maintained by Raysnows and classified under Workflow. It only reminds—it never blocks. When a turn modifies code files without running a single test or type check, the plugin gives the model one reminder before it wraps up: either actually run the checks, or file a specific exemption reason.

Core Features

The plugin asks two questions per turn:

  1. Did the model modify any code files this turn? (.js / .ts / .py / .go / .rs …)
  2. After modifying them, did it run any checks? (tests, type checking, node --check, tsc, pytest …)

If the first answer is “yes” and the second is “no,” the plugin injects a reminder into the model’s next-step context. The reminder is aimed at the model, not a popup for you.

What it deliberately does not do:

  • No blocking: it only nudges, it never stops the task. One block might save a bug, but it would slow down every single task.
  • Ignores docs: editing .md / .json doesn’t count, otherwise every documentation commit would trigger a warning.
  • No judgment on correctness: a failing test still counts as “verified”—what it cares about is whether the model actually looked at reality, not whether reality agrees with it.
  • No pretending isolation: the agent/pre-step payload carries no agent identity, so concurrent agents share one conservative ledger.

Installation & Enablement

Install command:

dsh plugin --profile web add dsh-verify-gate

No configuration required, no host restart needed. Once installed, depending on the model’s behavior, you’ll see:

Model’s behavior Result
Edits .js, runs nothing, says “done” One reminder
Edits .js, runs node --check No reminder
Edits .mjs, calls verify_exemption("only type definitions changed, no runtime path") No reminder

The exemption tool has a gate: reasons shorter than 12 characters are rejected outright, preventing the model from sliding by with “n/a.”

How It Works

The plugin observes and injects messages through three seams:

Seam Type Purpose
tools/execute waterfall (exec, next) Observe calls; exec.name and exec.arguments
agent/pre-step waterfall (payload, next) Inject reminder into decision.messages
agent/turn-stopping serial Finalize accounting, clear the ledger

turn/start and turn/end are session log entries (session.append(...)), not context events. Listening to them will never fire.
Injected messages must use the user role: in agent/pre-step, any message other than runtime-context is logged by the host as a user/message session event. The reminder text is wrapped in <system-reminder> so the model still reads it as a host-level notice, not a user utterance.

Fixing Sessions Corrupted by 0.1.0

Version 0.1.0 may have left an unloadable record in a session log. Upgrading to 0.1.1+ stops the bleeding but will not repair logs already broken: until that line is rewritten, the affected session will remain unopenable. A repair script ships in the package:

node node_modules/dsh-verify-gate/scripts/repair-session.mjs           # dry run, scans all sessions
node node_modules/dsh-verify-gate/scripts/repair-session.mjs --apply   # actual rewrite, auto-backup

It locates lines where a user/message entry contains a system message and rewrites them into the standard system/message event the host would have written itself (turn/step taken from the nearest preceding step/start), re-compressing only the zstd frame containing the affected line. Before rewriting, it self-checks the entire log, leaves an in-place backup as session.v4.jsonl.zstd.orig-<timestamp>, and moves the session’s projection cache aside so it rebuilds.

Run it while DSH is closed—it writes directly to session files on disk. Use --sessions-dir to point at an alternate root, or --no-projcache to skip touching the cache.

Use Cases & Caveats

This plugin suits developers building agents in DSH who want to ensure every code change is at least verified once. It runs with the current dsh process’s permissions; review the source code and license before installing.

Known limitations:

  • Direct fs writes to disk inside a PTC bypass tool dispatch entirely and are invisible. Only inner calls to tools.write / tools.edit are observed.
  • Single ledger. See “No pretending isolation” above.
  • “Verification” is matched via command regex. Project-specific check scripts may be missed—the bias is toward one extra reminder, never toward a false pass.

Closing Note

dsh-verify-gate fills the guard on DSH’s completion boundary, making sure the model checks whether any verification was run before calling it a day. No blocking, no false alarms—just a reminder. If you’re writing code in DSH, you can find this plugin on GitHub: https://github.com/Raysnows/dsh-verify-gate

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

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

Xiaoye