本文基于 deepseek-harness 仓库(
0.1.0-rc.5,约 1.2 万次提交)源码逐行解读,并实际运行了其单元测试与回放 fixture 验证结论。
DeepSeek 官方开源了一个 agent harness:everything is a plugin——连模型适配器、工具注册表、会话日志、甚至 agent 主循环本身都是插件,任何一个都可以从配置里被替换。
这不只是营销话术。把它拆开之后,我发现这个框架藏着大量"不看代码绝对发现不了"的细节:为什么工具调用结果要伪装成 user 角色?为什么模型请求必须是会话日志的"纯函数"?为什么崩溃后日志里会出现一个任何主循环都永远不会主动发出的 turn/end?并发工具调用怎么在"并发执行"和"严格保序"之间同时成立?
这篇文章用中英双语,从架构骨架到内核细节逐层拆解。
This article is based on a line-by-line reading of the deepseek-harness repository (
0.1.0-rc.5, ~12K commits), and the conclusions were verified by actually running its unit tests and replay fixtures.
DeepSeek has open-sourced an agent harness where everything is a plugin — the model adapters, the tool registry, the session log, and even the agent loop itself are all plugins, and any of them can be replaced from configuration.
That is not just marketing. Once you open it up, you find a pile of details you can only discover by reading the code: why do tool results disguise themselves as user messages? Why must a model request be a “pure function” of the session log? Why does a crash leave behind a turn/end that no loop ever emits on its own? And how do concurrent tool calls manage to be both “concurrent” and “strictly ordered” at the same time?
This article goes from the architectural skeleton down to the kernel-level details, in both Chinese and English.


大黑山