Introduction¶
The DeepSeek Harness (DSH) runtime does not have built-in session management capabilities. In multi-threaded and multi-agent collaboration scenarios, developers must manually maintain thread state and interactions. Existing approaches either implement a custom thread scheduling logic at the business layer or borrow the thread collaboration tools from the Codex desktop app. The latter, while mature, requires an additional adapter layer for DSH integration. The dsh-thread-tools plugin ports the Codex desktop thread collaboration toolkit 1:1 to DSH. Each DSH session maps to one thread, and a unified API handles thread creation, reading, waiting, messaging, archiving, and deletion.
Plugin Overview¶
dsh-thread-tools is a workflow-type plugin maintained by Heroicus. It does not depend on external account systems or network services, and relies solely on DSH’s internal APIs (sessionController.prompt, sessionController.wait, sessionQuery.readSurface, etc.) to perform thread management. It is well-suited for agent development and workflow orchestration scenarios that require direct multi-session management within DSH.
Core Features¶
The plugin provides 10 tools with identical names and parameters to their Codex desktop counterparts, maintaining consistent API semantics:
list_threads: List threads. Supports two modes:mode: recent: Returns a list of pinned threads sorted by recencymode: history: Returns a page of threads, supportingcursorandlimitpagination parameterslist_archived_threads: Lists a page of archived threads, also with pagination supportread_thread: Reads the turn summary of a thread. Supported parameters:turnLimit: Limits the number of turns returnedincludeOutputs: Whether to include output contentmaxOutputCharsPerItem: Maximum characters per output itemcursor: For paginationwait_threads: Waits for multiple threads to complete or require input. Waits for up to 8 threads; returns as soon as any one completes or needs input. Supports atimeoutMsparameter with a maximum of 120000 ms; setting it to 0 means an immediate snapshot (no waiting)send_message_to_thread: Sends a message to a specified thread. The message is wrapped in a<codex_delegation><source_thread_id>…</source_thread_id><input>…</input></codex_delegation>envelopecreate_thread: Creates a new thread. Optionally includes an initialprompt, dispatched asynchronouslyfork_thread: Duplicates a thread (including history) into a new independent threadset_thread_title: Renames a threadset_thread_archived: Archives or unarchives a thread. Archived threads reject incoming messagesdelete_thread: Permanently deletes a thread and its persisted logs
The hostId and source parameters are signature-compatibility parameters; in the current installation context, there is only one host.
Implementation Details¶
- Messaging goes through the same path as the host’s human client via
sessionController.prompt. Cold sessions are automatically restored, busy sessions are queued, and log and title semantics match those of manual user input wait_threadsusessessionController.waitand continues waiting in the case where a message is still being enqueued but the session has already gone idle, preventing premature responsesread_threadusessessionQuery.readSurfaceto fold the event stream, filtering out<system-reminder>and time-injection blocks, retaining only user prompts and model replies- Read-only operations do not call
sessionController.state(), avoiding accidental waking of cold sessions - Archive/pin state is stored in
$DSH_PROFILE_DIR/session-bus/state.json(atomic writes) - DSH does not expose a public “remove loaded session” API.
delete_threadfirst cancels any running turn, then deletes the on-disk logs; in-memory copies will disappear on the next restart. The return value includesclearedFromMemory: falseto indicate this
Installation & Activation¶
Local directory installation:
- Clone or extract this repository to a local directory
- Open the “Plugins” menu in DSH
- Select “Add Plugin” and point to the local directory
- Or use
plugin_manager’sinstall_bundlein a session, pointing to this directory
The plugin has no dependencies and no build step. index.js is the entire implementation.
Typical Usage¶
Create a thread and send the initial prompt:
// Create a thread
const thread = await create_thread({
prompt: "Help me analyze the code changes from the past week"
});
// Wait for the thread to complete
await wait_threads({
threadIds: [thread.id],
timeoutMs: 60000
});
// Read the thread summary
const summary = await read_thread({
threadId: thread.id,
turnLimit: 10
});
Send a message across threads:
await send_message_to_thread({
threadId: "target-thread-id",
input: "Please continue the derivation based on the previous turn's conclusion"
});
Archive and delete:
await set_thread_archived({
threadId: "thread-id",
archived: true
});
await delete_thread({
threadId: "thread-id"
});
Use Cases & Caveats¶
- Ideal for developers and workflow orchestration scenarios that require direct multi-session and multi-agent collaboration within DSH
- The plugin runs with the current DSH process permissions. Review the source code and license before installing
- Compared to the Codex desktop, it lacks tools that depend on account systems or host networking (e.g.,
handoff_thread,share_thread,list_projects,get_usage_limits), and does not provide state setters likeset_thread_pinnedorset_thread_read_state(the DSH sidebar does not consume these states)
Conclusion¶
dsh-thread-tools provides DSH with a thread collaboration toolkit aligned with the Codex desktop, implementing thread creation, reading, waiting, messaging, archiving, and deletion through a unified interface. If you are doing multi-agent development or workflow orchestration in DSH, this plugin can reduce the boilerplate code for manual session management while improving the reliability and consistency of interactions.