How geffzhang/deepseek-harness-dotnet works
DeepSeek Harness .NET is a C#/.NET reimplementation of the deepseek-harness agent runtime, aiming for behavioral equivalence. A user enters through a host or SDK; the agent loop prepares and runs session turns, uses model adapters for assistant output, and dispatches tools, while session events and projections preserve state. Cordis supplies the plugin, service, event, fiber, and effect layer beneath these capabilities. The README documents further product areas, including approval, sandbox policy, goals, and terminal control. Some links reflect README descriptions; unsampled implementations are not assumed to have been inspected.
Main entry points: AgentLoop.cs Agent loop · LlmRuntime.cs LLM runtime · Session.cs Session log · Context.cs Service context
Components 27
Hosts and SDK
- CLI host
src/Dsh.Cli/Program.cs - Desktop host
src/Dsh.Desktop/Program.cs - SDK handler
src/Dsh.Sdk/SdkInitializeHandler.cs
Agent runtime
- Agent loop
src/Dsh.AgentLoop/AgentLoop.cs - Agent Framework host
src/Dsh.Agent.Maf/DshAgentHost.cs
Models and messages
- Messages
src/Dsh.Ai/Messages.cs - LLM runtime
src/Dsh.Llm/LlmRuntime.cs - Chat client
src/Dsh.Ai.ChatClient/DshChatClient.cs - DeepSeek adapter
src/Dsh.Ai.DeepSeek/DeepSeekAdapter.cs
Session state
- Session log
src/Dsh.Session/Session.cs - Session store
src/Dsh.Session/SessionStore.cs - Session projections
src/Dsh.Session.Projection/SessionProjectionRegistry.cs - Persistence contract
src/Dsh.Session.Persistence/StorageContract.cs - JSONL persistence
src/Dsh.Session.Persistence.Jsonl/JsonlSessionService.cs - Session format
src/Dsh.Session.Format/SessionJsonText.cs
Tools and services
- System prompt
src/Dsh.SystemPrompt/SystemPrompt.cs - Tool runtime
src/Dsh.Tools/ToolRuntime.cs - Terminal control
src/Dsh.Tools/TerminalController.cs - Approval service
src/Dsh.Approval/ApprovalService.cs - Sandbox policy
src/Dsh.Sandbox.Policy/SandboxPolicyService.cs - Goal service
src/Dsh.Goal.Service/GoalService.cs
Cordis platform
- Service context
src/Dsh.Cordis/Context.cs - Fiber lifecycle
src/Dsh.Cordis/Fiber.cs - Effect cleanup
src/Dsh.Cordis/Effect.cs - Plugin declarations
src/Dsh.Cordis/Plugin.cs - Event service
src/Dsh.Cordis/EventService.cs
Other components
- User
Connections 28
- User → CLI host: uses
src/Dsh.Cli/Program.cs - User → Desktop host: uses
src/Dsh.Desktop/Program.cs - User → SDK handler: calls
src/Dsh.Sdk/SdkInitializeHandler.cs - CLI host → Agent loop: starts turns
- Desktop host → Agent loop: hosts sessions
- SDK handler → Agent loop: routes requests
src/Dsh.Sdk/SdkInitializeHandler.cs - Agent Framework host → Agent loop: adapts agent
- Agent loop → Session log: prepares sessions
src/Dsh.AgentLoop/AgentLoop.cs - Agent loop → LLM runtime: runs model calls
src/Dsh.AgentLoop/LlmRemoteServiceAdapter.cs - LLM runtime → Messages: projects messages
src/Dsh.Llm/LlmRuntime.cs - LLM runtime → Chat client: uses client
- LLM runtime → DeepSeek adapter: selects adapter
- Session log → Session store: managed by
- Session log → Session projections: projects events
src/Dsh.Session.Projection/SessionProjectionRegistry.cs - Session store → Persistence contract: validates persistence
- Persistence contract → JSONL persistence: shared contract
src/Dsh.Session.Persistence.Jsonl/JsonlSessionService.cs - JSONL persistence → Session format: reads and writes
src/Dsh.Session.Persistence.Jsonl/JsonlSessionService.cs - Agent loop → System prompt: assembles prompts
src/Dsh.AgentLoop/AgentLoop.cs - Agent loop → Tool runtime: dispatches tools
src/Dsh.AgentLoop/AgentLoop.cs - Tool runtime → Terminal control: routes terminal calls
src/Dsh.Tools/TerminalController.cs - Agent loop → Approval service: requests approval
src/Dsh.Approval/ApprovalService.cs - Agent loop → Sandbox policy: applies policy
- Agent loop → Goal service: supports goal work
src/Dsh.Goal.Service/GoalService.cs - Agent loop → Service context: uses context
src/Dsh.AgentLoop/AgentLoop.cs - Service context → Plugin declarations: loads plugins
src/Dsh.Cordis/Context.cs - Plugin declarations → Fiber lifecycle: creates fibers
src/Dsh.Cordis/Plugin.cs - Fiber lifecycle → Effect cleanup: owns cleanup
src/Dsh.Cordis/Fiber.cs - Service context → Event service: dispatches events
src/Dsh.Cordis/Context.cs