最新LatestOpenHarness 源码阅读 · 八Reading OpenHarness · 8
OpenHarness
源码阅读source reading
- 第一篇:Part 1: 按下回车之后After you press EnterAgent 不只是一次模型请求。这篇笔记从一条用户消息出发,跟踪它如何被装配、流式发送,并在工具调用与文本回复之间循环。An agent is more than one model request. Starting from a single user message, this note follows how it is assembled, streamed out, and looped between tool calls and text replies.7 分钟7 min
- 第二篇:Part 2: 模型答完了,任务还没完The model is done. The task isn't.第一篇沿着一条消息画出了 Query Loop 的地图;这一篇继续走进 Engine,观察每一轮怎样开始、被拦截、压缩、执行,并最终结束。The first piece mapped the Query Loop by following one message. This one walks into the Engine to watch how each turn starts, gets intercepted, compacted and executed, and finally ends.13 分钟13 min
- 第三篇:Part 3: 从零写一个工具,到模型能调用它From an empty file to a tool the model can call工具不只是给 LLM 的函数列表。它还定义输入、权限、生命周期事件,以及结果如何回到下一轮对话。A tool is more than a function list handed to the LLM. It also defines inputs, permissions and lifecycle events, and how its result returns to the next turn of the conversation.10 分钟10 min
- 第四篇:Part 4: 九道检查,顺序就是安全策略Nine checks, and the order is the policy工具执行前的统一闸门:先硬拦敏感路径与 deny 列表,再按模式决定放行、弹确认还是直接拒绝。One gate before any tool runs: sensitive paths and the deny list are blocked outright first, then the mode decides whether to allow, ask for confirmation, or refuse.9 分钟9 min
- 第五篇:Part 5: Hook 返回 blocked,不等于真的拦住了A hook returning blocked doesn't stop anything by itselfHook 是生命周期节点上的异步扩展机制:适合门禁、审计、通知与校验;但它不是能任意改写 prompt、工具入参或工具结果的通用中间件。Hooks are asynchronous extensions at lifecycle points: good for gates, audits, notifications and checks, but not a general-purpose middleware that can rewrite prompts, tool inputs or tool results at will.11 分钟11 min
- 第六篇:Part 6: 先给目录,用到再翻正文Catalog first, body on demandSkill 是 Markdown + YAML frontmatter。系统 prompt 只放清单;正文按需加载——模型走 skill 工具,用户走 /skill-name。A skill is Markdown plus YAML frontmatter. The system prompt holds only the catalog; the body loads on demand: the model goes through the skill tool, the user through /skill-name.11 分钟11 min
- 第七篇:Part 7: 外部工具接进来,走的还是同一条管线External tools, same pipelineMCP 把外部工具与资源接到 agent。OpenHarness 做 client:连上 server,用适配器把每个 MCP tool 注册成普通 BaseTool,再走同一套管线。MCP connects external tools and resources to the agent. OpenHarness is the client: it connects to servers, registers each MCP tool as an ordinary BaseTool through an adapter, and sends it down the same pipeline.14 分钟14 min
- 第八篇:Part 8: 谁定义,谁派活,谁来跑Who defines, who dispatches, who runs多 Agent 不是一个模块,是三层各管一段:定义层回答「有哪些 agent」,调度层回答「这次派谁」,执行层回答「怎么跑起来」。Multi-agent is not one module but three layers, each owning one part: the definition layer answers “which agents exist”, the dispatch layer “who goes this time”, and the execution layer “how it runs”.12 分钟12 min
系列之外Outside the series
全部 11 篇All 11 piecesLLM 没有消灭意图识别,只是把它变成了路由LLMs didn't end intent recognition. They turned it into routing.
taxonomy 设计错了,后面全是坑。Get the taxonomy wrong, and everything after it is a trap.
Codex 说 272K,OpenCode 说 500KCodex says 272K, OpenCode says 500K
同一套 GPT OAuth,Codex 显示 272K,OpenCode 显示 500K。数字并不只是大小不同,它们代表的上下文口径也不同。With the same GPT OAuth, Codex shows 272K and OpenCode shows 500K. The numbers differ in more than size: they count the context in different ways.
能用 workflow 的地方,先别上 AgentIf a workflow can do it, hold off on the agent
能用编排 workflow 解决的业务,绝不轻易使用 Agent。If an orchestrated workflow can solve the business problem, don't reach for an agent lightly.
项目Projects
全部项目All projects- 案例一Case 1
OpenHarness Lab
选择 OpenHarness,不是为了再使用一个现成 Coding Agent,而是为了把 LLM 外面的执行系统拆开,并以它为起点构建自己的 Agent。I chose OpenHarness not to use yet another ready-made coding agent, but to take apart the execution system around the LLM and build my own agent from there.
研究中Researching源码阅读与改造Source reading and modification2026 - 案例二Case 2
企业流程平台里的 Agent 入口An agent entry point for an enterprise workflow platform
这不是给每个审批节点加一个模型调用,而是为企业流程找到可审计、可回退的智能入口。This is not about adding a model call to every approval step. It is about finding an auditable, reversible way into enterprise workflows.
建设中Building平台工程Platform engineering只有摘要Summary only - 案例三Case 3
大营销抽奖平台Big Market lottery platform
抽奖只是用户看到的一次点击,系统真正承担的是峰值流量、有限库存与重复请求同时到来时的确定性。To the user, a draw is one click. What the system actually carries is determinism when peak traffic, limited stock and duplicate requests all arrive at once.
已上线Shipped后端架构Backend architecture2024
实验室Lab大营销抽奖Big Market lottery
大营销抽奖实验室Big Market lottery lab
在浏览器里模拟一次抽奖,显示请求经过的责任链和规则树节点。Simulates a draw in the browser and shows which responsibility-chain and rule-tree nodes the request passed through.
Open the lab去实验室- 额度校验Quota check
quota_check - 创建抽奖单Create order
order - 权重规则Weight rule
rule_weight - 默认规则Default rule
rule_default(跳过) (skipped) - 解锁规则Unlock rule
rule_lock(跳过) (skipped) - 库存规则Stock rule
rule_stock(跳过) (skipped) - 兜底奖规则Fallback award
rule_luck_award(跳过) (skipped) - 发奖与履约Award
award
rule_weight 接管,后面四步都跳过rule_weight takes over; the next four steps are skipped