A Minimal CLI Agent Blueprint Inspired by DeepSeek Harness
After reading the MIT-licensed DeepSeek Harness source code, the author drafted a minimal CLI agent blueprint. It uses an append-only JSONL event log as its source of truth, derives model history from the log, and defines a streaming request, tool-call, execution, and logging loop. The blueprint also specifies fail-closed permission modes and 12 operational invariants, including pairing every tool call with a result and replaying every model-visible byte from the conversation log. The source references and line numbers reflect the master snapshot the author reviewed and may change in later versions.
The blueprint offers a compact, explainable reference for agent-loop design, emphasizing replayable state, explicit tool orchestration, and permission boundaries. Its descriptions of DeepSeek Harness are the author's own reading and were not independently verified here.
引子:两个极端,和我想走的第三条路
想搞懂 Agent 到底怎么跑起来,网上给的路一般是两个极端。
一个是"30 行代码手写 Agent",你照着抄完,它能跑,但你不知道它为什么能跑——没有日志、没有并发、没有权限,一旦模型行为怪一点,你就只能靠 print 猜。
另一个是直接读一个成熟框架。比如 DeepSeek Harness(下称 DSH)开源的这个:Cordis 插件内核、20 多个工具、会话日志、沙箱、子 agent、PTY、遥测……读完你会觉得"太强了",然后更不敢自己写了。
我想要的是第三条:一条能自己解释清楚的最小 agent 循环。
读输入 → 拼请求 → 流式收 → 装配 tool_call → 执行工具 → 结果进历史 → 再发一次