DeepSeek Harness Python SDK: DSH plugin programmatic use

Configuration & UsagePublished 2026-10-03Author: DeepSeek Plugin Market
DeepSeek HarnessDSH pluginPython SDKsdk-minimalconfiguration
DeepSeek Harness ships a Python SDK: pip install deepseek-harness-sdk; a DeepSeekHarness context manager drives a sdk-minimal profile with JSONL session logs.

DeepSeek Harness ships an official Python SDK: after pip install deepseek-harness-sdk, a DeepSeekHarness context manager drives a sdk-minimal profile from your Python code — configuration is composed from the profile, the home patch, and any patches you pass, and session logs land in $DSH_HOME/sessions as uncompressed JSONL (source).

Installing the DeepSeek Harness Python SDK

The prerequisites are Python 3.10+ and Git; run pip install deepseek-harness-sdk, and the install comes with a matching native runtime wheel and the dsh command, so normal SDK runs do not need system Node.js (source). Steps:

  1. Check platform and version — Linux x64/arm64, macOS 14+ on arm64, or Windows x64, plus a DeepSeek-compatible API endpoint and credentials. Expected: satisfy these first so the native wheel matches.
  2. Create an isolated environment — make and activate a virtualenv (Linux/macOS: python -m venv .venv then . .venv/bin/activate; Windows: py -3.10 -m venv .venv and activate). Expected: python -m pip install deepseek-harness-sdk installs into it.
  3. Prepare an isolated workspace and home — use a disposable workspace and a separate dsh_home. Expected: the SDK uses only the home you pass and never reads ~/.dsh.
  4. Export credentials — set DEEPSEEK_API_KEY; with a compatible proxy also set DEEPSEEK_BASE_URL. Expected: credentials enter the runtime from the environment.

Running a task with DeepSeekHarness

In code, use DeepSeekHarness as a context manager with provider, model, cwd, dsh_home, and profile, call harness.run(prompt, session_id=...), and read result.final_response (source). Minimal usage:

python
from pathlib import Path
from deepseek_harness import DeepSeekHarness

workspace = Path("/absolute/path/to/disposable-workspace").resolve()
dsh_home = Path("/absolute/path/to/example-dsh-home").resolve()
with DeepSeekHarness(
    provider="deepseek-official",
    model="deepseek-v4-flash",
    max_tokens=49_152,
    cwd=str(workspace),
    dsh_home=str(dsh_home),
    profile="sdk-minimal",
) as harness:
    result = harness.run(
        "Inspect the repository and fix the failing tests.",
        session_id="example-001",
    )

print(result.final_response)

Key points:

  1. The process starts lazily — the SDK lazily starts an internal dsh --profile sdk-minimal process and reuses it until the context manager exits. Expected: the process is reclaimed after the with block.
  2. No separate Python runtime — there is no standalone Python runtime bin or a full set of configuration options; everything still goes through profiles and patches. Expected: concepts stay unified in DeepSeek Harness's own configuration system.
  3. New home to isolate, new session id for independent work — reuse the harness, home, and id only to continue the same persistent conversation. Expected: mixing them silently resumes the wrong session.

DSH plugins and the minimal profile: installing, patching, enabling str_replace_editor

Use dsh plugin to persist dependencies and bundle layers in that home; persist config changes in $DSH_HOME/profiles/sdk-minimal/cordis.patch.yml, or pass a patch from Python for one run (source). Three steps:

  1. Initialize the profile — run dsh --profile sdk-minimal --dump-default-config >/dev/null. Expected: the bundled standalone profile is initialized.
  2. Install a plugin bundle — use dsh plugin --profile sdk-minimal add file:/absolute/path/to/my-plugin-bundle, which forwards package management to pnpm and records every installed package that exports a dsh.bundle layer. Expected: pnpm is needed only for this management command, not to start an already-installed SDK. To find existing plugins, browse community ones on DSH Plugin Hub.
  3. Enable str_replace_editor on demand — the bundled runtime includes it, but sdk-minimal does not mount it by default. Write an editor.patch.yml that uses insert to add the filesystem backend and editor back, then pass it via patches or persist it in cordis.patch.yml. Expected: after the next start, the model can use the tool beyond the persistent shell.
yaml
# editor.patch.yml
- insert:
    - id: fs-local
      name: '@deepseek-ai/dsh-fs-local'
      config:
        cwd: !!js process.cwd()
    - id: tool-str-replace-editor
      name: '@deepseek-ai/dsh-tool-str-replace-editor'

Note: another profile is valid only if it includes @deepseek-ai/dsh-sdk-app or another JSON-RPC server entry; a missing server entry, an unresolvable plugin, or an invalid patch fails at startup rather than falling back to another composition.

Understanding the sdk-minimal profile

sdk-minimal inserts a full config tree over an empty root without dsh-base, so tools added to the base profile later never appear implicitly (source). Its defaults:

PropertyValue
System promptDSH_SYSTEM_PROMPT, else You are a helpful software engineer assistant.
Model for minimal.py--model, then DSH_MODEL, then deepseek-v4-flash
Model-facing toolpersistent bash on Linux/macOS, or pwsh on Windows
Shell timeout300 seconds
Runtime context and compactionnone
Session persistenceuncompressed JSONL under <dsh_home>/sessions

The profile contains the SDK protocol, an environment-configured DeepSeek adapter, local execution, and persistence. Filesystem tools, settings, managed credentials, OTel telemetry, web tools, subagents, local instruction discovery, and compaction are all absent. It also pins danger-full-access, so the persistent shell can modify any path visible to the runtime — always use a disposable checkout or container.

Notes and common questions

  1. ~/.dsh is never read: the SDK uses only the dsh_home you pass; that isolation is deliberate.
  2. Permissions are broad: under danger-full-access the shell can write any visible path, so isolate the environment.
  3. Session logs are uncompressed: JSONL under <dsh_home>/sessions; watch disk usage and privacy, as in Where DeepSeek Harness session history lives.
  4. The Web UI is not in the SDK: for a browser app in a Python SDK deployment, run dsh web against an explicit DSH_HOME; web is a standalone CLI app and cannot serve a Python SDK client.
  5. Changing models or adding self-hosted services: adjust providers and credentials, as in Configure DeepSeek Harness model providers.

Sources: Python SDK (official docs), dsh CLI README

FAQ

How do I install the DeepSeek Harness Python SDK, and does it need Node.js?

Installing the DeepSeek Harness Python SDK needs Python 3.10 or newer plus Git, then pip install deepseek-harness-sdk. The install bundles a matching native runtime wheel and the dsh command; normal SDK runs do not need system Node.js.

How do I run one task with the DeepSeek Harness Python SDK?

In DeepSeek Harness code, use DeepSeekHarness as a context manager with provider, model, cwd, dsh_home, and profile, then call harness.run(prompt, session_id=...) and read result.final_response. The SDK lazily starts an internal dsh --profile sdk-minimal process and reuses it until exit.

Does the DeepSeek Harness SDK read existing config in ~/.dsh?

No: the DeepSeek Harness SDK and its bundled examples never silently read ~/.dsh; the dsh_home you pass is the only source, and it stores the generated sdk-minimal profile, installed plugins, and session logs under sessions/.

How do I install plugins or change config for the DeepSeek Harness SDK profile?

Initialize the DeepSeek Harness profile first, then install packages with dsh plugin --profile sdk-minimal add (this step needs pnpm). Persist config edits in $DSH_HOME/profiles/sdk-minimal/cordis.patch.yml, or pass patches from Python for one run.

Why is str_replace_editor missing from the DeepSeek Harness sdk-minimal profile?

The DeepSeek Harness sdk-minimal profile does not mount str_replace_editor in its default Cordis tree. To enable it, write an editor.patch.yml that inserts fs-local and tool-str-replace-editor, then pass it via the patches argument or persist it in cordis.patch.yml.

Related Terms

deepseek-harness-sdk
deepseek-harness-sdk is the official Python package of DeepSeek Harness; installing it also brings a matching native runtime wheel and the dsh command, and the DeepSeekHarness class drives a dsh profile from code.— DeepSeek Harness Documentation - Python SDK
sdk-minimal
sdk-minimal is the standalone minimal profile bundled with the SDK; it inserts a full config tree over an empty root without dsh-base, containing only the SDK protocol, an environment-configured DeepSeek adapter, local execution, and persistence.— DeepSeek Harness Documentation - Python SDK
dsh_home
dsh_home is an isolated DeepSeek Harness home directory holding profiles, installed plugins, credentials, settings, and session logs; the SDK uses only the home you pass and never reads ~/.dsh.— DeepSeek Harness Documentation - Python SDK
patch
A patch is a configuration overlay of DeepSeek Harness that inserts or changes entries in an existing config tree; in the SDK it is composed from the profile's persistent patch, the home patch, and any patches tuple passed at construction.— DeepSeek Harness Documentation - Python SDK

Sources