Introduction¶
In a DSH environment, when the DeepSeek gateway emits an empty id or name in tool-call increments, persisted history records can become “polluted,” causing subsequent session loading to throw a message must have tool source error. dsh-session-repair is a DSH Web plugin that provides session diagnostics, trusted checkpoints, pre-repair backups, and safe repair capabilities, with the goal of repairing these polluted history records.
Plugin Positioning¶
dsh-session-repair is a DSH Web plugin for session diagnostics, trusted checkpoints, pre-repair backups, and safe repair.
* Maintainer: Zn-Dk
* Category: session
* License: MIT
Core Features¶
The plugin provides the following capabilities:
* Session Diagnostics: Generates diagnostic reports through Session Health Check.
* Safe Repair: Provides deterministic repair plans and automatically creates backups before repair.
* Backup Management: Supports pre-repair backups, rolling back to the pre-repair state, and manually clearing backups.
* Agent Tool Integration: Registers the dsh_session_repair model-callable tool for read-only diagnostics.
* Report Export: Supports diagnostic JSON export and report file download.
Installation and Enablement¶
Install the plugin via npm (recommended):
dsh plugin --profile web add dsh-session-repair
After installation, restart the dsh web service and refresh the Web interface.
Usage¶
1. Web Interface Operations¶
Open any session and click Session Health Check in the Chat header.
* If the diagnostic report status is repairable and a deterministic repair plan exists, the panel displays a Backup & Repair button.
* Clicking this button confirms the target sequence and pre-repair backup, then executes batch repair and revalidation.
* If the session is in an ambiguous, active, file-changed, or blocked state, writable repair buttons will not be displayed.
* The panel also provides Refresh (refresh report), Copy Report (copy JSON), Export Report (export file), Restore Pre-Repair (rollback), and Clear Backups (clear backups).
2. Agent Tool Invocation¶
The plugin registers a model-callable tool dsh_session_repair.
* Purpose: This is a read-only diagnostic tool used to diagnose session health status.
* Typical Usage: In the current session, tell the Agent “health-check the current session,” and the Agent will call this tool. For historical sessions, you can specify a sessionId for diagnostics.
* Note: This tool is for diagnostics only; actual repair operations still need to be performed through the Session Health Check panel in the Web interface.
Security Boundaries and Notes¶
- Permission Control: The plugin runs with the current dsh process permissions. The Host reads raw storage first before deciding whether to call engine APIs. Clients cannot directly access the
~/.dshdirectory, nor can they submit arbitrary JSON patches. - Repair Mechanism: Repair operations use batchId and artifact fingerprints. A pre-repair backup is mandatorily created before each repair, and old data is atomically replaced only after revalidation.
- Session State: Active sessions are detected via
ctx.get('sessions')/ctx.get('agents'). Their unclosed turns/steps are treated as a normal append state and do not trigger repair. - Data Storage: Plugin-specific data is stored in the
~/.dsh/session-repair/directory. External~/.dsh/backup-sessions-*directories are only used as legacy forensic/comparison sources and are not automatically restored by default.
Summary¶
dsh-session-repair provides a solution for safely repairing corrupted DSH session history in the Web interface, especially pollution issues caused by missing tool-call IDs. It reduces the risk of manual intervention by enforcing backups and using deterministic repair plans.
- Plugin Directory: https://www.skillhub.cn/plugins/Zn-Dk/dsh-session-repair
- GitHub: https://github.com/Zn-Dk/dsh-session-repair