dsh-stage-handoff: Finalize the Context Stage Before Compression and Hand Off the Next Stage to an Auditable Markdown File

Introduction

DeepSeek Harness (DSH) periodically compresses context during long-running agent sessions to free up token budget. Before compression, the current stage needs to be properly wrapped up, passing state and key decisions to the next stage. A common approach is to have the agent output a summary text, but this not only consumes extra tokens, but also risks losing details during compression, making it difficult for subsequent stages to trace back.

The dsh-stage-handoff plugin proactively prompts and guides the agent to wrap up the current stage before compression, generating an auditable Markdown file as the handoff artifact so that the next stage can continue working with more complete information.

Plugin Overview

dsh-stage-handoff is a workflow plugin designed for DeepSeek Harness, developed by maintainer WphiontaS. It injects reminders when context reaches a specified token threshold, guiding the agent to close the current stage and write a readable anchor file. The compression process preserves the retention budget of DSH’s automatic compaction engine rather than simply discarding trailing history, thereby maintaining context window utilization.

Core Features

  • Automatically injects a reminder when context reaches the threshold, triggering the agent to perform wrap-up actions
  • Guides the agent to generate a Markdown-formatted anchor file in the docs/anchors directory
  • Controls the character limit of anchor files to avoid excessive token consumption
  • Retains sufficient token budget before compression to ensure wrap-up actions can be completed
  • Provides a Web settings panel for dynamically adjusting reminder thresholds, retention budget, and other parameters

Installation and Activation

In DSH’s Web settings page, locate the “Stage Handoff” section and enable the plugin. Configuration items are updated at runtime via Cordis’s volatile-config event, requiring no restart.

The plugin is enabled by default and can be disabled in the configuration via enabled: false. Once disabled, reminder monitoring, tool execution, state handling, and related logic stop immediately, but the plugin remains mounted until the configuration file is reloaded.

Typical Usage

The plugin triggers a reminder when context reaches the threshold specified by notifyTokens. The default threshold is 363,520 tokens, which is half of the compaction wall under a 1M window. Upon receiving the reminder, the agent creates a Markdown file in the docs/anchors directory, recording key information from the current stage.

Configuration example (YAML):

- id: stage-handoff
  config:
    enabled: true
    notifyTokens: 363520
    notifyRepeatDelta: 25000
    anchorRoot: docs/anchors
    anchorLimitChars: 8000
    compactRetainTokens: 32000
    hostMaxTokens: 256000
    guardMaxBytes: 1048576
    staleReservationTtlMs: 86400000

The Web settings page provides three presets: 256k/512k/1M, which automatically set notifyTokens, compactRetainTokens, and anchorLimitChars. Each preset writes explicit values rather than clearing fields.

Applicable Scenarios and Notes

Suitable for agent workflows that require long-running execution with large context windows, particularly in multi-stage tasks that require clear handoffs.

The plugin runs with the permissions of the current DSH process. Before installation, review the source code and license (MIT). The plugin does not delete files—it only reports candidate files and stops; it does not replace the compaction backend but instead invokes DSH’s existing compactRegion method; it does not read anchor content, nor does it write anchors on behalf of the agent.

Ecosystem Context

DeepSeek Harness adopts a “everything is a plugin” philosophy. The community directory has no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-stage-handoff proactively wraps up context stages before compression, providing the next stage with a more auditable handoff artifact and reducing information loss during the compression process. It offers flexible configuration through the Web settings panel, making it suitable for agent projects that need to maintain context coherence during long-running sessions.

  • Directory page: https://www.skillhub.cn/plugins/WphiontaS/dsh-stage-handoff
  • GitHub: https://github.com/WphiontaS/dsh-stage-handoff
羽毛球分组比赛记分
小程序二维码

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

Xiaoye