Introduction¶
In the development of DeepSeek Harness (DSH), as the number of conversation rounds increases, the context window becomes filled with history and tool outputs, leading to increased inference costs and scattered attention. Manually cleaning up history is time-consuming and can easily result in losing key information. dsh-clear-mind is designed to address this issue by giving the model the ability to manage context autonomously, allowing it to compress redundant historical records into auditable checkpoints at appropriate times.
Plugin Overview¶
dsh-clear-mind is a plugin maintained by john-walks-slow (category: memory). Its core feature is “model-invokable context compaction.”
It provides two tools, mind_map and clear_mind, allowing the model (especially the root agent) to inspect the current context surface and autonomously replace a specified interval with a model-generated checkpoint. It also provides proactive threshold reminders, prompting the model to clean up when the context becomes too long. All operations generate expandable “tombstone” records in the GUI and do not depend on any external network services.
Core Features¶
This plugin provides the following capabilities:
- Model-invokable context compaction:
mind_map: Allows the model to overview the context surface by displaying the message sequence (seq), role, token weight, and boundary markers (▸,◂,◆), helping the model determine the cleanup range.clear_mind(start, end, notes): Replaces the history records in the[start..end]interval with a checkpoint written by the model, following the platform’s native compaction transaction process.
- Proactive threshold reminders: When the context token ratio reaches a configured threshold (e.g., 70%) or the number of steps in a single turn becomes too high, the plugin injects a
<system-reminder>at the next step boundary to guide the model to clean up. - Auditable GUI tombstones: Each cleanup operation is collapsed into a one-line tombstone in the GUI, preserving the notes content and supporting expansion for review to ensure the operation can be traced back.
- Zero network and zero external dependencies: The plugin runs entirely locally, makes no network requests, and depends on no external services.
- Platform transaction integration: It uses the platform’s native compaction transaction to ensure that the token meter and subsequent automatic compaction logic correctly recognize these operations.
- No impact on sub-agents: Sub-agents retain the platform’s automatic compaction mechanism, and manual history-modification tools are not exposed to them.
Installation and Enablement¶
Before installation, ensure the environment meets the requirements: Node.js version 22.5 or higher, and a DSH version aligned with dsh-tools 0.1.2-rc.1.
Run the following command to install the plugin:
dsh plugin --profile web add dsh-clear-mind
After installation, the plugin automatically mounts cordis.patch.yml. After restarting DSH, the model gains the mind_map and clear_mind tools. All parameters have reasonable built-in defaults and can be used without manual configuration.
Typical Usage¶
1. Invoking clear_mind for compaction¶
After the model confirms that the current stage has ended or the path is clear, it can invoke clear_mind. The parameters include the start sequence, end sequence, and notes content:
clear_mind(start, end, notes)
For example, to clean up a resolved build-error troubleshooting history:
clear_mind(1, 8, "已解决构建报错。问题出在 include 目录漏了 scripts。后续测试通过。")
2. Invoking mind_map to inspect the context¶
Before cleaning up, use mind_map to view the context surface:
mind_map()
This returns the current surface node count, token usage, and a preview of each message, helping the model identify the cleanup interval.
3. Configuring the reminder threshold¶
In the settings page (or configuration file), you can set the threshold for the context ratio relative to the model window. The default is 0.70 (i.e., 70%):
reminderThresholdRatio: 0.70
Notes¶
When using this plugin, be aware of the following behavior rules and limitations:
- Root agent only:
mind_mapandclear_mindare registered only for the root agent. Sub-agent context is managed automatically by the platform, and manual history-modification tools are not exposed. seqis identity:seqis the sequential ID of the context surface, not a numeric value. After cleanup operations, surface order may no longer be monotonic. When submitting, useseqas identity rather than interval length.- Automatic collapsing: Submitted
clear_mindcalls and their results are automatically collapsed into a one-line tombstone at the next step boundary to avoid redundant display. - Immutable logs: Human-side session records are append-only logs and are not modified by cleanup operations, preserving the source of truth.
- Headless mode compatibility: If the Web settings service is unavailable (e.g., in a Headless profile), the plugin automatically degrades to reading values from the configuration file.
- Version compatibility: Ensure you are using
dsh-tools 0.1.2-rc.1to guarantee full compatibility with the DSH platform contract.
Summary¶
dsh-clear-mind provides DSH with a controllable context management mechanism. By allowing the model to autonomously decide when to compress history and supporting it with a visual audit log, it effectively alleviates the token window pressure caused by long conversations while maintaining session traceability. For DSH users who need to handle complex tasks or multi-round iterations, this is a practical tool.
- Plugin directory: dsh-clear-mind - SkillHub
- Source repository: dsh-clear-mind on GitHub