Back to home@Milbaxter

dsh-critique-loop

DeepSeek Harness plugin: forces one critique-and-improve round after each completed turn.

Stars
0
Language
JavaScript
Created
Sep 1, 2026
Updated
Sep 1, 2026
GitHub repo

Introduction

dsh-critique-loop

English | 中文说明

A DeepSeek Harness (dsh) plugin that intercepts turn completion and triggers an automatic self-critique and improvement round.

Ported from the Grok Build harness experiment Milbaxter/grok-harness.


Why

Standard agent loops stop immediately when the model finishes its tool calls or responds with final text. By intercepting the terminal stopping boundary (agent/turn-stopping) and steering the agent before the turn closes, this plugin forces the model to review its own actions:

"Critique what you just did. Be specific about mistakes, gaps, and weaker choices. If the critique finds something worth changing, apply the improvement now. If nothing material needs changing, say so briefly and stop."

The next stop is permitted through without looping (or up to maxRounds), preventing runaway continuation while ensuring thorough verification.

Features

  • 🔄 Automatic Self-Review: Intercepts agent/turn-stopping to prompt the model for immediate self-reflection.
  • 🛡️ Loop Safe: Tracks per-turn critique counts with WeakMap isolation per agent; defaults to 1 round of critique per turn.
  • ⚙️ Configurable: Customize the critique prompt, maximum review rounds, or toggle enabled/disabled.
  • Zero Runtime Dependencies: Pure ES module built on Cordis lifecycle hooks and native Node.js APIs.

Installation

Add directly to your DeepSeek Harness profile from GitHub:

dsh plugin --profile web add github:Milbaxter/dsh-critique-loop

Or clone and add locally:

git clone https://github.com/Milbaxter/dsh-critique-loop.git
dsh plugin --profile web add ./dsh-critique-loop

Restart dsh web (or your headless session) after adding the plugin.

Configuration

In your cordis.yml or bundle configuration:

- id: dsh-critique-loop
  name: dsh-critique-loop
  config:
    enabled: true
    maxRounds: 1
    prompt: "Critique what you just did. Be specific about mistakes, gaps, and weaker choices. If the critique finds something worth changing, apply the improvement now. If nothing material needs changing, say so briefly and stop."

Options

OptionTypeDefaultDescription
enabledbooleantrueMaster switch to enable/disable the critique loop.
maxRoundsnumber1Maximum self-critique rounds per turn before stopping.
promptstring(standard prompt)Custom critique instruction steered into the agent.

Running Tests

npm test

Architecture

This plugin hooks into DeepSeek Harness's Cordis-based event system:

  1. Listens on agent/turn-stopping (serial terminal checkpoint).
  2. If shouldCritique(agent, turn) returns true, steers a user message with the critique prompt via agent.steer(...).
  3. Agent driver processes the steered input and executes another step in the open turn.
  4. Subsequent stop events in the same turn are allowed through to avoid recursion.
  5. On agent/pre-step, when genuine user messages arrive, per-turn counters are reset.

License

Apache 2.0 © Maximilian Rehn (Milbaxter)