DeepSeek Harness Code Mode: Orchestrating Multi-Step Tasks in TypeScript
Code Mode is DeepSeek Harness's advanced runtime: all Standard tools plus an SDK that lets the model combine multi-step operations into one TypeScript program.
What Code Mode Is
Code Mode is one of DeepSeek Harness's four runtime modes. It includes all of Standard mode's capabilities — file editing, shell, file and web search, skills, planning, goals, subagents, workflows — and adds the Code Mode SDK, which lets the model combine multi-step operations in a single TypeScript program[1].
The idea: instead of issuing one tool call at a time and waiting for each result, the model writes a small TypeScript program that calls several tools in sequence, with control flow, retries, and conditionals — then the harness executes that program[1].
The four modes are plugin compositions, not special code paths — see the Cordis architecture guide.
Standard Mode vs Code Mode
The practical difference is how the model interacts with tools[1]:
Standard mode remains the default because it is better for interactive, unpredictable work. Code Mode is for tasks where the sequence is known and batching saves time and tokens[1].
| Dimension | Standard mode | Code mode |
|---|---|---|
| Interaction | One tool call at a time (model proposes, harness executes) | Model writes a TypeScript program combining calls |
| Multi-step work | Several round trips | One program, batched and sequenced |
| Control flow | Limited to the agent loop | Full TS: loops, conditionals, retries, error handling |
| Best for | Interactive, exploratory coding | Deterministic multi-step automation |
How the SDK Works
The Code Mode SDK exposes the harness's tools as functions inside a TypeScript program that the model generates[1].
The model writes the program, the harness executes it with full tool access, and the session log records every step — so Code Mode runs remain fully traceable in the Trajectory view[1][2].
// conceptual example of a Code Mode program
import { bash, edit, search } from "@deepseek-ai/dsh-code-sdk";
const files = await search.find("TODO");
for (const f of files) {
const ok = await bash.run(`npm test -- ${f}`);
if (!ok) await edit.apply(f, patchFromTest(ok));
}
return { summary: "patched " + files.length + " files" };When Code Mode Wins
Code Mode shines in scenarios where the operation sequence is stable and repeated[1]:
Community feedback positions it as the harness's answer to 'agentic scripts' — the reliability of a script with the adaptability of an agent underneath[3].
- Batch refactors across many files with the same pattern
- Test-and-fix loops: run tests, parse failures, patch, retry
- Pipeline-style tasks: build → test → package → summarize
- Multi-repo chores where each step is deterministic
Enabling Code Mode
Code Mode is a profile configuration, not a separate install[1][4]:
Because profiles live in $DSH_HOME/profiles/<name>, you can keep a Standard profile for interactive work and a Code profile for automation, switching with a single flag[4].
# launch with the code profile (bundle composition including the SDK)
dsh --profile code
# or compose it yourself: add the Code Mode bundle to a custom profile
dsh plugin --profile my-agent add @deepseek-ai/dsh-code-modeLimitations and Caveats
Code Mode is still young[1][3]:
If you are comparing harnesses, see dsh vs Claude Code for how the mode system differs from fixed toolchains. To understand the whole runtime family, read minimal mode (the benchmark rig) next.
- The SDK surface is small today; expect additions before 1.0
- Compatibility-breaking changes are possible — pin your dsh version
- Traceability helps, but a misbehaving generated program can burn tokens fast — review before running