Dsh-Go icon
In-process Go reference implementation of the DeepSeek Harness Agent

Understand the Agent kernel.
Build with Dsh-Go.

A pure-Go, in-process reference implementation of the DeepSeek Harness Agent. Event sourcing, fold projection, Goal planning and tool governance — translated line by line into idiomatic Go, so you can read, debug and rebuild a real Agent.

UserSession · Event Sourcingappend-only log · replayablePersistenceJSONL · SQLiteFold / Projectionstate = f(events) · O(N)Prompt AssemblyAgent LoopTurn / Step 双循环Goal · 取消 · 重试Tool Waterfallpre → execute → post → resultLLM · DeepSeekstreaming · retry · cache

What Dsh-Go gives you

Three pillars make up the Agent kernel. Each is a Capability Seam: a service definition plus a swappable provider, so replacing one provider changes behavior without touching the rest.

The Agent kernel, decoded

Dsh-Go answers one question: how does a real Agent work inside? Instead of a black box, it gives you the actual machinery — and each piece is small enough to grasp in an afternoon.

Core conceptWhat it meansLearn it
Event SourcingNo mutable state; append immutable events, derive state from themTutorial
Fold ProjectionState = a pure function of the event log, incremental O(N)Tutorial
Goal State Machineactive / paused / blocked / complete planning with stable error codesTutorial
Turn / Step LoopOne turn per user message; steps run tools and feed results backArchitecture
Tool Waterfallpre → execute → post → result pipeline with pluggable middlewareCapabilities

9 zero-dependency examples

Start from examples/ and run go run ./examples/tutorial — no LLM key needed until the very last one.

ExampleWhat it demonstrates
tutorialEvent sourcing → fold projection → Goal machine (the teaching entry)
agent_loopTurn/Step double loop + tool continuation
usageSession, projection, Goal tool, commands, persistence
todoSwapping a capability end-to-end
workflowPipeline / parallel / cancellation cascade
subagentMulti-provider derivation + parent-release cascade
sandbox_approvalApproval states + sandbox mode
mcpMCP client → tool bridge
chatReal DeepSeek multi-turn chat (requires an API key)