dsh-carryover: DeepSeek Harness Session Handoff Plugin

Preface

The context in DeepSeek Harness (dsh) will eventually reach its limit. The common practice after reaching the limit is to “start a new session,” which causes the loss of everything agreed upon in the previous round, unfinished tasks, and details mentioned by the counterpart. If you don’t clear the session, you are burning money in an increasingly long context every time; if you do clear it, and the summarization fails silently, the conversation is lost.

This plugin turns this into a sequential process and treats the order as a strict rule: summarize first, then clean up. If summarization is unsuccessful, not a single item shall be deleted.

What is this

dsh-carryover is a session handoff plugin for DeepSeek Harness (dsh).

In one sentence: Before starting a new session, write the previous conversation into notes; only when the notes are actually written to disk is it permitted to delete the old session transcripts.

Attribute Description
Author JackZo400
Category Memory
License MIT
Repository github.com/JackZo400/dsh-carryover

Installation

Install using the following command:

dsh plugin --profile web add github:JackZo400/dsh-carryover

After installation, three things need to be confirmed:
1. sessionsRoot points to the correct transcript directory (default ~/.dsh/sessions).
2. summary.apiKey has a value (recommend using the environment variable DSH_CARRYOVER_API_KEY).
3. Maintain the mapping file (session-map.json), as the plugin relies on it to know which sessions should be carried over.

Configuration

Enable and set parameters in the plugin configuration:

- insert:
    - id: carryover
      name: dsh-carryover
      config:
        enabled: true

        sessionsRoot: ~/.dsh/sessions
        transcript: auto           # Automatically pick the transcript file with the largest version number
        workspace: .                # Note storage directory (default memory/carryover)
        inject: true                # Automatically include notes in the new session
        injectOrder: 40             # Injection order
        maxInjectChars: 4000

        summary:
          baseUrl: https://api.deepseek.com
          apiKey: ''
          model: deepseek-chat
          maxTokens: 900

Mapping File (session-map.json):
This is the core contract for the plugin’s operation, with a default path of <workspace>/tmp/session-map.json. It defines the correspondence between channels and session IDs:

{
  "group:demo": { "sessionId": "3f2a...c1", "carried": "1a9b...7e" },
  "c2c:alice":  { "sessionId": "88d0...4b" }
}
  • sessionId: The current session ID for the channel.
  • carried: The session ID that has already been carried over.
  • Keys can be customized but must be used to name the note files.

How it Works

Handoff Process (Before starting a new session)

  1. Look up the previous session ID for the current channel from the mapping file.
  2. Open the transcript directory, decompress session.v*.jsonl.zstd, remove system injections, and keep only the body content.
  3. Feed the body content to the summarization model to generate a note.
  4. Append the note to the note file and read it back to verify (check if both the session ID and summary content are present).
  5. Verification passed → delete old transcript directory; verification failed → keep old transcript and log KEEP.

Resume Process (New session starts)

When the new session assembles the system prompt, the plugin reverse-looks-up which channel the current session belongs to and attaches the corresponding note into the context. The full text is kept on disk; only the most recent segment is injected.

Usage

1. Host Plugin Call

Call this before starting a new session:

const carryover = ctx.get('carryover')
const r = await carryover.carryOver({ key: 'group:demo' })

if (r.status === 'kept') {
  log('Handover failed, old transcript kept:', r.reason)
}

status states include:
- none: No content to carry over.
- done: Handover successful, old transcript deleted.
- kept: Handover failed, old transcript not deleted.

2. Agent Tool Call

The Agent can directly call three tools:
- carryover_status: View handover status and note location.
- carryover_note: Read note content.
- carryover_run: Execute handover. mode=peek only predicts the result, mode=dry performs the actual summarization but does not write or delete.

3. Reading Notes

Other plugins or scripts can read notes:

const note = ctx.get('carryover').readNote('group:demo')

4. Standalone Usage

The plugin does not depend on the dsh environment and can be called independently in a Node.js project:

import { createCarryover } from 'dsh-carryover/carryover'

const engine = createCarryover({
  workspace: '/srv/app',
  sessionsRoot: '/srv/app/.dsh-sessions',
  summarize: async (dialogue) => myOwnSummarizer(dialogue),
})

await engine.carryOver({ key: 'group:demo' })

Notes & Limitations

  • Depends on zstd command line: Transcript decompression depends on zstd, as node:zlib can only decompress the first frame.
  • Does not find sessions itself: The plugin does not automatically guess which session is the previous one; it relies on the mapping file for maintenance.
  • Not encrypted: Notes are stored as plain text markdown in the workspace; sensitive content requires your own attention.
  • Transcript versions: Transcript filenames include version numbers (e.g., session.v4.jsonl.zstd); the latest version is automatically selected by default, but it will not delete files it cannot recognize.
  • Safeguard mechanism: Path checks are strict; paths outside sessionsRoot or containing .. are not allowed to be deleted, only logged.
羽毛球分组比赛记分
小程序二维码

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

Xiaoye