Introduction¶
In DeepSeek Harness (DSH), agents produce many intermediate steps during exploration: reading, searching, experimenting, tool calls, and outputs. These steps are written into a durable log for auditing purposes. However, if left on the model-visible session surface, subsequent requests will carry these intermediate processes, consuming context capacity that could be used for the current task.
@dpskh/tool-rewind solves this problem: while retaining the durable log, it folds the exploration surface after the most recent checkpoint mark into an automatically generated report. When the next round of requests begins, the model sees the report instead of every step of the exploration process.
What is this¶
@dpskh/tool-rewind is a DeepSeek Harness plugin maintained by dpskh, positioned as an exploration fold. Once mounted, it provides two entry points:
ctx.rewind
rewind
Among them, ctx.rewind is the service interface, and rewind is the plugin tool facing the model. It needs to be used in conjunction with @dpskh/tool-checkpoint: checkpoint is responsible for recording marks, and rewind is responsible for folding the exploration surface after the mark.
The plugin does not modify upstream packages, nor does it write its own session events; the folding only submits a replacement of a user/message from the core-vocabulary. The package information currently verified in the materials is as follows:
name: @dpskh/tool-rewind
version: 0.2.0
private: true
license: MIT
Core Capabilities¶
Folding the Exploration Surface¶
It reads the latest checkpoint mark in the session, selects a surface span after that mark, generates a report via ctx.llm, and then replaces this exploration surface with the report.
This replacement uses the same mechanism as the DSH compaction seam:
surfaceOp: { op: 'replace' }
After the replacement, subsequent requests no longer carry the intermediate steps of the exploration process; the durable log still retains the complete exploration content for auditing.
Service Invocation¶
The service invocation method given in the documentation is:
ctx.rewind.rewind(agent, signal)
This step completes three things: selecting the surface span after the latest mark, invoking the report generation, and then submitting the replaced user/message report.
If folding fails, the plugin does not write content: the original exploration area remains intact, the mark remains active, and the invocation is rejected with a classified RewindError. The failure types listed in the materials are as follows:
NO_CHECKPOINT
EMPTY_REGION
UNBALANCED
FOLD_IN_PROGRESS
CHANGED
SHRINK
The plugin uses a per-session in-process lock to reject concurrent folding for the same session. As long as there is an active checkpoint mark in the session, it injects a turn-stopping warning, preventing the current turn from ending until rewind folds the exploration.
Report Generation¶
The report is generated by ctx.llm. The provider/model resolution order in the report invocation is:
- Override in configuration;
- Last routed
request/headerconfig in session; - Agent options.
If the provider/model cannot be resolved from these three places, the report invocation will fail.
When the route exposes off reasoning effort, the report invocation disables thinking. Empty completion will retry, with the maximum number of retries determined by the configuration item maxSummarizationRetries.
The report invocation reuses the session’s system prompt and tool schemas, keeping them as the prefix of the last routed request, thereby maintaining the warm prefix cache.
Installation and Usage¶
The currently verified materials do not provide an official installation command. Do not concatenate commands based on the package name; below only shows the mount configuration appearing in the materials.
Configuring @dpskh/tool-rewind separately:
- id: tool-rewind
name: '@dpskh/tool-rewind'
config:
toolName: rewind
maxTokens: 1024
maxSummarizationRetries: 2
summarizationProvider: deepseek
summarizationModel: deepseek-chat
reportLanguage: en
Field meanings are as follows:
toolName: rewind
maxTokens: 1024
maxSummarizationRetries: 2
summarizationProvider: deepseek
summarizationModel: deepseek-chat
reportLanguage: en
In actual use, it is usually necessary to mount it together with the checkpoint plugin:
- id: tool-checkpoint
name: '@dpskh/tool-checkpoint' # https://github.com/dpskh/dsh-checkpoint
- id: tool-rewind
name: '@dpskh/tool-rewind'
config:
reportLanguage: en
When only mounting @dpskh/tool-rewind, there is no checkpoint mark, so folding has no target and fails with a no-checkpoint error.
Typical Usage¶
Invoking the Service¶
In DSH code or plugin logic, you can invoke it directly:
ctx.rewind.rewind(agent, signal)
This invocation is responsible for selecting the surface range, generating the report, and submitting the replaced report message.
Model Tool Return¶
The rewind tool takes no parameters. The return object given in the materials is:
{ markId, foldedNodes, start, end, foldedChars, reportChars }
Model Visibility¶
The replaced report becomes visible to the model starting from the next request. The durable events during exploration remain in the log but no longer appear on the model-visible surface.
The plugin also adds a system prompt paragraph:
tool:rewind
Used to establish the fold discipline, i.e., folding promptly after exploration occurs after a mark, rather than leaving intermediate steps on the model-visible surface indefinitely.
Applicable Scenarios and Caveats¶
Who is it for¶
Suitable for DSH agent scenarios that need to retain both audit logs and compressed model-visible context. Common practices are:
- Use
@dpskh/tool-checkpointto mark the start of exploration; - Let the agent complete a segment of exploration;
- Use
@dpskh/tool-rewindto fold this segment of exploration into a report; - Subsequent requests continue based only on the report, not the entire intermediate process.
Limitations to Note¶
-
Must have a checkpoint mark.
rewindfails when working alone due to the lack of a mark. -
A marker can only be folded once.
Folding the same marker again is rejected as an empty region. New exploration requires a new checkpoint. -
The shrink check is based on character count, not token count.
The report must be shorter than the model-visible text of the area being folded. Image blocks have no text scale and are conservatively ignored. -
Empty completion may occur under certain routes.
If the route does not exposeoffreasoning effort, default thinking may exhaustmaxTokens, leading to an empty completion. In this case, one can only rely on the retry budget ofmaxSummarizationRetries. -
Automatic compaction may occur before rewind.
If automatic compaction obscures part of the exploration beforerewindruns, the fold will cover the remaining part still on the surface; the storage-resident mark will still be retained. -
No writing on failure.
Failure preserves the original area, keeps the active mark, and rejects with a classifiedRewindError. -
Source code and license need to be checked before installation.
The plugin runs with the permissions of the current DSH process. It is recommended to check the source code, dependencies, and theMITlicense before installation to ensure they fit your usage environment.
Links¶
Directory page:
https://dshfind.com/zh/plugins/dpskh/dsh-rewind?ref=badge
GitHub:
https://github.com/dpskh/dsh-rewind