Introduction

When using DeepSeek V4.1 Flash for long conversations, the model often negates previous conclusions, loses key state, or shows increased hallucinations. DSH’s native compaction mechanism is difficult to trigger during idle windows. The dsh-context-checkpoint plugin uses automatic summarization, compaction, and injection to pin critical state to the beginning of the prompt, ensuring the model reads the current facts at the highest-attention position.

What It Is

The plugin name is leafstory/dsh-context-checkpoint, maintained by Leafstory. This is a workflow plugin using the MIT license. It implements a closed loop: threshold reached → summarize and persist → automatic compaction → inject back to the beginning of context after compaction.

Core Features

  • Automatic summarization and persistence: Writes project state to a file as long-term storage.
  • Injection into the beginning of context after compaction: After compaction, injects it as static context without relying on model memory.
  • Schedules compaction using context_compact: Uses a tool to schedule the compaction timing.
  • Triggers compaction at the agent/pre-step step boundary: Does not depend on idle windows; automatically runs during step transitions.
  • context_status and context_compact tools: Provide interfaces for status checking and scheduling.

How It Works

  1. Threshold check: Trigger summarization when usage exceeds the threshold.
  2. Persistence: Write state to the important_view.<task>-<session>.md file.
  3. Scheduling: Use context_compact to schedule compaction.
  4. Injection: After compaction, inject it as static context at the front of the prompt.

Typical Usage

  • User intent exemption: When the user explicitly says “summarize/persist/compact”, the trigger threshold is waived.
  • Force bypass: Calling context_compact {force:true} can bypass the threshold and persistence gate.
  • Status check: Use context_status to view exact token usage.
  • Audit: Use scripts/list-events.mjs to inspect checkpoint injection status.

Installation and Enablement

The plugin is installed via npm scripts:

npm run dsh:install

After installation, you must restart DSH for changes to take effect.

Applicable Scenarios and Notes

  • Dependencies: Relies on DSH’s native compaction engine and does not implement its own compaction algorithm.
  • Trigger timing: Compaction does not depend on idle windows; it automatically runs at the agent/pre-step step boundary.
  • Context nature: The injected content is static context and does not rely on model memory.
  • Scheduling condition: Before scheduling compaction, ensure the checkpoint file exists and is fresh (within 10 minutes).

Short Conclusion

This plugin repeatedly places critical state at the front of the prompt through engineering techniques, making it a practical tool for improving the stability of long-running tasks.

Directory page: Leafstory/dsh-context-checkpoint
GitHub: Leafstory/dsh-context-checkpoint