dsh-maintainer-doc-guard: DeepSeek Harness Long-Term Memory and Intent Guard

Preface

DeepSeek Harness compresses model output when processing long contexts. This compression silently drops project conventions, plans, tech stack decisions, and current work state, causing the model to drift from its original intent in subsequent operations. A validated solution is to externalize this long-term memory into maintained documents and force the model to read these files before every operation, re-“hydrating” memory from the files instead of relying on lossy compression summaries.

Plugin Introduction

dsh-maintainer-doc-guard is a DeepSeek Harness bundle maintained by huxin7735-collab. It keeps long-term project memory outside the context window and ensures that long-turn responses remain accountable to the user’s actual request. The plugin uses a set of mechanisms to force the model to calibrate context before every operation, preventing execution drift caused by memory loss.

Core Features

The plugin includes five main functional modules, along with a sidebar tab for document management.

  1. Maintainer Documentation Reminder
    The plugin registers a system prompt section (maintainer-doc-guard). This section lists the maintainer documents in the workspace (plan.md, conventions.md, stack.md, state.md, maintainer/README.md) and instructs the model to read the relevant documents before every operation or thinking turn.
    Compared with inserting a message before each step, using a system prompt section avoids message accumulation in the session log and ensures the instructions are re-evaluated each time the prompt is assembled.

  2. Precedent Gate
    The plugin implements a tools/pre-execute defense mechanism. When the model attempts to edit protected infrastructure areas (such as plugins, presets, or skills), this mechanism blocks the operation unless at least one precedent file with the same base name has already been read in the session.
    This prevents the model from writing infrastructure code based on memory alone, which could introduce invented APIs. When an operation is blocked, the model sees a specific list of candidate files, for example:

    Blocked by maintainer-doc-guard: you are about to write "<target>", which lives
    in a guarded infrastructure area, but this session has not read any working
    "index.js" precedent that shows the real contract.
“Same base name” here acts as a proxy for “working analogy for this class of files,” not as proof.
  1. Intent Gate
    The plugin implements a second tools/pre-execute defense mechanism. The Precedent Gate controls “how” to write, while the Intent Gate controls “whether it is worth” writing. If a step does not state its purpose and includes side effects (such as writing files), the Intent Gate rejects the first such invocation. This forces the model to clearly state its intent before execution; if it cannot state it, it should stop and ask instead of blindly proceeding.

  2. Goal Anchor
    The plugin adds a Goal Anchor section to the system prompt. This section quotes the user’s latest instruction verbatim and includes explicit priority rules:

    1. The user’s latest instruction (Goal Anchor content)
    2. The plan stated by the model in the previous turn
    3. Clues or branch tasks discovered by the model itself
      This ensures that during long turns, the model does not drift away from the user’s original request due to self-derived branch tasks.
  3. Nudge Phase
    The plugin adds a correction phase before blocking operations. It injects a reminder when the model attempts the first rejected operation instead of blocking it directly; triggers one reminder in long turns; and only blocks when the violation recurs. This design gives the model a chance to adjust its behavior before being blocked.

Configuration

The plugin provides several configuration options on the Harness settings page to adjust its behavior:

  • docsDir: Used to override the default documentation directory .dsh-maintainer-doc-guard/.
  • gate.maxDeniesPerTarget: Limits the number of repeated denials for the same target file, preventing deadlocks.
  • anchor.order: Adjusts the position of the Goal Anchor in system prompt assembly.
  • anchor.inSubagents: Controls whether the Goal Anchor is also enabled in delegated subagents.

Notes

  • Environment Requirements: The plugin requires Node.js version 20 or later.
  • Memory Reads: The plugin’s reads of maintainer documentation are in-memory, indexed by session identity, and not persisted.
  • Subagent Behavior: By default, subagents do not receive the Goal Anchor. This preserves correctness, because subagents are started by delegation messages rather than direct user input; rendering the user’s latest instruction would invert the priority rules. To enable it, set anchor.inSubagents: true.
  • License: No license information was found for this plugin.

Conclusion

dsh-maintainer-doc-guard addresses memory loss and intent drift caused by long-context compression by forcing the model to calibrate maintainer documentation before every operation, quote the user’s latest instruction, and introduce intent and precedent guards. For DeepSeek Harness workflows that require long-term maintenance and complex iteration, this plugin provides the necessary structured constraints.

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

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

Xiaoye