Introduction¶
In DeepSeek Harness (DSH), each session is isolated at the conversation layer: each possesses its own event log, agent, and context window. However, multiple sessions often share the same working directory. When two sessions are opened in parallel within the same workspace to perform different tasks, the agent writes files based on the assumption that “this directory is my project”—modifying the same index or writing to the same path. The result is that the latter write completely overwrites the former. This is not a failure of session isolation, but rather multiple writers sharing the same set of files.
The following introduces the community plugin dsh-session-isolation (Maintainer: TOP1Wu, Category: Workflow). It defines write boundaries for each session within the same workspace: each session outputs to an independent directory, and the tool layer rejects attempts to overwrite files still occupied by other active sessions.
What is this¶
In one sentence: It defines a write boundary for each session within the same workspace.
- Repository: TOP1Wu/dsh-session-isolation
- Community Directory: skillhub.cn Plugin Page
- License: MIT (README)
- Version: 0.1.0 in package.json
In the DSH ecosystem, plugins extend capabilities through official seams; the community directory is an independent site with no official affiliation with DeepSeek or High-Flyer. It is recommended to review the source code and license before installation—plugins run with the permissions of the current dsh process.
Problems Solved and Post-Installation Behavior¶
Typical Conflicts¶
Scenarios described in the README include: Session A creates directory-level documents for indexing, while Session B writes B’s project content into the same index within the same workspace; when running in parallel, both write to the same path, with the latter overwriting the former.
After Installation¶
- Each session (and its derived sub-agents) is automatically mapped to an output directory:
<workspace>/.sessions/<session short id>/ - The session receives an instruction at the first step: workspace path, this session’s output directory, and write boundaries (write new files to your own directory, do not touch others’ files, do not touch directory-level indexes by default, etc.).
- When a session attempts to overwrite a file occupied by another active session in the same workspace, file tools such as
write/editare rejected before execution, prompting the user to rewrite to their own output directory. - Ownership is automatically released after the owning session ends or the application restarts; files are not permanently locked.
Explicitly Not Done¶
- Does not change session cwd. It is a “convention + rejection” style isolation, not a process chroot to a subdirectory.
- Does not intercept file writing methods in bash such as
>,tee,python -c "open(...,'w')". - For physical-level isolation, one should still use “one topic per workspace” or git worktrees.
Core Mechanism¶
The plugin relies only on DSH extension seams, has no third-party dependencies, and uses only Node built-in node: modules.
Mechanism 1: Output Directory Convention (agent/pre-step)¶
Each session injects a one-time instruction at the first step, including the workspace directory, the absolute path of this session’s output directory, and four write boundaries. Sub-agents and parent sessions are considered the same ownership based on lineage and can modify each other’s outputs; sessions manually forked by the user are independent top-level ownerships.
Mechanism 2: Cross-Session Write Guard (ctx.tools.guard)¶
Before write, edit, str_replace_editor, or apply_patch are executed, the target path is checked: if the file is already occupied by another active top-level session in the same workspace, the operation is rejected. Ownership is accounted for in tools/result based on whether the “file was actually written to disk”; failed or rejected calls do not generate ownership.
Installation and Enablement¶
Command Line Profile¶
The plugin has zero third-party dependencies, requiring no build or network connection. Installation command (from README):
dsh plugin --profile web add /absolute/path/dsh-session-isolation
Restart DSH after installation (CLI installation does not hot-reload).
DSH Desktop¶
The true DSH_HOME for the desktop version is:
~/Library/Application Support/dsh-desktop/harness
It is not ~/.dsh. Running dsh plugin directly in the terminal will install to ~/.dsh, which is not effective for the desktop version. You can use the desktop’s built-in plugin marketplace or explicitly specify the home:
DSH_HOME="$HOME/Library/Application Support/dsh-desktop/harness" \
dsh plugin --profile web add /absolute/path/dsh-session-isolation
Verify Loading¶
dsh --profile web --dump-config | grep -A2 session-isolation
You should see something similar to:
# == dsh-session-isolation
- id: session-isolation
name: dsh-session-isolation
Verify Effectiveness¶
After restarting, open a session in the workspace and let the agent write a file, then:
ls "<workspace>/.sessions"
A directory named after the session’s short id should appear (the short id is the first segment of $DSH_SESSION_ID after removing the session- prefix).
Configuration¶
All configuration is via environment variables:
| Variable | Default | Function |
|---|---|---|
DSH_SESSION_ISOLATION |
guard |
guard = convention + guard; advise = only inject convention, do not reject; off = completely off |
DSH_SESSION_ISOLATION_DIR |
.sessions |
Output directory name |
DSH_SESSION_ISOLATION_MKDIR |
1 |
Set to 0 to not actively create the output directory, only inform the path |
Setting to advise or off allows softening or disabling the behavior without uninstalling.
Use Cases and Notes¶
Suitable for: Opening multiple parallel sessions in the same workspace to advance different subtasks, where you temporarily do not want to split into multiple clones or worktrees, using convention + tool guard to reduce the risk of mutual overwriting.
Boundaries you must be aware of:
- Only intercepts file-type tools, does not intercept file writing via bash; reliably parsing shell is difficult, this path relies solely on the convention of Mechanism 1.
- Ownership records are in-process memory, cleared after DSH restart; existing files become “ownerless,” and whoever writes first acquires ownership.
- Does not perform physical isolation; if strongly relying on shell or external scripts for heavy disk writing, isolation is incomplete.
- Mutual exclusion only between top-level sessions; sub-agents are merged into the parent session’s ownership.
Offline tests provided by the maintainer:
node test/logic.test.mjs
The README states there are 21 tests in total, covering contention interception, lineage ownership, no impact on cross-workspace scenarios, and release after session offline.
Uninstallation¶
dsh plugin --profile web remove dsh-session-isolation
Conclusion¶
Under the DSH “everything is a plugin” philosophy, dsh-session-isolation uses pre-step conventions and tools guard to solve the overwriting and mixing issues caused by “multiple sessions sharing a working directory.” It cannot replace the hard isolation of “one topic per workspace,” but within the workflow category, it is a directly deployable compromise for multi-session parallelism in the same directory.
- Directory Page: https://www.skillhub.cn/plugins/TOP1Wu/dsh-session-isolation
- GitHub: https://github.com/TOP1Wu/dsh-session-isolation