In DeepSeek Harness (DSH), when running background bash tasks or background subagents with run_in_background: true, tasks are registered in ctx.jobs. After returning a job id, control is managed via the job cancellation mechanism rather than tool call signals. This means that when a user clicks the stop button, the foreground reply is interrupted, but background tasks often continue to run. Upon task completion, the completion notification wakes up the model, leading to extra requests for conversations that have already been cancelled. The dsh-stop-kills-jobs plugin listens for the UI’s turn/end event, identifies user-initiated stop actions, and cancels background tasks associated with the current session to prevent this.
Overview¶
This is a client-side plugin maintained by Ezisup and released under the MIT license. Its core function is to terminate background tasks initiated in the current turn when a user actively interrupts a conversation.
Installation¶
Add the plugin via the command line:
dsh plugin --profile web add link:/xxx/dsh-stop-kills-jobs
A DSH restart is required after installation to take effect (the client side needs to be reloaded).
Configuration and Usage¶
- Go to Settings → Plugins → Plugin Configuration and find the “Terminate background tasks on stop” card.
- By default, the card is collapsed; click the title to expand it.
- The card is divided into two parts: “Terminate on stop” and “Plugin Output”.
- Terminate on stop: Controls whether to terminate background bash tasks and background subagents, governed by the master switch.
- Plugin Output: Displays prompts and detailed logs. This is independent of the stop button and is active at all times.
- Master Switch: Enabled by default. When turned off, the entire “Terminate on stop” section is hidden (the plugin does nothing), but saved settings are preserved and can be restored by turning it back on.
Toggle Descriptions¶
| Toggle | Default | Description |
|---|---|---|
| Enabled | On | Master switch; turning it off restores DSH’s original behavior |
| Background Commands (bash) | On | Whether to terminate run_in_background bash tasks |
| Background Subagents | On | Whether to terminate background subagents |
| Show prompt in conversation | On | Display recently terminated tasks in the settings page |
| Output detailed logs | Off | Write the decision process to the server logs |
Core Features¶
- Listen and Identify: Listens for the UI’s
turn/endevent and precisely matchesreason?.kind === 'aborted' && reason?.reason?.kind === 'user', responding only to actions where the user actively clicks stop. - Cancel Tasks: Uses authorized credentials (
ctx.agents.get(session.id)) to cancel background tasks registered by the current session and its subagents. - Prevent Wake-up: By cancelling tasks in a timely manner, it prevents task completion notifications from waking up the model, avoiding extra requests for cancelled conversations.
- Verbose Mode: Supports enabling detailed logging to help troubleshoot issues where tasks do not terminate properly.
Notes¶
- Scope: Only affects tasks initiated by the current session; it does not affect other sessions.
- Dependencies: The plugin runs with the privileges of the current dsh process. Please review the source code and license before use.
- Session Isolation: Subagent tasks register with
owner: parent. The plugin’sownerSessionfilter condition covers both parent session and subagent tasks. - Uninstallation: To remove it, use
dsh plugin --profile web remove dsh-stop-kills-jobsand restart DSH.