DeepSeek Harness Message Editing and Version Branching Plugin

Introduction

DeepSeek Harness (DSH) sessions append events chronologically; once settled, they are immutable. When you need to adjust a past prompt, correct an assistant response, or retry a specific turn, the only option is to create a new session and re-run from the beginning—wasting compute resources and breaking conversational continuity. dsh-message-edit adds event-sourcing-based “message editing and regeneration” capabilities to DSH, creating new version branches while preserving the original session and performing partial re-execution on top of the existing conversation.

This plugin is an unofficial port (0.2.x API) of the upstream Moeblack/dsh-message-edit, maintained by onup-1, and falls under the “Workflow” plugin category.

Installation & Activation

Installation command (from npm):

dsh plugin --profile web add dsh-message-edit

For local development, use a symbolic link:

dsh plugin --profile web add -w link:/path/to/dsh-message-edit

Restart dsh after installation to activate the plugin.

Core Features

  • Message Editing: Edit settled user text, assistant.reasoning thinking blocks, and assistant.response reply text.
  • Regeneration: Branch from before the turn containing the last settled assistant response and regenerate using the original user input.
  • Retry Any Turn: Select any historical turn in the Timeline and re-execute it.
  • Cascade Strategies:
  • truncate (default): Only re-execute the target input; discard old subsequent events after that point.
  • preserve: Retain subsequent user inputs and re-execute them sequentially in the new branch; all assistant outputs and tool chains are regenerated.
  • Version Switching: The ← button in the session header undoes the current atomic effect, while → re-applies the latest direct child effect; the Timeline displays the complete known branch tree, operation timestamps, before/after content of edits, and the current version.
  • Timeline Tab: Registered under conversation.view with order: 15, positioned between Trajectory (10) and Prompt Studio (20).

Data Model

Each plugin version contains a message-edit/version event in its non-inherited suffix:

interface MessageEditVersionEvent {
  schemaVersion: 2
  effect: {
    id: string
    operation: 'edit' | 'reroll' | 'retry'
    cascade: 'truncate' | 'preserve'
    targetTurn: number
    targetEventSeq: number
    targetBlockIndex?: number
    blockKind?: 'user' | 'assistant.reasoning' | 'assistant.response'
    before?: string
    after?: string
  }
  inverse: {
    kind: 'restore-version'
    sessionId: string
  }
}

The parentSession in the session header forms a version tree and must be consistent with the inverse.sessionId in the event; Session.inheritedEventCount (0.2.x; previously seedLength in the session header) distinguishes the current version’s own metadata from same-named events inherited from ancestors.

Design Principles

Temporal Composability

The plugin treats complete turns as effect atoms. The turn/start, model requests, tool calls, tool results, and turn/end of the target turn are never partially copied and stitched together; the new version branches from the closed boundary before that turn:

  1. User message editing, Reroll, and Retry: roll back the entire target turn, then pass the target user input to the Agent as a new turn.
  2. Assistant block editing: roll back the entire target turn, construct a new fully-closed turn using the original user input and the edited assistant content; the original tool chain does not carry over into the new version. When preserve is selected, subsequent user inputs are passed to the Agent sequentially, producing new complete tool chains.
  3. Every version appends an indivisible message-edit/version effect pair: effect records the forward effect, inverse records the restoration target. The parent version chain automatically exports composed inverses; restoration is not event deletion but switching along the inverse chain to a still-existing version.
  4. Message history transformations do not commute with each other, so undo follows LIFO: only the current atomic effect is undone at a time while preserving earlier effects; all successor branches remain intact and can be re-applied from the parent version.

Branching & Agent Wiring

The legacy implementation used a short-lived Session to stage the branch, persisted it, removed the live Session, and then reconstructed the Agent via agents.resume(). The current implementation uses only the public seed + meta transaction seam from AgentRegistry.create():

  1. Within the source Agent’s runMaintenance(), obtain an immutable seed from the closed boundary; use an empty seed before the first turn.
  2. Use a local equivalent pure-event constructor to add the version effect pair and optional manual assistant turn to the seed, then call ctx.agents.create({ seed, meta }). The Session validates the complete seed in one pass before Agent construction; any step failure triggers the structural inverse from the AgentFactory, ensuring external observers never see a half-formed Session, and the Agent’s turn count initializes directly from the complete history.
  3. After publishing, call ctx.sessions.flush() to establish a durability barrier before the HTTP operation succeeds.
  4. Workspace attachment and child Agent lifecycle each return atomic inverses; on operation failure, they are composed and applied in reverse order for recovery. Subsequently, user inputs requiring re-execution are queued via child.agent.followup().

This path does not touch ReactLoopAgent, AgentLoop private methods, or the narrowed fork RPC of apiproxy; the branch seed is still validated by the same Session public event contract.

Spatial Composability

  • The Host depends only on the public sessions, agents, sessionPersistence, sessionQuery, workspaceRegistry, and webServer services.
  • The Browser composes only through slots, conversation, connection, and the runtime sessions service.
  • The Timeline and session header share a single value-level Snapshot source keyed by sessionId; the controller reactively subscribes to the closed turn values of the current Session and the lineage values in the Session list, re-binding on Session identity replacement without caching stale Session objects.
  • New version navigation waits for the runtime Session list to publish the corresponding ID before executing ctx.uiWorkspace.openSession() (falling back to sessions.retain(id, { source: 'mainView' })), with availability changes directly driving navigation.

UI Components

  • conversation.view
  • id: message-edit-timeline
  • order: 15
  • label: Timeline
  • conversation.session.header.actions
  • id: message-edit-controls
  • Undo direct parent effect, re-apply direct child effect, effect chain count, regenerate last reply

Components use CSS Modules and --dsw-* semantic tokens; no UI library is introduced. All product copy is in Chinese; code comments are in English.

Build & Versioning

Build commands:

npm install
npm run build

Build outputs:
- index.mjs: Host plugin
- client.js: Browser plugin
- client.js.map: Browser source map

Changes in 0.3.0 relative to upstream 0.2.3:
- API adjustments: Session.events, SessionPersistence.inspect() / readFrom → ctx.sessionQuery.readSession(id) returning { events, inheritedEventCount }.
- header.seedLength → Session.inheritedEventCount / snapshot’s inheritedEventCount.
- Append session/end-seed { inherited: true } marker at the end of the seed.
- Plugin custom event changed to message-edit/version with ignorable: true.
- Synthetic assistant/message only writes {turn, step, message} → now includes stream: [], and must not carry sourceEventSeqs.
- ctx.sessions.open(id) (not available in 0.2.x) → ctx.get('uiWorkspace').openSession(id), with fallback sessions.retain(id, { source: 'mainView' }).
- inject referenced a non-existent conversation service → changed to ["slots", "sessions"].
- require('@deepseek-ai/dsh-client-runtime/client') → includes a minimal createSnapshotStore inline, only requiring react / react/jsx-runtime.
- Branch sessions each occupied a row in the sidebar → version branches are now auto-archived (PARK_VERSION_BRANCHES, enabled by default).
- Fixed a silent bug that also exists in upstream rc.6: user input is first queued as agent/inbox/spliced, and when the boundary is taken as turn.startSeq - 1, this queued event remains in the inherited prefix, causing the “edited the prompt but still executed the original task” issue. The port finds that queued event and moves the boundary before it.

HTTP API

  • GET /message-edit?sessionId=<id>: Read editable messages, retryable turns, and the complete version tree.
  • POST /message-edit: Execute edit, reroll, or retry, returning the published new Session ID.

Scope Boundaries

  • Does not modify Session events in place; history is append-only and deep-frozen.
  • Does not restore or modify workspace files, external command effects, or existing artifacts.
  • Does not modify the DSH engine, apiproxy, or official UI packages.

Use Cases & Notes

  • Suitable for developers and scenarios requiring partial adjustments, re-runs, and version rollback within conversation history.
  • The plugin runs with the current dsh process permissions; it is recommended to review the source code and license before installation.
  • The current 0.3.0 version has been verified on DSH 0.2.2-rc.5: editing user text, editing assistant text, regeneration, retrying any turn, version tree, and ←/→ switching have all been confirmed.

Summary

dsh-message-edit provides DeepSeek Harness with branch-based message editing, regeneration, and version switching capabilities, maintaining historical traceability through event sourcing while preserving the original session structure. It is well-suited for scenarios requiring flexible adjustments and retries within conversations, and serves as a powerful addition to the workflow plugin ecosystem.

  • Plugin directory page: https://www.skillhub.cn/plugins/onup-1/dsh-message-edit-0.3.0
  • GitHub: https://github.com/onup-1/dsh-message-edit-0.3.0
羽毛球分组比赛记分
小程序二维码

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

Xiaoye