跪拜 Guibai
← All articles
AI Coding · AIGC

DeepSeek's New Agent Harness Makes the Core Loop a Plugin

By 王若风 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Agent frameworks that hard-code the model loop, tool pipeline, and session storage force teams to fork source code when requirements change. dsh's reversible plugin spine makes those layers swappable at runtime, which matters for anyone building internal agent platforms that need to survive rapid shifts in model providers, sandbox backends, and tooling strategies.

Summary

DeepSeek's `deepseek-harness` (`dsh`) is an agent runtime where the model adapter, tool registry, session log, and even the core agent loop are all plugins. The architecture rests on Cordis, a plugin framework originally built for the Koishi chatbot, which enforces that every registration is a reversible effect—cleanly rolling back listeners, timers, and tool registrations when a plugin is unloaded. This eliminates orphaned state during hot-swaps and runtime reconfiguration, a persistent pain point in hard-coded agent frameworks.

The session model treats the event log as the single source of truth, projecting message history from an append-only log rather than storing it separately. Capability seams abstract the execution environment so that swapping a sandbox provider moves every dependent tool—Bash, PTY, LSP—to the new backend in one shot. Configuration is handled through composable profiles and bundles managed via pnpm, making plugin management identical to package management for frontend developers.

The project is still an early developer preview (v0.1.0-rc.5) with a steep TypeScript and pnpm prerequisite, almost no third-party plugins yet, and documentation that assumes deep prior knowledge. The bet is architectural: a system's long-term evolvability depends on how thin its irreplaceable core is, and dsh pushes that thickness down to a single interface contract.

Takeaways
Every component in dsh—model adapter, tool registry, session log, and the agent loop—is a plugin that can be swapped without patching a privileged core.
The plugin spine comes from Cordis, the kernel of the Koishi chatbot framework, which was vendored and hardened by DeepSeek to fix reentrant disposal bugs during plugin unload.
Reversible effects guarantee that every registration (timers, listeners, tools) is paired with a disposer, so unloading a plugin cleanly rolls back all its side effects in reverse order.
Four event dispatch modes—emit, waterfall, parallel, serial—let plugins observe, wrap, fan-out, or sequentially execute; waterfall acts as around-middleware for intercepting model input and tool execution.
Sessions are append-only event logs; message history is projected from the log, and a runtime assertion enforces that anything visible to the model must be reconstructable from the log.
Capability seams abstract the execution environment so that swapping a sandbox provider relocates all dependent tools (Bash, PTY, LSP) together, without per-tool forking.
Configuration uses profiles and bundles composed from a `cordis.yml` file; plugin management is a thin wrapper around pnpm, treating plugin installation as package installation.
The project is version 0.1.0-rc.5, explicitly warns of compatibility-breaking changes, has zero open issues (not due to stability but lack of third-party testing), and almost no third-party plugins yet.
Entry barriers are high: it requires TypeScript, pnpm 11.7.0, and Node ≥22.19.0, with documentation that assumes prior knowledge of agent harnesses and Cordis.
Conclusions

Making the agent loop itself a plugin—not just the tools or model adapter—is a genuinely rare design choice. Most frameworks treat the loop as the one sacred, hard-coded layer; dsh treats it as 'an implementation' of a public interface, which means the entire conversation-driving mechanism is replaceable.

Vendoring Cordis and patching its fiber lifecycle to close reentrant disposal gaps signals that DeepSeek is treating the plugin spine as a serious engineering investment, not a thin wrapper. The specific fixes—registering owner-lists before setup, keeping async cleanups visible until quiescence—address the hardest edge cases in reversible effect systems.

The session model's 'model-visible means logged' invariant, enforced by runtime assertions, is a stronger guarantee than most event-sourcing systems provide. It means the log is not just a record but a contract: anything the model saw can be replayed, forked, or compacted without data loss or format drift.

Capability seams that co-locate dependent tools under a single provider abstraction solve a real composition problem. Moving a sandbox shouldn't require remembering to also move the shell, the LSP, and the file system separately; dsh's design makes that a single provider swap.

The project's 30,000 stars in one day are almost entirely brand-driven and say nothing about production readiness. The real signal is the architecture, not the hype, and the architecture is betting that agent frameworks need to be thin-spined to survive rapid evolution.

The 'plugin management = package management' approach via pnpm is clever for frontend-heavy teams but locks out developers who don't live in the Node ecosystem. This is a tradeoff, not a universal win.

The documentation's assumption of deep prior knowledge—no screenshots, no use cases, no gentle onboarding—will throttle ecosystem growth unless addressed. A plugin architecture without plugins is just a well-engineered skeleton.

Concepts & terms
Reversible effects
A plugin discipline where every side effect (registering a timer, listener, or tool) is wrapped with a cleanup function. When the plugin is unloaded, the framework calls all cleanup functions in reverse order, preventing orphaned state and memory leaks.
Capability seam
An abstraction boundary defined by a service interface, its provider implementation, and its consumer. Swapping the provider changes the behavior of all dependent tools at once—for example, pointing a sandbox seam to a remote backend moves Bash, PTY, and LSP together.
Waterfall event dispatch
An event pattern where listeners form a middleware chain: each listener receives the arguments and a `next()` function, can modify the payload, and either passes control to the next listener or short-circuits the chain by returning without calling `next()`.
Event sourcing (applied to agent sessions)
Storing a session as an append-only event log rather than as a mutable message list. The message history visible to the model is a projection derived from the log, enabling replay, forking, and compaction from a single source of truth.
Agent harness
A runtime base for coding agents that provides the execution environment, tool integration, session management, and model interaction loop, typically exposing a local web interface for conversation and file operations.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗