<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>小南的博客</title>
        <link>https://tangly1024.com/</link>
        <description>一个博客</description>
        <lastBuildDate>Tue, 01 Sep 2026 09:44:54 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2026, 小南</copyright>
        <item>
            <title><![CDATA[04 Vibe Coding]]></title>
            <link>https://tangly1024.com/article/VibeCoding-004</link>
            <guid>https://tangly1024.com/article/VibeCoding-004</guid>
            <pubDate>Fri, 10 Apr 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Claude Code]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-341b7925fd2880d784f4d41a23264723"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-341b7925fd288018a7b6f0d1e6a5ba25"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text"></div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-341b7925fd2880428fe1dcaf70c1ced5" data-id="341b7925fd2880428fe1dcaf70c1ced5"><span><div id="341b7925fd2880428fe1dcaf70c1ced5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd2880428fe1dcaf70c1ced5" title="Claude Code "><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>Claude Code </b></span></span></h2><ul class="notion-list notion-list-disc notion-block-341b7925fd2880f6b574d6a707481568"><li><b>工具系统设计</b>：Claude Code 内置了 Read、Write、Edit、Bash、Grep、Glob 等精心设计的原子</li></ul><ul class="notion-list notion-list-disc notion-block-341b7925fd2880d4b61cf7bde5f76c07"><li>工具，每个工具都有明确的边界和安全约束。这套工具体系的设计思路，可以直接迁移到自定义Agent 项目中。</li></ul><ul class="notion-list notion-list-disc notion-block-341b7925fd2880b69c22e3b1072c4828"><li><b>记忆管理架构</b>：CLAUDE.md（项目级记忆）+ Auto Memory（自动记忆）的双层架构，解决了Agent 的&quot;长期记忆&quot;难题，成熟度超过大多数开源 Agent 框架的记忆方案。</li></ul><ul class="notion-list notion-list-disc notion-block-341b7925fd2880bc890bc6875e6b3893"><li><b>上下文工程</b>：Claude Code 的 /compact 命令背后是一套精密的上下文压缩与管理策略，它解决的是所有 Agent 都面临的核心挑战——<b>如何在有限的 Context Window 里塞下无限的世界知识</b>。</li></ul><ul class="notion-list notion-list-disc notion-block-341b7925fd28805da22bd99f103ed930"><li><b>人机协作模式 (Human-in-the-Loop)</b>：Claude Code 的权限确认机制、Checkpoint 回滚机制、Plan Mode 等设计，展示了 Agent 与人类如何高效且安全地协作。</li></ul><ul class="notion-list notion-list-disc notion-block-341b7925fd2880a0aaaec5e7b4665c17"><li><b>扩展生态</b>：Skills / MCP / Plugin 三套扩展体系，分别解决了&quot;业务逻辑封装&quot;、&quot;外部能力连接&quot;和&quot;社区生态接入&quot;三个不同层次的问题。</li></ul><div class="notion-text notion-block-341b7925fd2880c69c36eaa5637cf63d">Claude Code 的架构可以拆分为<b>六大核心系统</b>，各自承担不同的职责，共同构成一个完整的 Agent 工作闭环：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-341b7925fd2880f194b8c2f79270d3d8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/ca4639fd-f7f7-4f71-aca8-b72dfec611bb/image.png?table=block&amp;id=341b7925-fd28-80f1-94b8-c2f79270d3d8&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=cYDSF9xz5rhH5Jb_lg2wzqC4PVpb3ybT4OxgZigK8p4&amp;t=341b7925-fd28-80f1-94b8-c2f79270d3d8" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-341b7925fd288013af32ced41c41615d" data-id="341b7925fd288013af32ced41c41615d"><span><div id="341b7925fd288013af32ced41c41615d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd288013af32ced41c41615d" title="1 内置工具系统：Agent 的执行引擎"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>1 内置工具系统：Agent 的执行引擎</b></span></span></h3><div class="notion-text notion-block-341b7925fd28809aba42d50608a3fec5">内置工具是 Claude Code 与外部世界交互的<b>唯一通道</b>——模型本身不能直接操作文件系统或执行命令，所有操作都必须通过工具调用 (Tool Use) 完成。Claude Code 内置了以下核心工具：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-341b7925fd288030985af72aa8f7e3e4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/8905a4d8-1144-4328-b9ed-e4d95b502ef7/image.png?table=block&amp;id=341b7925-fd28-8030-985a-f72aa8f7e3e4&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=Z9R41Wqu9UOi0cSrEdZ2ccrAAPlfQlzB3OAbAzRQ6Sw&amp;t=341b7925-fd28-8030-985a-f72aa8f7e3e4" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-341b7925fd28803dbf10c9ea0882716d" data-id="341b7925fd28803dbf10c9ea0882716d"><span><div id="341b7925fd28803dbf10c9ea0882716d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd28803dbf10c9ea0882716d" title="2 多级记忆系统：跨会话的知识沉淀"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>2 多级记忆系统：跨会话的知识沉淀</b></span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-341b7925fd2880129266dda4ee87d9e1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/3202cdd0-6358-479a-bf2e-2bf280376e38/image.png?table=block&amp;id=341b7925-fd28-8012-9266-dda4ee87d9e1&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=WoJlH7iGQ_pMrkk6U2GOa-sLSD_zsLPlkyx6v5wS7p0&amp;t=341b7925-fd28-8012-9266-dda4ee87d9e1" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-341b7925fd28802ebc88f0b463c8a732" data-id="341b7925fd28802ebc88f0b463c8a732"><span><div id="341b7925fd28802ebc88f0b463c8a732" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd28802ebc88f0b463c8a732" title="3 项目管理系统：Checkpoint 回滚与安全保障"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>3 项目管理系统：Checkpoint 回滚与安全保障</b></span></span></h3><div class="notion-text notion-block-341b7925fd2880ba9a32e1566e95e5cf">让 AI Agent 自动修改代码，最大的担忧是：<b>改坏了怎么办？</b> Claude Code 的项目管理系统通过<b>Checkpoint（检查点） </b>机制解决了这个问题。</div><div class="notion-text notion-block-341b7925fd28803bb05dfc862c416b75"><b>工作原理</b>：Claude Code 在每次产生文件变更时，自动创建一个 Checkpoint，记录变更前的文件快照。如果对某次修改不满意，可以随时回滚到任意历史检查点——类似 Git 的 commit，但粒度更细，精确到每一轮对话中的每一次文件操作。</div><div class="notion-text notion-block-341b7925fd2880de96c2e2171437ebf1"><b>实际效果示例</b>：Claude Code 重构了 3 个文件后，你发现新的实现方案不合适。通过 /rewind 命令选择回滚点，一键恢复到重构前的代码状态——所有被修改的文件恢复原貌，新创建的文件被删除，干净利落。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-341b7925fd28809e823bf3aa51ea1a5f" data-id="341b7925fd28809e823bf3aa51ea1a5f"><span><div id="341b7925fd28809e823bf3aa51ea1a5f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd28809e823bf3aa51ea1a5f" title="4 斜杠命令系统：Agent 的控制面板"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>4 斜杠命令系统：Agent 的控制面板</b></span></span></h3><div class="notion-text notion-block-341b7925fd28804b9e61e1f5118f3b92">斜杠命令是与 Claude Code 交互的<b>快捷控制方式</b>——在对话输入框中键入 / 即可调出命令菜单。</div><div class="notion-text notion-block-341b7925fd28801e9c34ed1f74324bbb">截至 2026 年 3 月，Claude Code 内置了 <b>59 个斜杠命令</b>（含别名），覆盖了从会话管理、模型切换到扩展配置的方方面面。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-341b7925fd28800db647deae18eaa4e3" data-id="341b7925fd28800db647deae18eaa4e3"><span><div id="341b7925fd28800db647deae18eaa4e3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd28800db647deae18eaa4e3" title="1 会话管理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>1 会话管理</b></span></span></h4><table class="notion-simple-table notion-block-341b7925fd2880e4bec6f0c8220daf30"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-341b7925fd288083a23bc5ad2452633d"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">别名</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880dda97be65ed97030d5"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/clear</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">清空当前对话历史，释放上下文</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/reset</code>、<code class="notion-inline-code">/new</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880f49aa2ead6aee3f56d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/compact [指示]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">压缩对话历史，可指定保留重点</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880cca68dc7a04785c918"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/resume [会话]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">按 ID / 名称恢复指定历史会话</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/continue</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880b69796ef7a244bf6f4"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/fork [名称]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">从当前对话创建分支副本</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28805dbefad84cd5b93e36"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/rename [名称]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">重命名当前会话</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880059748e2577632fa5f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/export [文件名]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">导出对话为纯文本文件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880b0b33ed4049e69a335"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/exit</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">退出 CLI</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/quit</code></div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-341b7925fd2880a39e56fdfee3f84664" data-id="341b7925fd2880a39e56fdfee3f84664"><span><div id="341b7925fd2880a39e56fdfee3f84664" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd2880a39e56fdfee3f84664" title="2 模型与模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>2 模型与模式</b></span></span></h4><table class="notion-simple-table notion-block-341b7925fd28800aa4a4e38162fd74ea"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-341b7925fd288083a2ecc159c81c2f1a"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">别名</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880ac95ccfa208a9002ef"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/model [模型名]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">切换 AI 模型（左右箭头调整 Effort Level）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880cab444dfe264197ee2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/plan</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">进入 Plan Mode（先规划后执行）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd288041bc2bfe5abd12114c"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/fast [on\|off]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">切换快速输出模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880579e1dea9f6642b5da"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/output-style [风格]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">切换输出风格（Default / Explanatory / Learning）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28804f8810d786849eea63"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/vim</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">切换 Vim / Normal 编辑模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-341b7925fd288012a698d3116395e6c9" data-id="341b7925fd288012a698d3116395e6c9"><span><div id="341b7925fd288012a698d3116395e6c9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd288012a698d3116395e6c9" title="3 项目与上下文"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>3 项目与上下文</b></span></span></h4><table class="notion-simple-table notion-block-341b7925fd2880138188cca0cc743434"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-341b7925fd28803abe1efa7a97fd3ec4"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">别名</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28808ebe8ecd9c59335627"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/init</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">初始化项目，生成 <code class="notion-inline-code">CLAUDE.md</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880b28178c922bcc64da2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/add-dir &lt;路径&gt;</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">向当前会话添加额外的工作目录</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28805499b3d97f6fbb2ebb"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/context</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">可视化当前上下文使用情况（彩色网格）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880f5bd94c0fb23487b67"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/diff</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">打开交互式 Diff 查看器，查看未提交的变更</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880d9866ee436ea71679f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/rewind</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">回滚对话和 / 或代码到历史检查点</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/checkpoint</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880d7a477c31dc9c7e42f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/pr-comments [PR]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">获取 GitHub PR 的评论</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880888f5be71931afbb74"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/review</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">对 Pull Request 进行代码审查</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd288074bfaafd336782be6f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/security-review</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">分析当前分支的变更是否存在安全漏洞</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880c88ab7ce51c45d0498"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/copy</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">复制上一条 AI 回复到剪贴板</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-341b7925fd28803497e4ca22a5d505d1" data-id="341b7925fd28803497e4ca22a5d505d1"><span><div id="341b7925fd28803497e4ca22a5d505d1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd28803497e4ca22a5d505d1" title="4 配置与状态"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>4 配置与状态</b></span></span></h4><table class="notion-simple-table notion-block-341b7925fd2880b0ac7acd6e741bd130"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-341b7925fd288075bed2f2720cd3dac9"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">别名</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880b9b2fbde6dbd9c4fd5"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/config</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">打开配置界面</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/settings</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880b497e0c876c0e60b98"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/permissions</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">查看 / 修改工具权限</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/allowed-tools</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd288060aeb3ec39af913e33"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/memory</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">编辑 <code class="notion-inline-code">CLAUDE.md</code> 记忆文件，管理自动记忆</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28805394b9c41b4d8b9ac5"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/doctor</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">诊断安装和配置状态</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28806ea00cdbe8c6f4bf7f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/status</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">显示版本、模型、账户和连接状态</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880ada17ecaa8d462d3e0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/cost</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">显示当前会话 Token 用量和费用（API 用户）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28808d8c97e4638a02805d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/stats</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">可视化每日用量、会话历史和使用模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880c5ae49e88ceb73de5a"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/usage</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">显示订阅套餐限额和速率限制状态</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880f584a0f39886c7b602"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/theme</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">更换颜色主题（含深色 / 浅色 / 色盲友好版本）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28800982e3d0f0e74661e7"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/statusline</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">配置终端状态栏信息</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880cab1d8dd502331ae82"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/keybindings</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">打开快捷键配置文件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28807585eefd910a93b3dd"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/terminal-setup</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">配置终端快捷键（如 <code class="notion-inline-code">Shift+Enter</code>）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-341b7925fd28807ab269cdd6432305c3" data-id="341b7925fd28807ab269cdd6432305c3"><span><div id="341b7925fd28807ab269cdd6432305c3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd28807ab269cdd6432305c3" title="5 扩展与 Agent"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>5 扩展与 Agent</b></span></span></h4><table class="notion-simple-table notion-block-341b7925fd2880219ac5f601b7bfea18"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-341b7925fd288002a505f9d16f7c4ab8"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">别名</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880308d08ec7db85a5c3d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/mcp</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">管理 MCP Server 连接和 OAuth 认证</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28809a8b57ea5f72f99794"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/skills</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">列出可用的 Skills</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28808bad53f19b604fe7f4"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/plugin</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">管理 Plugin 插件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd288017ae35dbe563d384f0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/agents</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">管理自定义 Agent 配置</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd288002bdc6db3e9c04277c"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/tasks</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">列出和管理后台任务</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880e3bd3cf3b5fb7af51b"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/hooks</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">管理 Hook 事件配置</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-341b7925fd2880d7a59dfd1035a7aaca" data-id="341b7925fd2880d7a59dfd1035a7aaca"><span><div id="341b7925fd2880d7a59dfd1035a7aaca" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd2880d7a59dfd1035a7aaca" title="6 账户与平台"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>6 账户与平台</b></span></span></h4><table class="notion-simple-table notion-block-341b7925fd2880189593c37dad06edd6"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-341b7925fd2880c4911ae0c772ca5e9b"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">别名</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28808e9065f39e847b600a"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/login</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">登录 Anthropic 账户</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880b09a1ded6b9346b35b"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/logout</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">登出 Anthropic 账户</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880139b5ccdc8fc96755d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/upgrade</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">打开套餐升级页面</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880959327d1bd48e35b19"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/extra-usage</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">配置超额使用（限额触达后继续工作）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd288065babec06290e9a603"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/privacy-settings</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">查看 / 修改隐私设置（Pro/Max 用户）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880e6ba57eaec5ae6d95f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/desktop</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">将当前会话转移到桌面应用</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/app</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880b196f3f00da5065c94"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/mobile</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">显示移动端 App 下载二维码</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/ios</code>、<code class="notion-inline-code">/android</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880ee80b3e9029a2685cb"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/chrome</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">配置 Chrome 集成设置</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880bc82fbf08f39a6ec47"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/ide</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">管理 IDE 集成状态</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880c9ac2cd016e2bfb3ad"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/remote-control</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">允许从 claude.ai 远程控制此会话</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/rc</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd288055833cea906b619f5f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/remote-env</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">配置远程环境默认值</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28802db5f7c02901e03518"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/install-github-app</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">安装 Claude GitHub Actions App</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880c1b7aaebc5f91472ea"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/install-slack-app</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">安装 Claude Slack App</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-341b7925fd2880fe8579cdd9d9e624f9" data-id="341b7925fd2880fe8579cdd9d9e624f9"><span><div id="341b7925fd2880fe8579cdd9d9e624f9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd2880fe8579cdd9d9e624f9" title="7 信息与反馈"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>7 信息与反馈</b></span></span></h4><table class="notion-simple-table notion-block-341b7925fd2880b08ecbda37cb31c4d9"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-341b7925fd2880d5b27addbb726fa9f5"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">别名</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28808a897fdfb08693c861"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/help</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">显示帮助信息和可用命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28801ab2caf66551ce571e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/feedback [报告]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提交使用反馈或 Bug 报告</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/bug</code></div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28801daaabe42430fc7ad1"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/release-notes</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">查看版本更新日志</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28807fb899e5db2c2c73e7"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/insights</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">生成使用分析报告（项目领域、交互模式、摩擦点）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880079f79fa5588803848"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/stickers</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">订购 Claude Code 贴纸	</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd288057bf66f7ff5649abf7"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/passes</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">分享免费试用周（符合条件的账户可见）	</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-341b7925fd2880cb9ba9c7c863d1cae1" data-id="341b7925fd2880cb9ba9c7c863d1cae1"><span><div id="341b7925fd2880cb9ba9c7c863d1cae1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd2880cb9ba9c7c863d1cae1" title="8 内置 Skills（以斜杠命令形式触发）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>8 内置 Skills（以斜杠命令形式触发）</b></span></span></h4><table class="notion-simple-table notion-block-341b7925fd2880a6935df95cda9232ed"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-341b7925fd28801c8a29e420d59c18f7"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880998212e37102c7398c"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/simplify</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">审查近期变更代码的复用性、质量和效率，自动修复发现的问题</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd28807ca395f29e9be675dd"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/batch &lt;指令&gt;</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">将大规模代码变更分解为 5-30 个独立子任务，并行派发给 Agent 在隔离的 Git Worktree 中执行</div></td></tr><tr class="notion-simple-table-row notion-block-341b7925fd2880ca9191e4a86a96b842"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/debug [描述]</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">读取会话调试日志，诊断 Claude Code 自身的运行问题</div></td></tr></tbody></table><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-341b7925fd288073aef7f904bff567f8" data-id="341b7925fd288073aef7f904bff567f8"><span><div id="341b7925fd288073aef7f904bff567f8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd288073aef7f904bff567f8" title="5 扩展能力系统：MCP、Skills 与 Plugin"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>5 扩展能力系统：MCP、Skills 与 Plugin</b></span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-341b7925fd28804c80eff465b2492637"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/d7a5fb28-733e-49e6-8ef7-43aa1b1602e3/image.png?table=block&amp;id=341b7925-fd28-804c-80ef-f465b2492637&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=LgPm2O24CDn_SZlSs7nGllT4p36yhfPtbRXal0YE7Vw&amp;t=341b7925-fd28-804c-80ef-f465b2492637" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-341b7925fd2880669dbdf6a9fa258396" data-id="341b7925fd2880669dbdf6a9fa258396"><span><div id="341b7925fd2880669dbdf6a9fa258396" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd2880669dbdf6a9fa258396" title="6 多 Agent 协作系统"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6 多 Agent 协作系统</span></span></h3><div class="notion-text notion-block-341b7925fd2880e3a82ae2301f055e6b">传统的 AI 编程助手是&quot;单线程&quot;的——一次只能处理一个任务。Claude Code 的多 Agent 系统打破了这一限制，引入了 Sub-Agent 委托和 Agent Team 两种协作模式。</div><ol start="1" class="notion-list notion-list-numbered notion-block-341b7925fd2880c5940acce5cf2972e1" style="list-style-type:decimal"><li>Sub-Agent（子智能体委托）</li></ol><div class="notion-text notion-block-341b7925fd28802f858ecef38ba61866">Claude Code 在处理复杂任务时，可以自主派生出一个或多个 Sub-Agent，将子任务委托给它们并并行处理。每个 Sub-Agent 拥有独立的上下文和工具权限，完成后将结果汇报给主 Agent。</div><ol start="2" class="notion-list notion-list-numbered notion-block-341b7925fd2880b3bf07d6df4bbe82d8" style="list-style-type:decimal"><li>Agent Team（智能体团队）</li></ol><div class="notion-text notion-block-341b7925fd28806bb54bca58c53baa5a">这是更高级的多 Agent 编排模式（实验性功能），允许定义多个具有不同专长的 Agent 组成团队，协同完成复杂项目。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-342b7925fd288031a025db6693e6dae0" data-id="342b7925fd288031a025db6693e6dae0"><span><div id="342b7925fd288031a025db6693e6dae0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#342b7925fd288031a025db6693e6dae0" title="Claude code 配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Claude code 配置</span></span></h2><a class="notion-external notion-external-block notion-row notion-block-342b7925fd288041ad98f30f05d4997c" href="https://github.com/huangguang1999/ccstatusline-zh" target="_blank" rel="noopener noreferrer"><div class="notion-external-image"><svg viewBox="0 0 260 260"><g><path d="M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z" fill="#161614"></path></g></svg></div><div class="notion-external-description"><div class="notion-external-title">ccstatusline-zh</div><div class="notion-external-block-desc">huangguang1999<span> • </span>Updated May 10, 2026</div></div></a><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-342b7925fd2880aab965d1f1e0fab311" data-id="342b7925fd2880aab965d1f1e0fab311"><span><div id="342b7925fd2880aab965d1f1e0fab311" class="notion-header-anchor"></div><a class="notion-hash-link" href="#342b7925fd2880aab965d1f1e0fab311" title="使用&amp;开发"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">使用&amp;开发</span></span></h2><ol start="1" class="notion-list notion-list-numbered notion-block-342b7925fd288049a54eebbc751ba883" style="list-style-type:decimal"><li>完整十八开发阶段研发流水线</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd288062aaa0cb307086b82f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAANqad4LJIYzsDMGlxXBHbqeOmc-LxQAAgEOaxslGvBWia8hh9KJJPwBAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-8062-aaa0-cb307086b82f" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="2" class="notion-list notion-list-numbered notion-block-342b7925fd288025a005e5b97f46d9b0" style="list-style-type:decimal"><li>Claude Code 前后端设计规范</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd2880149a19d18dae278e26"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAANsad4LMQocOZk_198jBuYyYow7ITUAAgIOaxslGvBWDVyVa4q0yCEBAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-8014-9a19-d18dae278e26" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="3" class="notion-list notion-list-numbered notion-block-342b7925fd2880b9b39bf503a1c6af71" style="list-style-type:decimal"><li>Claude Code 可观测闭环</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd2880ce9872dd4d8a5f58ca"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAANyad4W4BwosqBoIlpXqOrAWgyyYo0AAkEOaxslGvBWpovWY2NSRf4BAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-80ce-9872-dd4d8a5f58ca" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="4" class="notion-list notion-list-numbered notion-block-342b7925fd2880999883d906207915d1" style="list-style-type:decimal"><li>Claude Code 对话模式技巧</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd2880b4bd4ffcc628361687"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAANwad4W0_T7IYOyuTW6k4unvQJhLr0AAkAOaxslGvBWNOZJxfnJLU4BAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-80b4-bd4f-fcc628361687" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="5" class="notion-list notion-list-numbered notion-block-342b7925fd28803fa853ef68aeff57ed" style="list-style-type:decimal"><li>Claude Code 工具体系</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd28804a9bcdce8d6303416e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAAN0ad4W7v0gEtMUAoRnMa9AD6LIMDUAAkIOaxslGvBW2D3fp7Aec_0BAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-804a-9bcd-ce8d6303416e" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="6" class="notion-list notion-list-numbered notion-block-342b7925fd2880c9a37aca69568f3b0c" style="list-style-type:decimal"><li>Claude Code 权限模式关系图</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd28805e9228c09d82c558df"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAAN2ad4W9Qg4u4SJf5fTTpNUKN3I5L0AAkMOaxslGvBWkz2i7Kg3rz8BAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-805e-9228-c09d82c558df" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="7" class="notion-list notion-list-numbered notion-block-342b7925fd28800ca9fed94539f2c3ce" style="list-style-type:decimal"><li>Claude Code 工具权限关系</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd28809f8546cb55d024af1f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAAN4ad4XC_sik_loqEwN6bcqIZQ9u8wAAkQOaxslGvBWVvSMPH1s5qcBAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-809f-8546-cb55d024af1f" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="8" class="notion-list notion-list-numbered notion-block-342b7925fd2880a0bec6ca36eff4af69" style="list-style-type:decimal"><li>Claude Code Bash 虚拟环境选择策略</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd288012b95ec0db6005efc7"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAAOCad4bRmI7F2s1tu1I8GCeWMR2BjAAAkwOaxslGvBWdOb3eUMPmroBAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-8012-b95e-c0db6005efc7" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="9" class="notion-list notion-list-numbered notion-block-342b7925fd2880aea94fdb4cb83a599c" style="list-style-type:decimal"><li>Claude Code Memory</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd28803a9410e47ccc4577e4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAAN8ad4XIEr-AAGJrFXNQW_e71QCAdOGAAJGDmsbJRrwVmeH0ryJNzsZAQADAgADdwADOwQ.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-803a-9410-e47ccc4577e4" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="10" class="notion-list notion-list-numbered notion-block-342b7925fd288099adc2c6bac80e73c6" style="list-style-type:decimal"><li>.claude/rules/*.md 项目规则详解</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd288095b266d96909f1cc34"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAAN-ad4XKSNNkjvNBDo_Mi68xfjYBXsAAkcOaxslGvBW77UaqGIY-Y8BAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-8095-b266-d96909f1cc34" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="11" class="notion-list notion-list-numbered notion-block-342b7925fd28805eab4dd130ad82a25f" style="list-style-type:decimal"><li>Claude Code 实战经验分享</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-342b7925fd288031b31ce950b47bc33d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://k-vault-image-host.pages.dev/file/AgACAgUAAyEGAATiQDIfAAOAad4XQYUJK7aL1UXnH2XgLgGNIT0AAkgOaxslGvBWTjk5KwpBUYQBAAMCAAN3AAM7BA.png?spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;t=342b7925-fd28-8031-b31c-e950b47bc33d" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-342b7925fd288041bb7af257fc1e4dba"> </div><div class="notion-blank notion-block-342b7925fd28802b8fb8eb7cbcd52594"> </div><div class="notion-blank notion-block-342b7925fd28808686f0e17d005836c2"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-341b7925fd2880c4abe3c78aab5b2124" data-id="341b7925fd2880c4abe3c78aab5b2124"><span><div id="341b7925fd2880c4abe3c78aab5b2124" class="notion-header-anchor"></div><a class="notion-hash-link" href="#341b7925fd2880c4abe3c78aab5b2124" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-341b7925fd2880f9844dcb6b59020329"><li>一些引用</li></ul><ul class="notion-list notion-list-disc notion-block-341b7925fd2880148734cc5c1bd76894"><li>引用文章</li></ul><div class="notion-blank notion-block-341b7925fd2880ba84f0cff8aad9941a"> </div><div class="notion-callout notion-gray_background_co notion-block-341b7925fd2880b28f2beec0916a5fcc"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">欢迎您在底部评论区留言，一起交流~</div></div><div class="notion-blank notion-block-341b7925fd28806190fff6ab9de95697"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[临时]]></title>
            <link>https://tangly1024.com/article/111</link>
            <guid>https://tangly1024.com/article/111</guid>
            <pubDate>Thu, 04 Jun 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-374b7925fd288049a9fecb799e382387"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-374b7925fd2880279d95cb500546d70f" data-id="374b7925fd2880279d95cb500546d70f"><span><div id="374b7925fd2880279d95cb500546d70f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880279d95cb500546d70f" title="第7章：Agent 层 — Main Crew"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第7章：Agent 层 — Main Crew</span></span></h2><blockquote class="notion-quote notion-block-374b7925fd28807a9210f58ddabb1502"><div>本章目标：深入理解 CrewAI 框架下的主 Agent 设计，包括 Agent/Task YAML 配置、Prompt 工程、ReAct 推理循环、step_callback 详细模式，以及工厂模式的应用。</div><div class="notion-text notion-block-374b7925fd2880579e42cecd3bf16bd8">本章依赖：第3章（数据模型）、第5章（Runner）、第6章（Session）</div><div class="notion-text notion-block-374b7925fd288039bbc7ef1c4ae1a6f7">对应源码：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd2880afa01fcd26109cf1bb"><li>[xiaopaw/agents/main_crew.py](file:///d:/ProjectsCodes/企业级智能体实战/xiaopow/xiaopaw/agents/main_crew.py)</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880e191cbd737210b85cb"><li>[xiaopaw/agents/models.py](file:///d:/ProjectsCodes/企业级智能体实战/xiaopow/xiaopaw/agents/models.py)</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880f1b610fcf542886578"><li>[xiaopaw/agents/config/agents.yaml](file:///d:/ProjectsCodes/企业级智能体实战/xiaopow/xiaopaw/agents/config/agents.yaml)</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd288024b910fb5f0ec8e2df"><li>[xiaopaw/agents/config/tasks.yaml](file:///d:/ProjectsCodes/企业级智能体实战/xiaopow/xiaopaw/agents/config/tasks.yaml)</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880889a2acaf92d45514c"><li>[xiaopaw/tools/intermediate_tool.py](file:///d:/ProjectsCodes/企业级智能体实战/xiaopow/xiaopaw/tools/intermediate_tool.py)</li></ul><div class="notion-text notion-block-374b7925fd2880cca9eeea81720cf199">预计时间：2-3 小时</div></blockquote><hr class="notion-hr notion-block-374b7925fd2880f094d8d1213b835e73"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd288056ad3ad0d140e2c328" data-id="374b7925fd288056ad3ad0d140e2c328"><span><div id="374b7925fd288056ad3ad0d140e2c328" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288056ad3ad0d140e2c328" title="7.1 什么是 Agent？通俗理解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.1 什么是 Agent？通俗理解</span></span></h3><div class="notion-text notion-block-374b7925fd2880e2b44ce2b48ce3206b">在聊代码之前，先理解一个概念：<b>Agent（智能体）到底是什么？</b></div><div class="notion-text notion-block-374b7925fd288046946ae88309ecd430">想象你有一个非常聪明的助手，你给他一个任务，他：</div><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880e3af31e4f44c34f3d4" style="list-style-type:decimal"><li><b>思考</b>：这个任务我应该怎么做？</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd28804ebb89c081f7acb58d" style="list-style-type:decimal"><li><b>行动</b>：调用工具去完成（查资料、写代码、发消息）</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd288075b052ebe3afe2ba4a" style="list-style-type:decimal"><li><b>观察</b>：看看工具返回了什么结果</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd28803393bcf60cb75860a1" style="list-style-type:decimal"><li><b>判断</b>：结果对吗？需要继续吗？还是可以给出最终答案了？</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-374b7925fd2880c1aefde93227245543" style="list-style-type:decimal"><li><b>回到步骤 1</b>（如果需要的话）</li></ol><div class="notion-text notion-block-374b7925fd288082b933d516fa09b71b">这就是 Agent 的核心工作方式——<b>ReAct（推理-行动）循环</b>。</div><hr class="notion-hr notion-block-374b7925fd2880eca1a5e1f574122462"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880fabc51f429cfb593a3" data-id="374b7925fd2880fabc51f429cfb593a3"><span><div id="374b7925fd2880fabc51f429cfb593a3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880fabc51f429cfb593a3" title="7.2 CrewAI 框架简介"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.2 CrewAI 框架简介</span></span></h3><blockquote class="notion-quote notion-block-374b7925fd288097bb48df199fbef17a"><div>CrewAI 是一个 Python 框架，帮助我们快速构建 AI Agent。它提供了 Agent、Task、Crew 三个核心概念。</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28809c9d97c60975f267ea" data-id="374b7925fd28809c9d97c60975f267ea"><span><div id="374b7925fd28809c9d97c60975f267ea" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809c9d97c60975f267ea" title="7.2.1 核心概念一览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.2.1 核心概念一览</span></span></h4><table class="notion-simple-table notion-block-374b7925fd288088a24ff56b38c9d6b4"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880928ffdc21823576639"><td class="" style="width:120px"><div class="notion-simple-table-cell">概念</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">通俗理解</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">在代码中</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880b4b444dedc9a54c72c"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Agent</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">&quot;一个员工&quot; — 有身份、有目标、有技能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Agent(role=..., goal=..., tools=...)</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880b88f61cc4dcf64fa96"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Task</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">&quot;一个任务&quot; — 具体要做的事情</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Task(description=..., expected_output=...)</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880fc9ecbe42a6fbab09e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Tool</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">&quot;一个工具&quot; — Agent 可以调用的能力</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">SkillLoaderTool()</code>, <code class="notion-inline-code">IntermediateTool()</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288079ad58f69e98da2724"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Crew</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">&quot;一个团队&quot; — 包含 Agent + Task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Crew(agents=[...], tasks=[...])</code></div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880a7ac4fd7a2a82e0aae" data-id="374b7925fd2880a7ac4fd7a2a82e0aae"><span><div id="374b7925fd2880a7ac4fd7a2a82e0aae" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a7ac4fd7a2a82e0aae" title="7.2.2 CrewAI 的执行流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.2.2 CrewAI 的执行流程</span></span></h4><hr class="notion-hr notion-block-374b7925fd2880289592e8d55b0d9430"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880adbdfeecf474b2d308" data-id="374b7925fd2880adbdfeecf474b2d308"><span><div id="374b7925fd2880adbdfeecf474b2d308" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880adbdfeecf474b2d308" title="7.3 XiaoPaw 的 Agent 架构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.3 XiaoPaw 的 Agent 架构</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880349ce6faa1a04261d7" data-id="374b7925fd2880349ce6faa1a04261d7"><span><div id="374b7925fd2880349ce6faa1a04261d7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880349ce6faa1a04261d7" title="7.3.1 整体设计"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.3.1 整体设计</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288067b1d7e675281ec7ec" data-id="374b7925fd288067b1d7e675281ec7ec"><span><div id="374b7925fd288067b1d7e675281ec7ec" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288067b1d7e675281ec7ec" title="7.3.2 设计原则"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.3.2 设计原则</span></span></h4><div class="notion-text notion-block-374b7925fd288078b5a8f9c77467d9e4"><b>原则一：极简主 Agent（单工具原则）</b></div><div class="notion-text notion-block-374b7925fd2880ae807dfb304da0b196">主 Agent 只有一个能力扩展工具：<code class="notion-inline-code">SkillLoaderTool</code>。所有专业能力（PDF 处理、飞书操作、网络搜索等）都通过 Skill 生态接入。这样做的好处：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd2880628cbdf8a7bd6c0451"><li>主 Agent 的 Prompt 更短（不需要列举所有工具）</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28805299efc408f60774b4"><li>新增 Skill 不需要修改主 Agent</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28806cba3febc0c47bbb76"><li>主 Agent 的职责清晰：理解意图 → 编排 Skill</li></ul><div class="notion-text notion-block-374b7925fd288051b65acca311dc623b"><b>原则二：结构化输出</b></div><div class="notion-text notion-block-374b7925fd2880099e70d015a58fce8f">使用 Pydantic 模型强制 LLM 输出 JSON 格式：</div><div class="notion-text notion-block-374b7925fd2880b1804adeff96aeb1d0">为什么需要结构化输出？</div><ul class="notion-list notion-list-disc notion-block-374b7925fd2880ada43aec7cc1f3e49c"><li>程序可以可靠地解析 Agent 的回复（<code class="notion-inline-code">result.pydantic.reply</code>）</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28805dace7c7dc8ebfe134"><li>可以追踪 Agent 用了哪些 Skill（<code class="notion-inline-code">result.pydantic.used_skills</code>）</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28809c85b0f919e27e7a67"><li>避免 LLM 输出格式不一致导致的解析错误</li></ul><div class="notion-text notion-block-374b7925fd28804a8bc1e07595eec2d9"><b>原则三：YAML + Python 分离</b></div><table class="notion-simple-table notion-block-374b7925fd2880a79eb7d87945861a0e"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd28809daf90d1abe4c8ea21"><td class="" style="width:120px"><div class="notion-simple-table-cell">配置层</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">位置</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">内容</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">修改频率</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288027abbcd8d9c7c87fb2"><td class="" style="width:120px"><div class="notion-simple-table-cell">YAML（人设层）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">agents.yaml</code>, <code class="notion-inline-code">tasks.yaml</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 的角色、目标、行为规范</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">经常调整（调 Prompt）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880ea96a8d88f87208324"><td class="" style="width:120px"><div class="notion-simple-table-cell">Python（代码层）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">main_crew.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具绑定、LLM 绑定、工厂函数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">较少修改（代码稳定）</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd28809eaaa8db8d2f518f5c"><b>原则四：工厂模式防污染</b></div><div class="notion-text notion-block-374b7925fd2880e4bde4df9a76cfb504">每次请求创建新的 Crew 实例，防止上一轮的状态污染下一轮。详见 7.7 节。</div><hr class="notion-hr notion-block-374b7925fd2880b6982ef507e7f5a1e2"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880fd8168d731d59d802a" data-id="374b7925fd2880fd8168d731d59d802a"><span><div id="374b7925fd2880fd8168d731d59d802a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880fd8168d731d59d802a" title="7.4 Agent 配置详解（agents.yaml）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.4 Agent 配置详解（agents.yaml）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880daadccec38105e6f0c" data-id="374b7925fd2880daadccec38105e6f0c"><span><div id="374b7925fd2880daadccec38105e6f0c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880daadccec38105e6f0c" title="7.4.1 完整配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.4.1 完整配置</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288069b13deefbef5488d2" data-id="374b7925fd288069b13deefbef5488d2"><span><div id="374b7925fd288069b13deefbef5488d2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288069b13deefbef5488d2" title="7.4.2 配置字段详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.4.2 配置字段详解</span></span></h4><table class="notion-simple-table notion-block-374b7925fd2880a2995bc883a53d2448"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd28809780e3d4bc22b8c78b"><td class="" style="width:120px"><div class="notion-simple-table-cell">字段</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">作用</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">对 LLM 的影响</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">示例</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809b9c38d53896b7c3e9"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">role</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定义身份/职位</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">影响回复风格和专业程度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">&quot;XiaoPaw 工作助手&quot;</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880a991dce38dac9b343a"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">goal</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定义最终目标</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">指导整个推理方向</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">&quot;通过 Skills 完成任务&quot;</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880909dd6d8355e46b072"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">backstory</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">背景故事 + 行为规范</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">最重要的 Prompt 工程部分</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工作流程、边界、策略</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28802b86a0ee301234bc5d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">max_iter</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">最大迭代次数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">安全阀，防止无限循环</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">50</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880f69a0bdaf6f6d9c7b8" data-id="374b7925fd2880f69a0bdaf6f6d9c7b8"><span><div id="374b7925fd2880f69a0bdaf6f6d9c7b8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880f69a0bdaf6f6d9c7b8" title="7.4.3 backstory 中的 Prompt 工程技巧"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.4.3 backstory 中的 Prompt 工程技巧</span></span></h4><div class="notion-text notion-block-374b7925fd2880b0b0cff3aa76bbbbea"><b>技巧一：明确工作流程（Step-by-Step）</b></div><div class="notion-text notion-block-374b7925fd2880218020cb644493fc47">为什么 Step-by-Step 有效？因为 LLM 是&quot;逐 token 生成&quot;的，明确的步骤让它更容易产生正确的推理链。</div><div class="notion-text notion-block-374b7925fd288000913fd42bb48d660c"><b>技巧二：明确行为边界（负面约束）</b></div><div class="notion-text notion-block-374b7925fd2880e98231ff07a3df97e4">负面约束（&quot;不要做什么&quot;）和正面约束（&quot;要做什么&quot;）同样重要。LLM 有时会&quot;过度自信&quot;编造结果，明确禁止可以防止。</div><div class="notion-text notion-block-374b7925fd2880d1b34dd2464b75fb14"><b>技巧三：搜索策略优先级</b></div><div class="notion-text notion-block-374b7925fd2880fa8550d9ddec13b637">让 Agent 知道工具之间的优先级关系，避免&quot;大材小用&quot;。</div><hr class="notion-hr notion-block-374b7925fd2880358bc4d33b11a6d531"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880878de4e1e405773b8e" data-id="374b7925fd2880878de4e1e405773b8e"><span><div id="374b7925fd2880878de4e1e405773b8e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880878de4e1e405773b8e" title="7.5 Task 配置详解（tasks.yaml）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.5 Task 配置详解（tasks.yaml）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880659e70e7d302bb0f97" data-id="374b7925fd2880659e70e7d302bb0f97"><span><div id="374b7925fd2880659e70e7d302bb0f97" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880659e70e7d302bb0f97" title="7.5.1 完整配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.5.1 完整配置</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880f08bf1d6a26d690c9b" data-id="374b7925fd2880f08bf1d6a26d690c9b"><span><div id="374b7925fd2880f08bf1d6a26d690c9b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880f08bf1d6a26d690c9b" title="7.5.2 Task 的两要素"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.5.2 Task 的两要素</span></span></h4><table class="notion-simple-table notion-block-374b7925fd288059a594de1b34241875"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd288038aeccf1feb3a805ab"><td class="" style="width:120px"><div class="notion-simple-table-cell">要素</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">作用</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">示例</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880239050db0a9416f3d0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">description</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">任务的&quot;输入&quot;：告诉 Agent 当前要处理什么</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">历史对话 + 用户消息</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28801388d0f34abf18ae17"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">expected_output</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">任务的&quot;输出格式&quot;：告诉 Agent 最终要返回什么</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">JSON 格式 {reply, used_skills}</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880c28eabcd6c21d5adee" data-id="374b7925fd2880c28eabcd6c21d5adee"><span><div id="374b7925fd2880c28eabcd6c21d5adee" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c28eabcd6c21d5adee" title="7.5.3 模板变量注入"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.5.3 模板变量注入</span></span></h4><div class="notion-text notion-block-374b7925fd28802a935ccf6072e42709"><code class="notion-inline-code">description</code> 中的 <code class="notion-inline-code">{history}</code> 和 <code class="notion-inline-code">{user_message}</code> 是<b>模板变量</b>，在运行时通过 <code class="notion-inline-code">akickoff(inputs={...})</code> 注入：</div><div class="notion-text notion-block-374b7925fd288068806be5c59c55589e"><b>注入过程</b>：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880fdaba9e48454a2ab51" data-id="374b7925fd2880fdaba9e48454a2ab51"><span><div id="374b7925fd2880fdaba9e48454a2ab51" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880fdaba9e48454a2ab51" title="7.5.4 结构化输出（output_pydantic）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.5.4 结构化输出（output_pydantic）</span></span></h4><div class="notion-text notion-block-374b7925fd28804bb234c1934acd5c1f"><b>在 Task 中使用</b>：</div><div class="notion-text notion-block-374b7925fd288039914ac325f303c59f"><b>使用结果</b>：</div><hr class="notion-hr notion-block-374b7925fd288075849fcc3342f84785"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880119e1de40a7b2ce6ff" data-id="374b7925fd2880119e1de40a7b2ce6ff"><span><div id="374b7925fd2880119e1de40a7b2ce6ff" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880119e1de40a7b2ce6ff" title="7.6 历史格式化（_format_history）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.6 历史格式化（_format_history）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880cd9bcbcc3b4e986f93" data-id="374b7925fd2880cd9bcbcc3b4e986f93"><span><div id="374b7925fd2880cd9bcbcc3b4e986f93" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880cd9bcbcc3b4e986f93" title="7.6.1 完整实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.6.1 完整实现</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288026b965dc6da483c442" data-id="374b7925fd288026b965dc6da483c442"><span><div id="374b7925fd288026b965dc6da483c442" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288026b965dc6da483c442" title="7.6.2 输出示例"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.6.2 输出示例</span></span></h4><div class="notion-text notion-block-374b7925fd28804fbe97f7b43a7643ed"><b>完整历史只有 4 条时（不截断）</b>：</div><div class="notion-text notion-block-374b7925fd288021b924d9f3f2f2b136"><b>完整历史有 30 条，截断到 20 条时</b>：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880a983aedf57a9ee6445" data-id="374b7925fd2880a983aedf57a9ee6445"><span><div id="374b7925fd2880a983aedf57a9ee6445" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a983aedf57a9ee6445" title="7.6.3 设计要点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.6.3 设计要点</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880dda4beff794f5f339b" style="list-style-type:decimal"><li><b>不直接丢弃历史</b>：超出部分不是直接扔掉，而是告知 Agent &quot;存在更早的历史&quot;</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd288083a137ff54fbd024cb" style="list-style-type:decimal"><li><b>引导 Agent 使用 history_reader</b>：如果 Agent 需要更早的上下文，会主动调用 history_reader Skill</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd28808f8213cfb648b847b2" style="list-style-type:decimal"><li><b>不暴露时间戳</b>：只展示对话内容，不展示原始时间戳（保持简洁）</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd2880c8a683e7ba6e82f193" style="list-style-type:decimal"><li><b>中文角色名</b>：比英文更自然，LLM 处理中文语境时效果更好</li></ol><hr class="notion-hr notion-block-374b7925fd288040b4f5d7255c46c7d3"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880a08a28f6657781ddf6" data-id="374b7925fd2880a08a28f6657781ddf6"><span><div id="374b7925fd2880a08a28f6657781ddf6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a08a28f6657781ddf6" title="7.7 Verbose 模式（step_callback）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.7 Verbose 模式（step_callback）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28809bbd72e19ddb9c81bd" data-id="374b7925fd28809bbd72e19ddb9c81bd"><span><div id="374b7925fd28809bbd72e19ddb9c81bd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809bbd72e19ddb9c81bd" title="7.7.1 什么是 Verbose 模式？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.7.1 什么是 Verbose 模式？</span></span></h4><div class="notion-text notion-block-374b7925fd2880a7be4fdadee46f6fe7">Verbose 模式让 Agent 把&quot;心里想什么&quot;实时告诉用户：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28807b9736fed96c424e35" data-id="374b7925fd28807b9736fed96c424e35"><span><div id="374b7925fd28807b9736fed96c424e35" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28807b9736fed96c424e35" title="7.7.2 回调构建"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.7.2 回调构建</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880ea9b57c097e3ef595c" data-id="374b7925fd2880ea9b57c097e3ef595c"><span><div id="374b7925fd2880ea9b57c097e3ef595c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880ea9b57c097e3ef595c" title="7.7.3 ReAct 循环中的回调触发"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.7.3 ReAct 循环中的回调触发</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288044a8f9f79c0a3c9ddf" data-id="374b7925fd288044a8f9f79c0a3c9ddf"><span><div id="374b7925fd288044a8f9f79c0a3c9ddf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288044a8f9f79c0a3c9ddf" title="7.7.4 适用范围"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.7.4 适用范围</span></span></h4><table class="notion-simple-table notion-block-374b7925fd288061980cfa2991e676b4"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880a4beedc055ea12cf15"><td class="" style="width:120px"><div class="notion-simple-table-cell">场景</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">verbose 推送</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">原因</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28801fa539dbf814c74371"><td class="" style="width:120px"><div class="notion-simple-table-cell">单聊（p2p）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 推送</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">用户主动开启，希望看到推理过程</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880f5abeaca81c56f6e2f"><td class="" style="width:120px"><div class="notion-simple-table-cell">群聊（group）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 推送</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">群成员可以看到推理过程</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880e3a636c3e34be03bb0"><td class="" style="width:120px"><div class="notion-simple-table-cell">话题群（thread）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌ 不推送</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">避免话题污染（一个话题里塞太多消息）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809a9269dd9789ca89d8"><td class="" style="width:120px"><div class="notion-simple-table-cell">Sub-Crew</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌ 不注入</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Sub-Crew 的推理过程不需要暴露给用户</div></td></tr></tbody></table><hr class="notion-hr notion-block-374b7925fd2880f79d75c7006e9e7137"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880758952eb74505746d9" data-id="374b7925fd2880758952eb74505746d9"><span><div id="374b7925fd2880758952eb74505746d9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880758952eb74505746d9" title="7.8 工厂模式（build_agent_fn）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.8 工厂模式（build_agent_fn）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288022a5c4eaf18fa9feca" data-id="374b7925fd288022a5c4eaf18fa9feca"><span><div id="374b7925fd288022a5c4eaf18fa9feca" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288022a5c4eaf18fa9feca" title="7.8.1 为什么需要工厂模式？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.8.1 为什么需要工厂模式？</span></span></h4><div class="notion-text notion-block-374b7925fd28806fb4bcf71249b57969">先看一个&quot;不用工厂模式&quot;的问题：</div><div class="notion-text notion-block-374b7925fd28800eb3d6c98c7cc6e1e2"><b>CrewAI 的 Agent 在 </b><code class="notion-inline-code"><b>kickoff()</b></code><b> 后会积累内部状态</b>（如执行历史、工具调用记录）。如果复用同一个实例，上一轮的状态会影响下一轮的推理。这就是&quot;状态污染&quot;。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880f8a734e8e44fcf1368" data-id="374b7925fd2880f8a734e8e44fcf1368"><span><div id="374b7925fd2880f8a734e8e44fcf1368" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880f8a734e8e44fcf1368" title="7.8.2 工厂模式的实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.8.2 工厂模式的实现</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288026b617c58e279977e6" data-id="374b7925fd288026b617c58e279977e6"><span><div id="374b7925fd288026b617c58e279977e6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288026b617c58e279977e6" title="7.8.3 闭包原理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.8.3 闭包原理</span></span></h4><div class="notion-text notion-block-374b7925fd288045880acb32a51d61f6"><b>通俗理解</b>：闭包就像一个&quot;带记忆的函数&quot;。它记住了创建时的环境（sender、max_history_turns 等），之后每次调用都能使用这些记忆。</div><hr class="notion-hr notion-block-374b7925fd2880caa634e6211f3d66a6"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880ef8672faf51580b745" data-id="374b7925fd2880ef8672faf51580b745"><span><div id="374b7925fd2880ef8672faf51580b745" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880ef8672faf51580b745" title="7.9 Crew 构建详解（_build_crew）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.9 Crew 构建详解（_build_crew）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288070a5b5c4a1a13b6916" data-id="374b7925fd288070a5b5c4a1a13b6916"><span><div id="374b7925fd288070a5b5c4a1a13b6916" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288070a5b5c4a1a13b6916" title="7.9.1 完整实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.9.1 完整实现</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880d9b039d2c7eb6c2074" data-id="374b7925fd2880d9b039d2c7eb6c2074"><span><div id="374b7925fd2880d9b039d2c7eb6c2074" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880d9b039d2c7eb6c2074" title="7.9.2 关键参数说明"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.9.2 关键参数说明</span></span></h4><table class="notion-simple-table notion-block-374b7925fd2880f5aebbe15ab199e78b"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880cd84adc57afbc5aacc"><td class="" style="width:120px"><div class="notion-simple-table-cell">参数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">值</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">为什么这样设置</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880ebb3e8f8911254a123"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">temperature</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">0.3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">较低温度让输出更稳定。对于需要精确执行的工作助手，不可预测性是有害的</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288097ba4dd615e9fbaba0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">process</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Process.sequential</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">单 Agent 单 Task，顺序执行即可</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28801699eade9df004b00d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">verbose</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">True</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">在控制台打印 ReAct 过程，方便调试</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288078b537de486a5a6353"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">output_pydantic</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">MainTaskOutput</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">强制 JSON 格式输出，程序可解析</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28804e9453c9fc6b4a2309"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">max_iter</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">50</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">足够的迭代次数处理复杂任务，同时防止无限循环</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880cf8006d806008f0640" data-id="374b7925fd2880cf8006d806008f0640"><span><div id="374b7925fd2880cf8006d806008f0640" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880cf8006d806008f0640" title="7.9.3 IntermediateTool 详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.9.3 IntermediateTool 详解</span></span></h4><hr class="notion-hr notion-block-374b7925fd28800a92c2cf03212c47b0"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880349c28f7317470a0af" data-id="374b7925fd2880349c28f7317470a0af"><span><div id="374b7925fd2880349c28f7317470a0af" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880349c28f7317470a0af" title="7.10 完整执行流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.10 完整执行流程</span></span></h3><div class="notion-text notion-block-374b7925fd2880c79949f00f1d88cc01">把以上所有部分串联起来，看一次完整的消息处理流程：</div><hr class="notion-hr notion-block-374b7925fd2880b0b65efcd3b64eac87"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880c4954af279fa07d8a2" data-id="374b7925fd2880c4954af279fa07d8a2"><span><div id="374b7925fd2880c4954af279fa07d8a2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c4954af279fa07d8a2" title="7.11 本章小结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.11 本章小结</span></span></h3><div class="notion-text notion-block-374b7925fd2880aa86affa8bcc524ea6">本章我们深入学习了 XiaoPaw 的 Agent 层——Main Crew 的完整实现。核心要点回顾：</div><table class="notion-simple-table notion-block-374b7925fd2880ea92fdd8ebd82eff08"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880ff8857e74bf892e0cf"><td class="" style="width:120px"><div class="notion-simple-table-cell">概念</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">说明</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">位置</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28807aa938de2b4dd97cd6"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Agent</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">有身份、有目标、有工具的 AI 角色</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">agents.yaml</code> + <code class="notion-inline-code">main_crew.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28803fbbb2eba4758a9d75"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Task</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">具体的任务描述和期望输出</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">tasks.yaml</code> + <code class="notion-inline-code">main_crew.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288025a0bde1cff795e6c5"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Crew</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent + Task 的组合体</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">main_crew.py</code> 的 <code class="notion-inline-code">_build_crew()</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880ee8a7cf17aeb448d96"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>ReAct 循环</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Thought → Action → Observation 的推理循环</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">CrewAI 框架内部</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880cda2e8d4c824a32b39"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>step_callback</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每轮 ReAct 后触发的回调，用于 verbose 推送</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">_make_step_callback()</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880aaa91cee6cf1a0e619"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>工厂模式</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每次请求创建新 Crew 实例，防止状态污染</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">build_agent_fn()</code></div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd28803dba8cd73979f94335"><b>关键设计决策</b>：</div><table class="notion-simple-table notion-block-374b7925fd2880128108e41bfe1cd075"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880fb8661dd7b9bde620c"><td class="" style="width:120px"><div class="notion-simple-table-cell">决策</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">原因</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880c781ddd74eeeb5e043"><td class="" style="width:120px"><div class="notion-simple-table-cell">单工具原则（SkillLoaderTool）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">主 Agent 极简，能力通过 Skill 扩展</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288012bee0fae40f62c9c4"><td class="" style="width:120px"><div class="notion-simple-table-cell">YAML + Python 分离</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">人设可调（YAML），代码稳定（Python）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28800ebbc7cf244463f3e9"><td class="" style="width:120px"><div class="notion-simple-table-cell">结构化输出（output_pydantic）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">程序可解析，避免 LLM 输出格式不一致</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288065ac49c6392fd7dd6c"><td class="" style="width:120px"><div class="notion-simple-table-cell">工厂模式（每次新建 Crew）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">防止 CrewAI 内部状态污染</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809db128f0753fec1a70"><td class="" style="width:120px"><div class="notion-simple-table-cell">历史截断 + history_reader 引导</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">控制上下文长度，不丢失历史</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880158657c0afa6e0c8e9"><td class="" style="width:120px"><div class="notion-simple-table-cell">低温 LLM（temperature=0.3）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">追求稳定性和可预测性</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd2880fdadf2ee0849ff3e99"><b>下一步</b>：下一章将深入 Sub-Crew 与 AIO-Sandbox 沙盒的实现，了解 Skill 如何在隔离环境中安全执行。</div><hr class="notion-hr notion-block-374b7925fd2880b7a8d1d906399125c3"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880bfb923decf648bb676" data-id="374b7925fd2880bfb923decf648bb676"><span><div id="374b7925fd2880bfb923decf648bb676" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880bfb923decf648bb676" title="7.12 练习"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.12 练习</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd28803780b7e1e03eebd27a" style="list-style-type:decimal"><li>修改 <code class="notion-inline-code">agents.yaml</code> 中的 <code class="notion-inline-code">backstory</code>，添加一条新的行为约束（如&quot;回复不能超过 200 字&quot;），观察 Agent 行为变化</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd2880c79b71e4ce5c23b3c0" style="list-style-type:decimal"><li>在 <code class="notion-inline-code">MainTaskOutput</code> 中添加一个新字段 <code class="notion-inline-code">confidence: float</code>，让 Agent 输出对自己回答的信心程度</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880dfba39d94848ea629a" style="list-style-type:decimal"><li>尝试把 <code class="notion-inline-code">temperature</code> 从 0.3 改为 0.8，观察 Agent 的回复风格变化</li></ol><div class="notion-blank notion-block-374b7925fd28800fbeefc4ac5b45f802"> </div><hr class="notion-hr notion-block-374b7925fd2880188ad4c53743df28bc"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-374b7925fd2880cbb2b4c2ee2b107697" data-id="374b7925fd2880cbb2b4c2ee2b107697"><span><div id="374b7925fd2880cbb2b4c2ee2b107697" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880cbb2b4c2ee2b107697" title="第8章：Sub-Crew 与 AIO-Sandbox"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第8章：Sub-Crew 与 AIO-Sandbox</span></span></h2><blockquote class="notion-quote notion-block-374b7925fd2880c590d6d7642379835e"><div>本章目标：深入理解 Sub-Crew 的创建、MCP 协议、AIO-Sandbox 沙盒通信，以及工具行为约束。</div><div class="notion-text notion-block-374b7925fd288037bb7fc684bd3a9c3c">对应源码：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd288062b20feacff22fa771"><li><a class="notion-link" href="https://www.notion.so/xiaopaw/agents/skill_crew.py" target="_blank" rel="noopener noreferrer">xiaopaw/agents/skill_crew.py</a></li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd288066b3d8f570e2374512"><li><a class="notion-link" href="https://www.notion.so/sandbox-docker-compose.yaml" target="_blank" rel="noopener noreferrer">sandbox-docker-compose.yaml</a></li></ul></blockquote><hr class="notion-hr notion-block-374b7925fd288098accbfd130b7ef14d"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28800fb25ddf424097d8c1" data-id="374b7925fd28800fb25ddf424097d8c1"><span><div id="374b7925fd28800fb25ddf424097d8c1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28800fb25ddf424097d8c1" title="8.1 Sub-Crew 设计理念"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.1 Sub-Crew 设计理念</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880bda1ecf684af578ce1" data-id="374b7925fd2880bda1ecf684af578ce1"><span><div id="374b7925fd2880bda1ecf684af578ce1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880bda1ecf684af578ce1" title="8.1.1 为什么要 Sub-Crew？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.1.1 为什么要 Sub-Crew？</span></span></h4><div class="notion-text notion-block-374b7925fd288086ae78fbcff621d569">主 Agent 的上下文窗口有限（LLM 处理输入有 token 上限），如果让主 Agent 直接操控所有的文件处理、搜索、飞书工具：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880909e69c888a7fa3761" data-id="374b7925fd2880909e69c888a7fa3761"><span><div id="374b7925fd2880909e69c888a7fa3761" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880909e69c888a7fa3761" title="8.1.2 Sub-Crew 的隔离性"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.1.2 Sub-Crew 的隔离性</span></span></h4><table class="notion-simple-table notion-block-374b7925fd28801cb917c99a19436d1d"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd288026a51be0a94df75840"><td class="" style="width:120px"><div class="notion-simple-table-cell">维度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">主 Crew</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Sub-Crew</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288082a63def45d006a41a"><td class="" style="width:120px"><div class="notion-simple-table-cell">LLM 上下文</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">完整历史的最近20条</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">完全独立，不知道主对话</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880bbb987d0953d297480"><td class="" style="width:120px"><div class="notion-simple-table-cell">工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">SkillLoaderTool + IntermediateTool</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Sandbox MCP 工具</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880259d5ad3c97fdec3f0"><td class="" style="width:120px"><div class="notion-simple-table-cell">生命周期</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每次用户消息新建</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每个 task 型 Skill 调用新建</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880bb94d8dfd0bbff0e3d"><td class="" style="width:120px"><div class="notion-simple-table-cell">对话历史</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不分享</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不获取</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28807ca71deb1804abbf7a"><td class="" style="width:120px"><div class="notion-simple-table-cell">文件系统</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不直接访问</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/workspace/sessions/{sid}/</code></div></td></tr></tbody></table><hr class="notion-hr notion-block-374b7925fd288018b0a4e5527595ef3b"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28802ab796d4a511872616" data-id="374b7925fd28802ab796d4a511872616"><span><div id="374b7925fd28802ab796d4a511872616" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28802ab796d4a511872616" title="8.2 AIO-Sandbox 沙盒概述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.2 AIO-Sandbox 沙盒概述</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288033ad63cbd6b8d64aee" data-id="374b7925fd288033ad63cbd6b8d64aee"><span><div id="374b7925fd288033ad63cbd6b8d64aee" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288033ad63cbd6b8d64aee" title="8.2.1 什么是 AIO-Sandbox？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.2.1 什么是 AIO-Sandbox？</span></span></h4><div class="notion-text notion-block-374b7925fd2880c3bd82f76620862c42">AIO-Sandbox 是一个开源的 Docker 沙盒环境，提供：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd2880dfa874e2e8aca0301f"><li>隔离的代码执行环境（Python、Bash）</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28800e81ebfcf2d17a3ae7"><li>文件系统操作</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd288022b753c99ef5f77eb9"><li>浏览器自动化</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880019fd6ebbe177b3843"><li>MCP（Model Context Protocol）接口</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288051a727ea05feb6d12e" data-id="374b7925fd288051a727ea05feb6d12e"><span><div id="374b7925fd288051a727ea05feb6d12e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288051a727ea05feb6d12e" title="8.2.2 MCP 协议"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.2.2 MCP 协议</span></span></h4><div class="notion-text notion-block-374b7925fd28800cba9af21c38e40e91">MCP 是 Anthropic 提出的标准化工具调用协议。在 XiaoPaw 中：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880c284dee13812c5ccde" data-id="374b7925fd2880c284dee13812c5ccde"><span><div id="374b7925fd2880c284dee13812c5ccde" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c284dee13812c5ccde" title="8.2.3 Docker 挂载映射"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.2.3 Docker 挂载映射</span></span></h4><hr class="notion-hr notion-block-374b7925fd28805cbe51d608d592866a"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880d18731d2f63ec48b15" data-id="374b7925fd2880d18731d2f63ec48b15"><span><div id="374b7925fd2880d18731d2f63ec48b15" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880d18731d2f63ec48b15" title="8.3 Sub-Crew 构建（skill_crew.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.3 Sub-Crew 构建（skill_crew.py）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880719c68e7cca600071c" data-id="374b7925fd2880719c68e7cca600071c"><span><div id="374b7925fd2880719c68e7cca600071c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880719c68e7cca600071c" title="8.3.1 build_skill_crew() 工厂"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.3.1 build_skill_crew() 工厂</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880618e04e76d147b9014" data-id="374b7925fd2880618e04e76d147b9014"><span><div id="374b7925fd2880618e04e76d147b9014" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880618e04e76d147b9014" title="8.3.2 沙盒行为指令（sandbox_directive）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.3.2 沙盒行为指令（sandbox_directive）</span></span></h4><div class="notion-text notion-block-374b7925fd28809ca4f1c706fb0ffa9e"><b>指令设计要点</b>：</div><table class="notion-simple-table notion-block-374b7925fd288025a693d6c2ebd96cc0"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd288042b0aed0d69d65440d"><td class="" style="width:120px"><div class="notion-simple-table-cell">指令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">目的</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288030bd67db7b478ed1d6"><td class="" style="width:120px"><div class="notion-simple-table-cell">工作目录/输出目录</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">约束文件路径，防止写入随机位置</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28806db0e6e562bf503e2e"><td class="" style="width:120px"><div class="notion-simple-table-cell">可用工具列表</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">明确 Sub-Crew 能调用什么</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880ddbf6cd71374c69fcf"><td class="" style="width:120px"><div class="notion-simple-table-cell">规则 1：不编造结果</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">防止 LLM 幻觉</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880bbb225cead3f2a6385"><td class="" style="width:120px"><div class="notion-simple-table-cell">规则 3：输出到指定目录</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">统一输出路径，方便主 Agent 定位结果</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880e09c38e0e9545f91f8"><td class="" style="width:120px"><div class="notion-simple-table-cell">规则 6：--break-system-packages</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">解决 Docker 内 pip 安装冲突</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880f180cbcc54a0108336" data-id="374b7925fd2880f180cbcc54a0108336"><span><div id="374b7925fd2880f180cbcc54a0108336" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880f180cbcc54a0108336" title="8.3.3 MCP 工具集"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.3.3 MCP 工具集</span></span></h4><div class="notion-text notion-block-374b7925fd2880d1ba62f625d3844d10"><b>Sub-Crew 连接沙盒时，启用所有 MCP 工具（不使用白名单）</b>。工具约束通过 Agent backstory 行为规则来管理。</div><div class="notion-text notion-block-374b7925fd28803da85cc286da9c3f19">为什么不使用 <code class="notion-inline-code">create_static_tool_filter</code> 白名单？</div><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880b983d0d1493709135b" style="list-style-type:decimal"><li><code class="notion-inline-code">web_browse</code> Skill 需要 <code class="notion-inline-code">browser_*</code> 系列工具，静态白名单会限制这些工具</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd28809b82eecaf02bbdd9d7" style="list-style-type:decimal"><li>白名单后期维护成本高，新增工具需要修改代码</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880cea4aec0f46f689c87" style="list-style-type:decimal"><li>Backstory 行为约束更灵活，可以根据 Skill 类型调整指令</li></ol><hr class="notion-hr notion-block-374b7925fd288081bfaaf1241419813e"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28805c8b76d4b1a2696a51" data-id="374b7925fd28805c8b76d4b1a2696a51"><span><div id="374b7925fd28805c8b76d4b1a2696a51" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28805c8b76d4b1a2696a51" title="8.4 Sub-Crew 调用流程（完整串联）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.4 Sub-Crew 调用流程（完整串联）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28805abe51d13121bb4e26" data-id="374b7925fd28805abe51d13121bb4e26"><span><div id="374b7925fd28805abe51d13121bb4e26" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28805abe51d13121bb4e26" title="8.4.1 从 SkillLoaderTool 到 Sub-Crew"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.4.1 从 SkillLoaderTool 到 Sub-Crew</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28805980dfd998d73c7920" data-id="374b7925fd28805980dfd998d73c7920"><span><div id="374b7925fd28805980dfd998d73c7920" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28805980dfd998d73c7920" title="8.4.2 时序图"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.4.2 时序图</span></span></h4><hr class="notion-hr notion-block-374b7925fd28807fb613e0a137ca689e"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880279947e0f06673b229" data-id="374b7925fd2880279947e0f06673b229"><span><div id="374b7925fd2880279947e0f06673b229" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880279947e0f06673b229" title="8.5 Sub-Crew 与主 Agent 的 Session"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.5 Sub-Crew 与主 Agent 的 Session</span></span></h3><div class="notion-text notion-block-374b7925fd2880b292cfc8bb0d4da965"><b>关键点</b>：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd2880ecbb6df2cb3dc9dd53"><li>同一个 session 的两个 Sub-Crew 共享 <code class="notion-inline-code">/workspace/sessions/s-abc/</code> 目录</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880e295c1dc56fcfe26b0"><li>第一个 Sub-Crew 的输出文件可以被第二个 Sub-Crew 读取</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880d5ac78cd4c21fa9845"><li>每个 Sub-Crew 是独立实例，不知道前一个 Sub-Crew 做了什么</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880d287ece97c97b15fd5"><li>任务上下文（task_context）由主 Agent 负责串联</li></ul><hr class="notion-hr notion-block-374b7925fd2880f49c64c17d7c4dd4a5"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd288056b3f8cec391c118b0" data-id="374b7925fd288056b3f8cec391c118b0"><span><div id="374b7925fd288056b3f8cec391c118b0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288056b3f8cec391c118b0" title="8.6 Sandbox 凭证注入"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.6 Sandbox 凭证注入</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880a1994dd1326fbec7eb" data-id="374b7925fd2880a1994dd1326fbec7eb"><span><div id="374b7925fd2880a1994dd1326fbec7eb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a1994dd1326fbec7eb" title="8.6.1 write_feishu_credentials()"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.6.1 write_feishu_credentials()</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28800abc1bffef654aad82" data-id="374b7925fd28800abc1bffef654aad82"><span><div id="374b7925fd28800abc1bffef654aad82" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28800abc1bffef654aad82" title="8.6.2 使用方式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.6.2 使用方式</span></span></h4><div class="notion-text notion-block-374b7925fd288022a4dbf82c75a39864">feishu_ops Skill 的 Python 脚本读取凭证：</div><div class="notion-text notion-block-374b7925fd28805696b9ed76e0548fe9"><b>为什么凭证不经过 LLM？</b></div><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880d6bf61ebe434b32a6b" style="list-style-type:decimal"><li>LLM 的输入/输出可能被记录到日志和 trace</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd2880e09538d880ef42afc4" style="list-style-type:decimal"><li>凭证是敏感信息，不应暴露给第三方模型</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880a6a3fce1f678055e66" style="list-style-type:decimal"><li>凭证通过文件系统注入沙盒，脚本直接读取</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd2880a09b7fed67ba7d8a84" style="list-style-type:decimal"><li>LLM 不知道凭证的存在，也无法读取</li></ol><hr class="notion-hr notion-block-374b7925fd2880d39c44e16c4ed2d931"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880bdb21fff0ea1301376" data-id="374b7925fd2880bdb21fff0ea1301376"><span><div id="374b7925fd2880bdb21fff0ea1301376" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880bdb21fff0ea1301376" title="8.7 本章小结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.7 本章小结</span></span></h3><ul class="notion-list notion-list-disc notion-block-374b7925fd28802fabbad293db9410a0"><li><b>Sub-Crew</b>：每次 task 型 Skill 调用创建新实例，完全隔离</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd288089bf27dd234641db9a"><li><b>AIO-Sandbox</b>：Docker 沙盒，通过 MCP 协议通信</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880efa690c9f13d7de27e"><li><b>MCP 工具集</b>：21 个工具全部可用，约束通过 backstory 行为规则</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd288047a614dfca47e2ccb5"><li><b>凭证安全</b>：飞书/百度凭证写入沙盒文件（chmod 600），不经过 LLM</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880a1a744c0ebddcb32f8"><li><b>工作目录</b>：Sandbox 路径与主机路径通过 Docker volume 双向映射</li></ul><div class="notion-text notion-block-374b7925fd2880bbad35fb87601404be">下一章将深入 SkillLoaderTool 的实现和 Skills 生态系统。</div><div class="notion-blank notion-block-374b7925fd2880c9be46c1c67a45c010"> </div><hr class="notion-hr notion-block-374b7925fd2880549e03e1500f61f00a"/><div class="notion-blank notion-block-374b7925fd28802aa455dce17063bc69"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-374b7925fd2880aba1baebe38a9b5d86" data-id="374b7925fd2880aba1baebe38a9b5d86"><span><div id="374b7925fd2880aba1baebe38a9b5d86" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880aba1baebe38a9b5d86" title="第9章：Skills 生态系统与 SkillLoaderTool"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第9章：Skills 生态系统与 SkillLoaderTool</span></span></h2><blockquote class="notion-quote notion-block-374b7925fd28808d845afcb37d95315d"><div>本章目标：全面理解 XiaoPaw 的 Skills 生态——从定义规范到渐进式披露，从 SkillLoaderTool 的主/子工具切换，到三种特殊处理（reference、task、history_reader）。你将会学到：Skill 是什么、如何定义、如何加载、如何执行，以及整个调用链路是如何衔接的。</div><div class="notion-text notion-block-374b7925fd2880dbb843d337bb573009">对应源码：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd2880da8de7c0d85ef8748e"><li><a class="notion-link" href="https://www.notion.so/xiaopaw/tools/skill_loader.py" target="_blank" rel="noopener noreferrer">xiaopaw/tools/skill_loader.py</a> — 核心工具</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880409dd6cf213b7c5e7c"><li><a class="notion-link" href="https://www.notion.so/xiaopaw/skills/load_skills.yaml" target="_blank" rel="noopener noreferrer">xiaopaw/skills/load_skills.yaml</a> — Skill 清单</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd288067bbb7c0740f4b3edd"><li><a class="notion-link" href="https://www.notion.so/xiaopaw/agents/skill_crew.py" target="_blank" rel="noopener noreferrer">xiaopaw/agents/skill_crew.py</a> — Sub-Crew 工厂</li></ul></blockquote><hr class="notion-hr notion-block-374b7925fd2880daa90cc09217607e1a"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880bf90d5fc4fb84a87c5" data-id="374b7925fd2880bf90d5fc4fb84a87c5"><span><div id="374b7925fd2880bf90d5fc4fb84a87c5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880bf90d5fc4fb84a87c5" title="9.1 什么是 Skill？—— 用一个比喻理解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.1 什么是 Skill？—— 用一个比喻理解</span></span></h3><div class="notion-text notion-block-374b7925fd288012995fec10eddc2163">在正式进入代码之前，我们先用一个生活中的比喻来理解 &quot;Skill&quot; 这个概念。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880b3afffccbda10989aa" data-id="374b7925fd2880b3afffccbda10989aa"><span><div id="374b7925fd2880b3afffccbda10989aa" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880b3afffccbda10989aa" title="9.1.0 比喻：智能手机的应用商店"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.1.0 比喻：智能手机的应用商店</span></span></h4><div class="notion-text notion-block-374b7925fd288061bfe0ea0162f18eec">想象你的手机刚出厂时，只有打电话、发短信等最基本的功能。但当你从应用商店下载了微信、支付宝、地图等 App 后，手机的能力就大大扩展了。</div><div class="notion-text notion-block-374b7925fd28805ca8cdd319a04f4748">XiaoPaw 的 <b>Skill 生态</b> 就是这个思路：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880c2828de5bb4136f0ee" data-id="374b7925fd2880c2828de5bb4136f0ee"><span><div id="374b7925fd2880c2828de5bb4136f0ee" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c2828de5bb4136f0ee" title="9.1.1 为什么需要 Skill 生态？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.1.1 为什么需要 Skill 生态？</span></span></h4><div class="notion-text notion-block-374b7925fd288032b5e7f5cb0d182c0c"><b>核心问题</b>：如果让主 Agent 直接拥有所有工具（PDF 处理、Word 处理、搜索、飞书操作……），会发生什么？</div><div class="notion-text notion-block-374b7925fd2880a8b1a8d29e47734743"><b>关键优势</b>：</div><table class="notion-simple-table notion-block-374b7925fd288052878ce207c751bf9f"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd288003a7b9dd90a86b4da3"><td class="" style="width:120px"><div class="notion-simple-table-cell">维度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">全挂工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Skill 生态</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880908ae3f8a391721c32"><td class="" style="width:120px"><div class="notion-simple-table-cell">工具描述 token 消耗</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">~550 tokens（所有工具）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">~150 tokens（只有 Skill 列表）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880fbbd04de277d4f3389"><td class="" style="width:120px"><div class="notion-simple-table-cell">选择准确度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">容易选错</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">更精准（先在菜单中选，再加载详细指令）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28804796afdb6a92036b9c"><td class="" style="width:120px"><div class="notion-simple-table-cell">扩展性</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">新增工具需改 Agent 定义</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">只需添加 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 文件</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288047ba0bc5e832dbd751"><td class="" style="width:120px"><div class="notion-simple-table-cell">隔离性</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">一个工具崩溃影响全局</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每个 Skill 在独立 Sub-Crew 中运行</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288083b208fdefd874e7cd"><td class="" style="width:120px"><div class="notion-simple-table-cell">上下文安全</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具描述可能泄露敏感信息</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">阶段 0 只暴露名称+简短描述</div></td></tr></tbody></table><hr class="notion-hr notion-block-374b7925fd2880a0be83f9ea2bc6214f"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd288018946dd76434eb82a6" data-id="374b7925fd288018946dd76434eb82a6"><span><div id="374b7925fd288018946dd76434eb82a6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288018946dd76434eb82a6" title="9.2 Skill 定义规范"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.2 Skill 定义规范</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288027b2e8e2663115a4ea" data-id="374b7925fd288027b2e8e2663115a4ea"><span><div id="374b7925fd288027b2e8e2663115a4ea" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288027b2e8e2663115a4ea" title="9.2.1 SKILL.md 格式详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.2.1 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 格式详解</span></span></h4><div class="notion-text notion-block-374b7925fd2880b59109d55ceb6a1e9e">每个 Skill 目录下必须有一个 <code class="notion-inline-code">SKILL.md</code> 文件。这个文件是 Skill 的&quot;身份证&quot; + &quot;使用说明书&quot;，分为两部分：</div><div class="notion-text notion-block-374b7925fd2880618b2ddfef45518dd7"><b>YAML Frontmatter</b> 是 Skill 的&quot;身份证&quot;——描述 Skill 的基本信息，<b>阶段 0</b> 只需解析这部分。
<b>Markdown 正文</b> 是 Skill 的&quot;使用说明书&quot;——详细的执行步骤，<b>阶段 1</b> 按需加载。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288074b210ed0cfb874fd7" data-id="374b7925fd288074b210ed0cfb874fd7"><span><div id="374b7925fd288074b210ed0cfb874fd7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288074b210ed0cfb874fd7" title="实例：pdf Skill 的 SKILL.md"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">实例：pdf Skill 的 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a></span></span></h4><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880aa8664e8be6b9a2204" data-id="374b7925fd2880aa8664e8be6b9a2204"><span><div id="374b7925fd2880aa8664e8be6b9a2204" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880aa8664e8be6b9a2204" title="Python Libraries"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Python Libraries</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288081b902e586b23affc5" data-id="374b7925fd288081b902e586b23affc5"><span><div id="374b7925fd288081b902e586b23affc5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288081b902e586b23affc5" title="pypdf - Basic Operations"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">pypdf - Basic Operations</span></span></h4><div class="notion-text notion-block-374b7925fd2880d78164d409243d599f">...（省略更多内容）</div><div class="notion-text notion-block-374b7925fd2880d7bca5effbdb969b4c"><b>不太好的 description 示例</b>：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880209861f350d9385ffa" data-id="374b7925fd2880209861f350d9385ffa"><span><div id="374b7925fd2880209861f350d9385ffa" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880209861f350d9385ffa" title="9.2.3 Skill 的类型：reference vs task"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.2.3 Skill 的类型：reference vs task</span></span></h4><div class="notion-text notion-block-374b7925fd28803da450d8765074d0a5">这是 Skill 生态中最核心的概念之一。两种类型的设计目标不同：</div><table class="notion-simple-table notion-block-374b7925fd2880039203f166786da840"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd288066a9a9d588a1ebce32"><td class="" style="width:120px"><div class="notion-simple-table-cell">维度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">reference</code>（参考型）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">task</code>（任务型）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28806190c0c4e507107989"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>含义</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">返回操作指南给主 Agent，主 Agent 自己推理</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">启动独立 Sub-Crew，在沙盒中执行</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880f3b59de98e052eace2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>执行环境</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">主 Agent 的推理空间</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">独立的 AIO-Sandbox 沙盒</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880d0a81cea1c3b634ed2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>上下文</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">共享主 Agent 上下文</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">完全隔离，不感知主对话</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809b84d1ef9c08a572c3"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>开销</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">轻量，只是文本返回</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">较重，需要启动 Sub-Crew + MCP 通信</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288075a488e823d7d69c49"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>适用场景</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">信息型任务、需要主 Agent 综合判断</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">代码执行、文件处理、API 调用</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288012afd0de9acb116e23"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>示例</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">history_reader</code>（读取历史消息）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">pdf</code>、<code class="notion-inline-code">docx</code>、<code class="notion-inline-code">feishu_ops</code>、<code class="notion-inline-code">baidu_search</code></div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd288005bb59fe5f6675b892"><b>通俗理解</b>：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd288023bc15ffba66254b33"><li><code class="notion-inline-code">reference</code> 型 Skill = &quot;给你一本说明书，你自己看着办&quot;</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880509e55d07beb89bac3"><li><code class="notion-inline-code">task</code> 型 Skill = &quot;派一个专业工人去执行，你等着收结果就行&quot;</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288041812ee73f1d57530d" data-id="374b7925fd288041812ee73f1d57530d"><span><div id="374b7925fd288041812ee73f1d57530d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288041812ee73f1d57530d" title="9.2.4 load_skills.yaml — Skill 清单"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.2.4 load_skills.yaml — Skill 清单</span></span></h4><div class="notion-text notion-block-374b7925fd28809a93cbe2221b73ff5c"><code class="notion-inline-code">skills/load_skills.yaml</code> 是全局的 Skill 注册表，它告诉 SkillLoaderTool：<b>有哪些 Skill 可用、各自的类型是什么、是否启用</b>。</div><div class="notion-text notion-block-374b7925fd2880e991a2e55a657c6a54"><b>关键设计点</b>：</div><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880d08b13e68089efbeb9" style="list-style-type:decimal"><li><code class="notion-inline-code"><b>enabled</b></code><b> 字段</b>：可以临时关闭某个 Skill，不需要删除文件。比如某个 Skill 的 API Key 还没配置好，设 <code class="notion-inline-code">enabled: false</code> 即可。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd28809bb5e3c079ee6ed68f" style="list-style-type:decimal"><li><code class="notion-inline-code"><b>type</b></code><b> 字段</b>：决定 Skill 的执行方式，SkillLoaderTool 据此分流。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd288031a0fcefa1f3f08c38" style="list-style-type:decimal"><li><b>注释</b>：每个 Skill 的注释说明了为什么是 task 类型（需要代码执行），帮助维护者理解。</li></ol><div class="notion-text notion-block-374b7925fd2880a6bdabd5c04e66b8e6"><b>如何新增一个 Skill？</b> 只需三步：</div><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd288052b82df635adfdad66" style="list-style-type:decimal"><li>创建 <code class="notion-inline-code">skills/新Skill名/SKILL.md</code> 文件</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd2880d4a94cd0de408fe391" style="list-style-type:decimal"><li>在 <code class="notion-inline-code">load_skills.yaml</code> 中添加条目</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd28804eb7facd9b15f526b1" style="list-style-type:decimal"><li>重启 XiaoPaw，SkillLoaderTool 自动发现新 Skill</li></ol><hr class="notion-hr notion-block-374b7925fd28802caa78cf474d294a47"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28801296baf23905d11885" data-id="374b7925fd28801296baf23905d11885"><span><div id="374b7925fd28801296baf23905d11885" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28801296baf23905d11885" title="9.3 渐进式披露（Progressive Disclosure）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.3 渐进式披露（Progressive Disclosure）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880e8ad88f80d1104e5f7" data-id="374b7925fd2880e8ad88f80d1104e5f7"><span><div id="374b7925fd2880e8ad88f80d1104e5f7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880e8ad88f80d1104e5f7" title="9.3.1 设计原理——为什么分两阶段加载？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.3.1 设计原理——为什么分两阶段加载？</span></span></h4><div class="notion-text notion-block-374b7925fd288035b626e7fc8f8469e9">这是 SkillLoaderTool 最核心的设计模式。<b>渐进式披露</b> 的意思是：<b>只在需要时才暴露详细信息</b>。</div><div class="notion-text notion-block-374b7925fd28800ea0a9c2dc2362be85"><b>Token 预算分析</b>：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28807692d5e44abb8702d9" data-id="374b7925fd28807692d5e44abb8702d9"><span><div id="374b7925fd28807692d5e44abb8702d9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28807692d5e44abb8702d9" title="9.3.2 实现细节——_build_description() 方法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.3.2 实现细节——_build_description() 方法</span></span></h4><div class="notion-text notion-block-374b7925fd2880948cd4e4257cd7ecee">这是渐进式披露第一阶段的核心实现。它只读取 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 的 YAML frontmatter，构建一个轻量级的 XML 格式工具描述：</div><div class="notion-text notion-block-374b7925fd2880b48de0fa2f80621e31"><b>为什么用 XML 格式？</b></div><div class="notion-text notion-block-374b7925fd2880f0b3ecfc47fdb407b1">XML 格式对 LLM 来说结构清晰，标签明确（<code class="notion-inline-code">&lt;name&gt;</code>、<code class="notion-inline-code">&lt;type&gt;</code>、<code class="notion-inline-code">&lt;description&gt;</code>），LLM 能准确解析。相比之下，纯文本列表或 Markdown 表格可能被 LLM 误解格式。</div><div class="notion-text notion-block-374b7925fd2880d58088ce778e7a7055"><b>路径穿越防护</b>：</div><div class="notion-text notion-block-374b7925fd28802f889fc584e551e6c5">这段代码的作用是：如果有人恶意配置 <code class="notion-inline-code">name=&quot;../../etc&quot;</code>，<code class="notion-inline-code">resolve()</code> 会计算出实际路径，然后 <code class="notion-inline-code">startswith</code> 检查确保它仍然在 <code class="notion-inline-code">_SKILLS_DIR</code> 目录下。这是一个重要的安全防护。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288025b834fbf0ebe0e702" data-id="374b7925fd288025b834fbf0ebe0e702"><span><div id="374b7925fd288025b834fbf0ebe0e702" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288025b834fbf0ebe0e702" title="9.3.3 _extract_frontmatter_description() — 提取 frontmatter 中的 description"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.3.3 _extract_frontmatter_description() — 提取 frontmatter 中的 description</span></span></h4><div class="notion-text notion-block-374b7925fd2880b68c7cf77710352480"><b>通俗解释</b>：</div><div class="notion-text notion-block-374b7925fd2880449a05ec0e6a893d46">这个方法就像一个&quot;图书管理员&quot;——它只看书的封面（frontmatter），不打开书的内容（Markdown 正文）。这样就节省了时间和资源。</div><hr class="notion-hr notion-block-374b7925fd288037975dc7888f44ab5e"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880788fced331e9e5dc72" data-id="374b7925fd2880788fced331e9e5dc72"><span><div id="374b7925fd2880788fced331e9e5dc72" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880788fced331e9e5dc72" title="9.4 SkillLoaderTool 实现详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.4 SkillLoaderTool 实现详解</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28808d9039dc3d643b1ae5" data-id="374b7925fd28808d9039dc3d643b1ae5"><span><div id="374b7925fd28808d9039dc3d643b1ae5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28808d9039dc3d643b1ae5" title="9.4.1 类结构总览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.4.1 类结构总览</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28800d8aa9f48cc3adfcf8" data-id="374b7925fd28800d8aa9f48cc3adfcf8"><span><div id="374b7925fd28800d8aa9f48cc3adfcf8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28800d8aa9f48cc3adfcf8" title="9.4.2 PrivateAttr —— 为什么有些属性要用 PrivateAttr？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.4.2 PrivateAttr —— 为什么有些属性要用 PrivateAttr？</span></span></h4><div class="notion-text notion-block-374b7925fd2880f18f29cdbc3fcc65a1">这是 CrewAI <code class="notion-inline-code">BaseTool</code> 的一个重要机制。让我们用一个表格来对比：</div><table class="notion-simple-table notion-block-374b7925fd288008b6f7eb40d40b1444"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880dfa17af5e1f85acba7"><td class="" style="width:120px"><div class="notion-simple-table-cell">属性类型</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">行为</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">用途</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880d38e48f450c0ed75a5"><td class="" style="width:120px"><div class="notion-simple-table-cell">普通属性</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">被 CrewAI 序列化，传给 LLM</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具的名称、描述、参数 Schema</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880bd9301edb3041c226f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">PrivateAttr</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">只在 Python 代码中使用，<b>不</b>传递给 LLM</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">内部状态、会话 ID、凭据、缓存</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd2880488101dbe3847b9d39"><b>为什么 session_id 不能暴露给 LLM？</b></div><div class="notion-text notion-block-374b7925fd2880638941db2419fd126e"><code class="notion-inline-code"><b>_skill_registry</b></code><b> 和 </b><code class="notion-inline-code"><b>_instruction_cache</b></code><b> 为什么也是 PrivateAttr？</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28800db037f1a5577605f2" data-id="374b7925fd28800db037f1a5577605f2"><span><div id="374b7925fd28800db037f1a5577605f2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28800db037f1a5577605f2" title="9.4.3 init 方法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.4.3 <b>init</b> 方法</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880718fe8daa927b0adc6" data-id="374b7925fd2880718fe8daa927b0adc6"><span><div id="374b7925fd2880718fe8daa927b0adc6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880718fe8daa927b0adc6" title="9.4.4 输入输出模型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.4.4 输入输出模型</span></span></h4><div class="notion-text notion-block-374b7925fd288079be43fcb578aa1763"><code class="notion-inline-code"><b>field_validator</b></code><b> 的作用</b>：</div><div class="notion-text notion-block-374b7925fd288024b61df7d01da85bc9">通俗地说，这个 validator 就像一个&quot;翻译官&quot;。LLM 可能会传 <code class="notion-inline-code">task_context={&quot;page&quot;: 1}</code>（一个 dict），但我们的 Schema 定义的是 <code class="notion-inline-code">str</code> 类型。validator 在 Pydantic 校验之前自动把 dict 转成 <code class="notion-inline-code">&#x27;{&quot;page&quot;: 1}&#x27;</code> 字符串，这样就不会报错了。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880b18806cae9e0fb6087" data-id="374b7925fd2880b18806cae9e0fb6087"><span><div id="374b7925fd2880b18806cae9e0fb6087" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880b18806cae9e0fb6087" title="9.4.5 _get_skill_instructions() — 渐进式披露第二阶段"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.4.5 _get_skill_instructions() — 渐进式披露第二阶段</span></span></h4><div class="notion-text notion-block-374b7925fd288080a388ee504ca9db51">当 LLM 决定调用某个 Skill 时，SkillLoaderTool 需要加载完整的 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 内容。这个方法就是渐进式披露第二阶段的核心：</div><div class="notion-text notion-block-374b7925fd2880bf9eb9fedad0758e97"><b>关键设计点总结</b>：</div><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd28803db29bd54820b21b20" style="list-style-type:decimal"><li><b>缓存机制</b>：<code class="notion-inline-code">_instruction_cache</code> 避免同一 Skill 重复读取文件</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd288098b2f0e6294b450bf9" style="list-style-type:decimal"><li><b>路径占位符替换</b>：<code class="notion-inline-code">{skill_base}</code> → 实际的沙盒路径，让 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 可以在不同环境复用</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880e1b54ad8f29642229e" style="list-style-type:decimal"><li><b>花括号转义</b>：<code class="notion-inline-code">{</code> → <code class="notion-inline-code">{{</code>，防止 CrewAI 模板变量冲突</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd2880809acdd9f00f7f7dc0" style="list-style-type:decimal"><li><b>sandbox_execution_directive</b>：附加沙盒执行指令，告诉 Sub-Crew Agent 如何使用工具</li></ol><hr class="notion-hr notion-block-374b7925fd288065aa43f43be0d399b2"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28804d9a4eff5ad22d3a6b" data-id="374b7925fd28804d9a4eff5ad22d3a6b"><span><div id="374b7925fd28804d9a4eff5ad22d3a6b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28804d9a4eff5ad22d3a6b" title="9.5 三种处理类型详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.5 三种处理类型详解</span></span></h3><div class="notion-text notion-block-374b7925fd288099976ed7b980ee6045">当 LLM 调用 SkillLoaderTool 时，<code class="notion-inline-code">_execute_skill_async()</code> 方法会根据 Skill 的类型进行分流：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880f2a356ded9bf37c4e4" data-id="374b7925fd2880f2a356ded9bf37c4e4"><span><div id="374b7925fd2880f2a356ded9bf37c4e4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880f2a356ded9bf37c4e4" title="9.5.1 reference 型 — 返回指令文本"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.5.1 reference 型 — 返回指令文本</span></span></h4><div class="notion-text notion-block-374b7925fd2880f09882e50ad6cb7782"><b>通俗解释</b>：reference 型 Skill 就像&quot;给你一本菜谱&quot;。主 Agent 拿到菜谱后，自己理解步骤，自己决定怎么做。不需要派一个专业厨师（Sub-Crew）去执行。</div><div class="notion-text notion-block-374b7925fd28804481cbd5635e820807"><b>适用场景</b>：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd2880c49d6cdeb46382a944"><li>信息型 Skill，如 <code class="notion-inline-code">history_reader</code></li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28804e834fe6afc3239b58"><li>需要主 Agent 综合判断的复杂决策流程</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880a68926fe42794a5b54"><li>操作指南长度适中，不会压满上下文窗口</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28807a814ce5ccca2dccc1" data-id="374b7925fd28807a814ce5ccca2dccc1"><span><div id="374b7925fd28807a814ce5ccca2dccc1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28807a814ce5ccca2dccc1" title="9.5.2 task 型 — 启动 Sub-Crew"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.5.2 task 型 — 启动 Sub-Crew</span></span></h4><div class="notion-text notion-block-374b7925fd2880409ff9cd49a1023fd3"><b>通俗解释</b>：task 型 Skill 就像&quot;叫一个专业服务&quot;。比如你要处理 PDF，你自己不会，就叫一个&quot;PDF 处理专家&quot;（Sub-Crew）来帮你做。这个专家有自己的工具（沙盒 MCP 工具），做完后把结果告诉你。</div><div class="notion-text notion-block-374b7925fd288069b6e1dc69745340be"><b>关键点</b>：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd28807da989e6855e595019"><li>每次 <code class="notion-inline-code">build_skill_crew()</code> 返回<b>新实例</b>，防止状态污染</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28808f9e8ad25d7aeaa08e"><li>Sub-Crew 在独立的沙盒中执行，与主 Agent 完全隔离</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd288065b92fffacba47608d"><li>Sub-Crew 的结果通过 <code class="notion-inline-code">akickoff()</code> 返回给主 Agent</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880d494bee23e15676666" data-id="374b7925fd2880d494bee23e15676666"><span><div id="374b7925fd2880d494bee23e15676666" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880d494bee23e15676666" title="9.5.3 history_reader — 特殊内联处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.5.3 history_reader — 特殊内联处理</span></span></h4><div class="notion-text notion-block-374b7925fd2880709bbafe302bf17ed9"><code class="notion-inline-code">history_reader</code> 是一个特殊的 Skill：它虽然是 reference 型，但不需要从 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 读取指令，而是<b>直接在 SkillLoaderTool 内部从内存中读取历史消息</b>。</div><div class="notion-text notion-block-374b7925fd28807b8493d8af8e6b42a3"><b>为什么 history_reader 要特殊处理？</b></div><table class="notion-simple-table notion-block-374b7925fd2880c184c0e771d8167d28"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880439c5cc0409a1f56b4"><td class="" style="width:120px"><div class="notion-simple-table-cell">原因</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">说明</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288043bc8fce683b1d31b2"><td class="" style="width:120px"><div class="notion-simple-table-cell">不需要沙盒</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">只是内存中的列表切片操作，不涉及文件系统或代码执行</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288055a411f8f43947842c"><td class="" style="width:120px"><div class="notion-simple-table-cell">避免网络开销</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不启动 Sub-Crew，不需要 MCP 协议通信，响应更快</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28802190d8e50cb026e9a2"><td class="" style="width:120px"><div class="notion-simple-table-cell">安全性</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">历史消息包含用户隐私数据，不应传入沙盒环境</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880aa8c62eb07a1e3eb69"><td class="" style="width:120px"><div class="notion-simple-table-cell">可靠性</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">减少中间环节，降低出错概率</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880bd803ced8d6e5ddc7a" data-id="374b7925fd2880bd803ced8d6e5ddc7a"><span><div id="374b7925fd2880bd803ced8d6e5ddc7a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880bd803ced8d6e5ddc7a" title="9.5.4 三种处理类型对比"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.5.4 三种处理类型对比</span></span></h4><hr class="notion-hr notion-block-374b7925fd2880078828d856526d9984"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880a39808dee2a4e565bf" data-id="374b7925fd2880a39808dee2a4e565bf"><span><div id="374b7925fd2880a39808dee2a4e565bf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a39808dee2a4e565bf" title="9.6 SKILL.md 模板变量安全"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.6 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 模板变量安全</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288081b872c0c0c916588d" data-id="374b7925fd288081b872c0c0c916588d"><span><div id="374b7925fd288081b872c0c0c916588d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288081b872c0c0c916588d" title="9.6.1 问题描述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.6.1 问题描述</span></span></h4><div class="notion-text notion-block-374b7925fd2880d08b5edfabcfa5cff2">CrewAI 框架使用 <code class="notion-inline-code">{var}</code> 语法进行模板变量替换。当 CrewAI 加载 Agent 的 backstory 或 Task 的 description 时，会自动扫描所有 <code class="notion-inline-code">{变量名}</code> 格式的占位符，然后在 <code class="notion-inline-code">akickoff(inputs={...})</code> 中查找对应的值。</div><div class="notion-text notion-block-374b7925fd28802d9161c47098c78275"><b>问题来了</b>：<a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 中可能包含代码示例，比如：</div><div class="notion-text notion-block-374b7925fd2880c3aaf8d55753e2063d">如果 CrewAI 发现 <code class="notion-inline-code">{name}</code> 但没有在 <code class="notion-inline-code">inputs</code> 中提供对应的值，就会报错：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288046acc6f5ce2052f7f4" data-id="374b7925fd288046acc6f5ce2052f7f4"><span><div id="374b7925fd288046acc6f5ce2052f7f4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288046acc6f5ce2052f7f4" title="9.6.2 解决方案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.6.2 解决方案</span></span></h4><div class="notion-text notion-block-374b7925fd2880128a30cf965f171850">分两步走：</div><div class="notion-text notion-block-374b7925fd2880e49d04dc4126bff887"><b>第一步：转义花括号</b></div><div class="notion-text notion-block-374b7925fd2880998d33d72fe07f2e14"><b>第二步：注入自映射变量</b></div><div class="notion-text notion-block-374b7925fd2880d6becef9263403d139"><b>完整流程图</b>：</div><div class="notion-text notion-block-374b7925fd2880bab612db5230f2ee0c"><b>通俗解释</b>：</div><div class="notion-text notion-block-374b7925fd28802fa615ff73bf2a56ee">这就像&quot;套娃&quot;——先把 <code class="notion-inline-code">{</code> 变成 <code class="notion-inline-code">{{</code>（告诉 CrewAI &quot;这是文本，别替换&quot;），然后为了防止 CrewAI 的扫描器仍然报错，主动告诉它&quot;这些变量都存在，值就是它们自己&quot;，这样 CrewAI 就不会报错了。</div><hr class="notion-hr notion-block-374b7925fd2880fd84b4c8face908d39"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880609359c28fd066a0c6" data-id="374b7925fd2880609359c28fd066a0c6"><span><div id="374b7925fd2880609359c28fd066a0c6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880609359c28fd066a0c6" title="9.7 异步双通道 — _arun 与 _run"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.7 异步双通道 — _arun 与 _run</span></span></h3><div class="notion-text notion-block-374b7925fd2880eeab86cc90c63b1353">CrewAI 的 <code class="notion-inline-code">BaseTool</code> 支持两种调用方式：异步 <code class="notion-inline-code">_arun()</code> 和同步 <code class="notion-inline-code">_run()</code>。SkillLoaderTool 同时实现了两者，确保在不同场景下都能正常工作。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880fba251e40e8fd097cf" data-id="374b7925fd2880fba251e40e8fd097cf"><span><div id="374b7925fd2880fba251e40e8fd097cf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880fba251e40e8fd097cf" title="9.7.1 异步路径 _arun()"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.7.1 异步路径 _arun()</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880078e46f5004dacdf6d" data-id="374b7925fd2880078e46f5004dacdf6d"><span><div id="374b7925fd2880078e46f5004dacdf6d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880078e46f5004dacdf6d" title="9.7.2 同步路径 _run()"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.7.2 同步路径 _run()</span></span></h4><div class="notion-text notion-block-374b7925fd2880af8f67cf3c978fffa1"><b>为什么需要两个通道？</b></div><hr class="notion-hr notion-block-374b7925fd288017931fc4efb0977768"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880fe84e1f5b760780145" data-id="374b7925fd2880fe84e1f5b760780145"><span><div id="374b7925fd2880fe84e1f5b760780145" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880fe84e1f5b760780145" title="9.8 完整调用流程 — 端到端走一遍"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.8 完整调用流程 — 端到端走一遍</span></span></h3><div class="notion-text notion-block-374b7925fd2880ba929ef0b260023c9c">让我们用一个具体的例子来走一遍完整的调用流程：</div><div class="notion-text notion-block-374b7925fd28803e8212faabc4d49b61"><b>场景</b>：用户在飞书中说&quot;帮我分析这个 PDF 文件的内容&quot;</div><hr class="notion-hr notion-block-374b7925fd28809ca33af25c4da3836e"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880cc9176f94a77f029a0" data-id="374b7925fd2880cc9176f94a77f029a0"><span><div id="374b7925fd2880cc9176f94a77f029a0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880cc9176f94a77f029a0" title="9.9 本章小结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.9 本章小结</span></span></h3><div class="notion-text notion-block-374b7925fd2880fb996dd8612310c794">本章我们深入学习了 XiaoPaw 的 Skills 生态系统和 SkillLoaderTool 的实现。核心要点回顾：</div><table class="notion-simple-table notion-block-374b7925fd2880998766fa7cd29b474b"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd28806f857fe94dc8fa76a4"><td class="" style="width:120px"><div class="notion-simple-table-cell">知识点</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心内容</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880cf870bc702964c7b48"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Skill 定义</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> = YAML frontmatter（元数据）+ Markdown 正文（操作指南）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880cf9502df796dcb7cef"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Skill 类型</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">reference</code>（返回指令，轻量）vs <code class="notion-inline-code">task</code>（启动 Sub-Crew，重量）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28800ab12df4110e582e09"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>渐进式披露</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">阶段 0：只加载 frontmatter 的 description（~50 字符/Skill）；阶段 1：按需加载完整 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880ce8d11d5aad1ef71cb"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>SkillLoaderTool</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">主 Agent 的唯一工具，负责 Skill 发现、加载、分流</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288044b4faf5dec34bbbaf"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>PrivateAttr</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">会话 ID、沙盒 URL 等敏感信息不暴露给 LLM</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28801a90f5ed8966a018e9"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>三种处理</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">reference（返回指令）、task（启动 Sub-Crew）、history_reader（内联分页）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28802088f0fd1220dcca1e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>模板变量安全</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">{</code> → <code class="notion-inline-code">{{</code> 转义 + 自映射注入，防止 CrewAI 报错</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288090b6dec333bbbf7c5f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>异步双通道</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">_arun()</code>（异步路径，直接 await） + <code class="notion-inline-code">_run()</code>（同步路径，ThreadPoolExecutor）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28801fb57ec8f82ada1497"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>路径穿越防护</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">resolve()</code> + <code class="notion-inline-code">startswith()</code> 确保 Skill 路径在允许的目录内</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd2880f08a59f3ce79f06464"><b>设计哲学</b>：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd2880b98841c37ad9f9ac40"><li><b>极简主 Agent</b>：主 Agent 只有一个工具（SkillLoaderTool），所有能力通过 Skill 扩展</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880b08633e18c8e13a774"><li><b>渐进式披露</b>：按需加载，不浪费 token</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28809491c0c793eae52027"><li><b>安全第一</b>：PrivateAttr 保护敏感信息，路径穿越防护，沙盒隔离</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880b7b49ed2fddecdbcbd"><li><b>可扩展性</b>：新增 Skill 只需添加 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 文件 + 更新 load_skills.yaml</li></ul><hr class="notion-hr notion-block-374b7925fd2880999981c3056dd079be"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880b0929ffbef937a99c2" data-id="374b7925fd2880b0929ffbef937a99c2"><span><div id="374b7925fd2880b0929ffbef937a99c2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880b0929ffbef937a99c2" title="9.10 练习与思考"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.10 练习与思考</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd28801b9cd8f368140fa8c9" style="list-style-type:decimal"><li><b>新增一个 Skill</b>：尝试创建一个名为 <code class="notion-inline-code">hello_world</code> 的 task 型 Skill，让它能接收用户的名字并返回问候语。需要：</li><ol class="notion-list notion-list-numbered notion-block-374b7925fd28801b9cd8f368140fa8c9" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-374b7925fd2880598824eaf583fd6ea5"><li>创建 <code class="notion-inline-code">skills/hello_world/SKILL.md</code></li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880329b0bed8658e05363"><li>在 <code class="notion-inline-code">load_skills.yaml</code> 中注册</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880e6b45ed12790239425"><li>理解 SkillLoaderTool 如何发现和加载它</li></ul></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd2880d9846bfa26c95120cf" style="list-style-type:decimal"><li><b>对比 reference 和 task</b>：<code class="notion-inline-code">history_reader</code> 是 reference 型，但如果把它改成 task 型会有什么不同？分析两种方式的优缺点。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880e2968fd363263dae83" style="list-style-type:decimal"><li><b>模板变量问题</b>：如果 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 中有 <code class="notion-inline-code">{user_name}</code> 这样的占位符，当前的转义机制会把它变成什么？最终 Sub-Crew 看到的是什么？</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd288038b2c3d764216bcfdc" style="list-style-type:decimal"><li><b>路径安全</b>：如果 <code class="notion-inline-code">load_skills.yaml</code> 中配置了 <code class="notion-inline-code">name: &quot;../../etc&quot;</code>，SkillLoaderTool 会如何处理？画出代码执行路径。</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-374b7925fd288070be79d854aea19cd6" style="list-style-type:decimal"><li><b>渐进式披露的 token 节省</b>：假设有 10 个 Skill，每个 <a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a> 平均 3000 字符。计算渐进式披露相比全量加载节省了多少 token（假设 1 token ≈ 4 字符）。</li></ol><div class="notion-text notion-block-374b7925fd288072a30ec140775dc707">下一章将详细介绍每个 Skill 的具体实现——包括文件处理、飞书操作、搜索、网页浏览等。</div><div class="notion-blank notion-block-374b7925fd2880f5adc5d0ac7baedc35"> </div><hr class="notion-hr notion-block-374b7925fd2880dfaac0e2a67d27edb6"/><div class="notion-blank notion-block-374b7925fd28807bbc45ed947b674c21"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-374b7925fd2880fb83e3fd0933512ecb" data-id="374b7925fd2880fb83e3fd0933512ecb"><span><div id="374b7925fd2880fb83e3fd0933512ecb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880fb83e3fd0933512ecb" title="第10章：Skill 详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第10章：Skill 详解</span></span></h2><blockquote class="notion-quote notion-block-374b7925fd288063ad07d72b9e637a8e"><div>本章目标：逐一深入分析每个 Skill 的设计目的、操作规范、脚本架构和实现细节。通过本章学习，你将理解每个 Skill 是如何独立工作、如何与沙盒互动、以及如何通过统一的输出规范与主 Agent 通信的。</div><div class="notion-text notion-block-374b7925fd288093b48dccdb2940c38d">对应目录：<a class="notion-link" href="https://www.notion.so/xiaopaw/skills/" target="_blank" rel="noopener noreferrer">xiaopaw/skills/</a></div></blockquote><hr class="notion-hr notion-block-374b7925fd2880e4bf6dc48b21755483"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28806989e9d30d8e5854d1" data-id="374b7925fd28806989e9d30d8e5854d1"><span><div id="374b7925fd28806989e9d30d8e5854d1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28806989e9d30d8e5854d1" title="10.1 分类总览与设计哲学"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.1 分类总览与设计哲学</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880c2913ae6e8179e3813" data-id="374b7925fd2880c2913ae6e8179e3813"><span><div id="374b7925fd2880c2913ae6e8179e3813" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c2913ae6e8179e3813" title="10.1.1 九大 Skill 一览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.1.1 九大 Skill 一览</span></span></h4><table class="notion-simple-table notion-block-374b7925fd2880cead8ec5470093515e"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880fabe34e4cf1cbbc72a"><td class="" style="width:120px"><div class="notion-simple-table-cell">Skill</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">类型</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">使用沙盒</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">脚本语言</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心能力</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880349b48ca53a7937067"><td class="" style="width:120px"><div class="notion-simple-table-cell">pdf</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Python</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">PDF 文本提取、合并、拆分、旋转、元数据读取</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288087bd69fecb00672a80"><td class="" style="width:120px"><div class="notion-simple-table-cell">docx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Python</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Word 文档创建、读取、编辑</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880dd9b1afd7f18c10fab"><td class="" style="width:120px"><div class="notion-simple-table-cell">pptx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Python</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">PowerPoint 文本提取</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880d881dac6d536b5b8b1"><td class="" style="width:120px"><div class="notion-simple-table-cell">xlsx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Python</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Excel 数据分析、读写、图表</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288069adb4c0c08fefad74"><td class="" style="width:120px"><div class="notion-simple-table-cell">feishu_ops</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Python</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">飞书消息发送、文档读取、日历管理、多维表格</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28806da50af754cee37fa9"><td class="" style="width:120px"><div class="notion-simple-table-cell">scheduler_mgr</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Python</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定时任务的创建/查看/更新/删除</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880739525e5f43bec6fc4"><td class="" style="width:120px"><div class="notion-simple-table-cell">baidu_search</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Python</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">百度千帆网页搜索</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880868f10f33e374a70ef"><td class="" style="width:120px"><div class="notion-simple-table-cell">web_browse</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">task</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">MCP 工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">网页抓取与浏览器自动化</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28803fb0bddb52889ba8fd"><td class="" style="width:120px"><div class="notion-simple-table-cell">history_reader</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">reference</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无（内联）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">对话历史按页读取</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28807c9a52f48ff0d1cd5a" data-id="374b7925fd28807c9a52f48ff0d1cd5a"><span><div id="374b7925fd28807c9a52f48ff0d1cd5a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28807c9a52f48ff0d1cd5a" title="10.1.2 设计哲学"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.1.2 设计哲学</span></span></h4><div class="notion-text notion-block-374b7925fd2880dcb909dad2115d4387">每个 Skill 都遵循以下设计原则：</div><hr class="notion-hr notion-block-374b7925fd28805f9806fd94d0d0900d"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28809ca031c8b84db462eb" data-id="374b7925fd28809ca031c8b84db462eb"><span><div id="374b7925fd28809ca031c8b84db462eb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809ca031c8b84db462eb" title="10.2 文件处理 Skills"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.2 文件处理 Skills</span></span></h3><div class="notion-text notion-block-374b7925fd2880c88561c0ae00b467f8">文件处理是 XiaoPaw 最基础的能力之一。当用户在飞书中上传 PDF、Word、Excel 或 PowerPoint 文件时，对应的 Skill 会被触发。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28801ca3a5d61b26995f05" data-id="374b7925fd28801ca3a5d61b26995f05"><span><div id="374b7925fd28801ca3a5d61b26995f05" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28801ca3a5d61b26995f05" title="10.2.1 pdf — PDF 文本提取与处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.2.1 pdf — PDF 文本提取与处理</span></span></h4><div class="notion-text notion-block-374b7925fd2880158b04cf3fe59e7dd2"><b>Skill 定义</b>：</div><div class="notion-text notion-block-374b7925fd28801a8c70fda023aa16b1"><b>通俗理解</b>：PDF Skill 就像你的&quot;PDF 全能助手&quot;。你给它一个 PDF 文件，它能帮你提取文字、拆分页面、合并多个文件、旋转页面、提取表格等。</div><div class="notion-text notion-block-374b7925fd2880e298f5f14071cdafcc"><b><a class="notion-link" href="http://skill.md/" target="_blank" rel="noopener noreferrer">SKILL.md</a></b><b> 中的核心操作指南</b>：</div><div class="notion-text notion-block-374b7925fd288020aacfc1322c22d236"><b>使用的 Python 库</b>：</div><table class="notion-simple-table notion-block-374b7925fd28804e964cf86a67d4dd36"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880c899ede8cdb2dd22aa"><td class="" style="width:120px"><div class="notion-simple-table-cell">库</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">用途</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">为什么选择它</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288088939fe3835e954b31"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">pypdf</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">基础操作：读取、合并、拆分、旋转、元数据</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">纯 Python 实现，无外部依赖，安装简单</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28800788a0dce5366de08c"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">pdfplumber</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">高级操作：精确文本提取、表格提取</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">比 pypdf 的文本提取更准确，特别是复杂布局</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd288041ad2dc996074e15c5"><b>为什么需要两个库？</b></div><div class="notion-text notion-block-374b7925fd288059aa91ead32b0fb398">pypdf 适合&quot;编辑&quot;操作（合并、拆分、旋转），pdfplumber 适合&quot;提取&quot;操作（文字、表格）。两者互补，覆盖了常见的 PDF 处理需求。</div><div class="notion-text notion-block-374b7925fd288057b207fc1c914565b6"><b>注意事项</b>：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd28807d868ccfee78f08ea3"><li>加密 PDF 需要密码才能处理</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880a7a6afed812d7e32d8"><li>扫描版 PDF（图片）需要 OCR 才能提取文字</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880b49756e7e4b78de5af"><li>大文件（&gt;100MB）处理可能较慢</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880258f1dd8114ae3f3e5" data-id="374b7925fd2880258f1dd8114ae3f3e5"><span><div id="374b7925fd2880258f1dd8114ae3f3e5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880258f1dd8114ae3f3e5" title="10.2.2 docx — Word 文档处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.2.2 docx — Word 文档处理</span></span></h4><div class="notion-text notion-block-374b7925fd28808c996ce1f43bf256a5"><b>Skill 定义</b>：</div><div class="notion-text notion-block-374b7925fd2880918e3de439ab245c2f"><b>通俗理解</b>：DOCX Skill 就像你的&quot;Word 助手&quot;。它能读取 Word 文档的内容，也能根据你的需求创建新的 Word 文档。</div><div class="notion-text notion-block-374b7925fd288067b049fce5fafaf77f"><b>核心操作</b>：</div><div class="notion-text notion-block-374b7925fd2880f2b83ff4c7618eff3e"><b>python-docx 库的核心概念</b>：</div><table class="notion-simple-table notion-block-374b7925fd2880cca35bd798cd2f7aed"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd28800e8195cf4dce80bfa6"><td class="" style="width:120px"><div class="notion-simple-table-cell">概念</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">对应 Word 中的...</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">代码操作</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880889705cf01de137c54"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Document</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">整个 Word 文件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">doc = Document(path)</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880a69d32e0720bddaebd"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Paragraph</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">一个段落</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">doc.add_paragraph(&quot;text&quot;)</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28803784c2d558e9d6df16"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Run</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">段落中的一段文字（相同格式）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">run = para.add_run(&quot;text&quot;)</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288085ac27e070594b2f49"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Table</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">表格</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">doc.add_table(rows, cols)</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880c3a125e74176e5e26a"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Heading</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">标题（1-9 级）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">doc.add_heading(&quot;title&quot;, level=1)</code></div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28800cbaa9e36d92f2c646" data-id="374b7925fd28800cbaa9e36d92f2c646"><span><div id="374b7925fd28800cbaa9e36d92f2c646" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28800cbaa9e36d92f2c646" title="10.2.3 pptx — PowerPoint 处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.2.3 pptx — PowerPoint 处理</span></span></h4><div class="notion-text notion-block-374b7925fd2880518070c4f0abe2ecca"><b>Skill 定义</b>：</div><div class="notion-text notion-block-374b7925fd288074982fe673a366c71d"><b>通俗理解</b>：PPTX Skill 能帮你读取 PowerPoint 文件中的文字内容，提取每张幻灯片的标题和正文。</div><div class="notion-text notion-block-374b7925fd28808eb8efe7e52e962290"><b>python-pptx 的核心概念</b>：</div><table class="notion-simple-table notion-block-374b7925fd2880bf93bcd3243508aa1c"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd288088a6e9d49f6523bfb3"><td class="" style="width:120px"><div class="notion-simple-table-cell">概念</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">代码</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288028b32bd6dda4fbe009"><td class="" style="width:120px"><div class="notion-simple-table-cell">整个 PPT 文件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">prs = Presentation(path)</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880a48778de69ef3f82bb"><td class="" style="width:120px"><div class="notion-simple-table-cell">一张幻灯片</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">slide = prs.slides[i]</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880ffaf23c2f2b6b0813e"><td class="" style="width:120px"><div class="notion-simple-table-cell">幻灯片上的元素</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">shape = slide.shapes[j]</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288040a1cdd72a2cf3d917"><td class="" style="width:120px"><div class="notion-simple-table-cell">文本框</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">shape.text_frame</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288011855aeb1172d1b822"><td class="" style="width:120px"><div class="notion-simple-table-cell">段落</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">shape.text_frame.paragraphs</code></div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288087a6a1f7092b279a2b" data-id="374b7925fd288087a6a1f7092b279a2b"><span><div id="374b7925fd288087a6a1f7092b279a2b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288087a6a1f7092b279a2b" title="10.2.4 xlsx — Excel 数据处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.2.4 xlsx — Excel 数据处理</span></span></h4><div class="notion-text notion-block-374b7925fd2880488f7ad9a4a44cdef3"><b>Skill 定义</b>：</div><div class="notion-text notion-block-374b7925fd2880288255d4d40f2915fc"><b>通俗理解</b>：XLSX Skill 是你的&quot;Excel 数据分析师&quot;。它能读取 Excel 文件中的数据，进行筛选、排序、统计，并生成新的 Excel 文件。</div><div class="notion-text notion-block-374b7925fd2880218c8fd8f4eea13036"><b>为什么用 pandas？</b></div><div class="notion-text notion-block-374b7925fd288018b433c7bb5e7c257d">pandas 是 Python 最强大的数据分析库。相比直接用 openpyxl 操作单元格，pandas 提供的&quot;DataFrame&quot;概念（类似 Excel 的表格视图）让数据分析更加直观和高效。</div><hr class="notion-hr notion-block-374b7925fd2880f6bf1bde5e5699f95f"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880498375f7e7fc00d38f" data-id="374b7925fd2880498375f7e7fc00d38f"><span><div id="374b7925fd2880498375f7e7fc00d38f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880498375f7e7fc00d38f" title="10.3 feishu_ops — 飞书操作"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.3 feishu_ops — 飞书操作</span></span></h3><div class="notion-text notion-block-374b7925fd2880c798b7d8d0e5d4c380">这是 XiaoPaw 最核心也是功能最丰富的 Skill，它让 Sub-Crew 能够直接与飞书平台交互——发送消息、读取文档、管理日历等。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288077a5b2dba99e8f6a1b" data-id="374b7925fd288077a5b2dba99e8f6a1b"><span><div id="374b7925fd288077a5b2dba99e8f6a1b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288077a5b2dba99e8f6a1b" title="10.3.1 脚本架构总览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.3.1 脚本架构总览</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288058a8fac4c1a38598e2" data-id="374b7925fd288058a8fac4c1a38598e2"><span><div id="374b7925fd288058a8fac4c1a38598e2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288058a8fac4c1a38598e2" title="10.3.2 共享认证模块 _feishu_auth.py"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.3.2 共享认证模块 _feishu_auth.py</span></span></h4><div class="notion-text notion-block-374b7925fd2880649a25c9ffacde9190">这是 feishu_ops 所有脚本的&quot;地基&quot;。每个脚本都通过 <code class="notion-inline-code">import _feishu_auth as auth</code> 引用它，获取飞书 API 的认证 Token 和通用工具函数。</div><div class="notion-text notion-block-374b7925fd28809fa935c386d7d8eace"><b>为什么需要一个共享模块？</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288080838aeb3d2afc5b0b" data-id="374b7925fd288080838aeb3d2afc5b0b"><span><div id="374b7925fd288080838aeb3d2afc5b0b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288080838aeb3d2afc5b0b" title="10.3.3 消息发送脚本"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.3.3 消息发送脚本</span></span></h4><div class="notion-text notion-block-374b7925fd288082a376e262a14c43a3"><b>send_text.py — 发送纯文字消息</b></div><div class="notion-text notion-block-374b7925fd28806ebff5ffcfc71371b9">这是最基础的消息发送脚本，也是理解其他脚本的起点：</div><div class="notion-text notion-block-374b7925fd2880a98954d57f33ea28bb"><b>参数说明</b>：</div><table class="notion-simple-table notion-block-374b7925fd2880f6aee7d133a670cf2a"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd28801e9758e27554ebc368"><td class="" style="width:120px"><div class="notion-simple-table-cell">参数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">必填</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">说明</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">示例</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28807797aec00412832bb8"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">--routing_key</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">目标路由键，标识消息发给谁</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">p2p:ou_abc123</code>（私聊）、<code class="notion-inline-code">group:oc_xyz789</code>（群组）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880a089b7e06a48cf0afe"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">--text</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">消息文本内容</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">&quot;你好，这是定时报告&quot;</code></div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd2880be93cfd34bf7f9f64d"><b>send_image.py — 发送图片消息</b></div><div class="notion-text notion-block-374b7925fd2880b5894ccc0d8efe9d53">发送图片比发送文字多一步：先上传图片获取 <code class="notion-inline-code">image_key</code>，再用 <code class="notion-inline-code">image_key</code> 发送图片消息。</div><div class="notion-text notion-block-374b7925fd2880338958fd37fdd00258"><b>send_file.py — 发送文件消息</b></div><div class="notion-text notion-block-374b7925fd2880239f91c0f3e3eafc93">这是处理结果回传的<b>核心场景</b>。用户上传文件 → Skill 处理 → 结果保存到 <code class="notion-inline-code">outputs/</code> → 调用 send_file.py 将结果发回给用户。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28808dbe18c56ee84d07a9" data-id="374b7925fd28808dbe18c56ee84d07a9"><span><div id="374b7925fd28808dbe18c56ee84d07a9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28808dbe18c56ee84d07a9" title="10.3.4 文档读取脚本"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.3.4 文档读取脚本</span></span></h4><div class="notion-text notion-block-374b7925fd28809ea645e3ebe28a9c9d"><b>read_doc.py — 读取飞书文档</b></div><div class="notion-text notion-block-374b7925fd2880518634ef21f1d3276b"><b>read_sheet.py — 读取飞书电子表格</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880cdb86ce8df12f56f59" data-id="374b7925fd2880cdb86ce8df12f56f59"><span><div id="374b7925fd2880cdb86ce8df12f56f59" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880cdb86ce8df12f56f59" title="10.3.5 所有脚本的统一设计模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.3.5 所有脚本的统一设计模式</span></span></h4><div class="notion-text notion-block-374b7925fd2880b4a728fc6f8c79ff90">总结 feishu_ops 所有 16 个脚本的共同模式：</div><hr class="notion-hr notion-block-374b7925fd2880b3a4c3cd34bec9d38d"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28804d9411c13388936f4a" data-id="374b7925fd28804d9411c13388936f4a"><span><div id="374b7925fd28804d9411c13388936f4a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28804d9411c13388936f4a" title="10.4 baidu_search — 百度搜索"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.4 baidu_search — 百度搜索</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880e595bad26decfca182" data-id="374b7925fd2880e595bad26decfca182"><span><div id="374b7925fd2880e595bad26decfca182" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880e595bad26decfca182" title="10.4.1 Skill 概述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.4.1 Skill 概述</span></span></h4><div class="notion-text notion-block-374b7925fd288036af17c75f153a704b"><b>通俗理解</b>：baidu_search Skill 是 XiaoPaw 的&quot;搜索引擎&quot;。当用户问&quot;最近有什么新闻&quot;、&quot;Python 最新版本是什么&quot;这类需要实时信息的问题时，这个 Skill 会去百度搜索最新结果。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880dd95dbf31f19b7b65e" data-id="374b7925fd2880dd95dbf31f19b7b65e"><span><div id="374b7925fd2880dd95dbf31f19b7b65e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880dd95dbf31f19b7b65e" title="10.4.2 凭证注入"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.4.2 凭证注入</span></span></h4><div class="notion-text notion-block-374b7925fd2880028ebed8bf24175151">搜索 API 需要 API Key。这个 Key 通过环境变量 <code class="notion-inline-code">BAIDU_API_KEY</code> 配置，由 CleanupService 在启动时写入沙盒：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28802a9be5f86d13c8ed5f" data-id="374b7925fd28802a9be5f86d13c8ed5f"><span><div id="374b7925fd28802a9be5f86d13c8ed5f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28802a9be5f86d13c8ed5f" title="10.4.3 搜索脚本详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.4.3 搜索脚本详解</span></span></h4><div class="notion-text notion-block-374b7925fd2880768418f84695186558"><b>参数说明</b>：</div><table class="notion-simple-table notion-block-374b7925fd288016a4fae0b9e531af8f"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd28804ea7fbdcb97741c9b8"><td class="" style="width:120px"><div class="notion-simple-table-cell">参数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">必填</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">说明</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">示例</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880c784a1f0833dfff763"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">--query</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">搜索关键词或自然语言问题</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">&quot;Python 异步编程最佳实践&quot;</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28803e9eb1e216a7f2e599"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">--top_k</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">返回结果数，默认 20，最大 50</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">--top_k 5</code>（精准搜索）/ <code class="notion-inline-code">--top_k 30</code>（广泛调研）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880eebfefcda049ad85d6"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">--recency</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">时间范围过滤</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">week</code>（近7天）/ <code class="notion-inline-code">month</code>（近30天）/ <code class="notion-inline-code">semiyear</code>（近半年）/ <code class="notion-inline-code">year</code>（近一年）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880bc91c2e56ef22799d4"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">--sites</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">指定站点（逗号分隔）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">&quot;github.com,stackoverflow.com&quot;</code></div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd28804ab8e5c26eb80d6cfc"><b>典型使用场景</b>：</div><hr class="notion-hr notion-block-374b7925fd2880898364e4611d5988d0"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd288062aec1df317cefeb4b" data-id="374b7925fd288062aec1df317cefeb4b"><span><div id="374b7925fd288062aec1df317cefeb4b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288062aec1df317cefeb4b" title="10.5 web_browse — 网页浏览与自动化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.5 web_browse — 网页浏览与自动化</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28809d81dfe0e931fe4326" data-id="374b7925fd28809d81dfe0e931fe4326"><span><div id="374b7925fd28809d81dfe0e931fe4326" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809d81dfe0e931fe4326" title="10.5.1 Skill 概述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.5.1 Skill 概述</span></span></h4><div class="notion-text notion-block-374b7925fd2880e6b44be22f437d32a5"><b>通俗理解</b>：web_browse Skill 是 XiaoPaw 的&quot;浏览器&quot;。它能打开网页、提取内容、截图，甚至填写表单、点击按钮——就像真人在操作浏览器一样。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288001a51ada250e79aaa8" data-id="374b7925fd288001a51ada250e79aaa8"><span><div id="374b7925fd288001a51ada250e79aaa8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288001a51ada250e79aaa8" title="10.5.2 两种工作模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.5.2 两种工作模式</span></span></h4><div class="notion-text notion-block-374b7925fd28809ba2a5cd55927eac2f">web_browse 支持两种模式，根据任务需求选择：</div><table class="notion-simple-table notion-block-374b7925fd2880639252c3fe934bacc0"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880758b23fa26fedcb021"><td class="" style="width:120px"><div class="notion-simple-table-cell">模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">速度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">适用场景</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880829c5cd0ea79cde1e3"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>快速提取</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">sandbox_convert_to_markdown</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">快（~2s）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提取网页文本内容（新闻文章、文档页面）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288052a75ecb957f6fa6bf"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>浏览器全功能</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_navigate</code> + <code class="notion-inline-code">browser_*</code> 系列</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">慢（~10s）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">截图、表单填写、JavaScript 动态渲染页面</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd288057bc17ffca5ce4d17f"><b>为什么需要两种模式？</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288014a1fbd1a0eb5a8a98" data-id="374b7925fd288014a1fbd1a0eb5a8a98"><span><div id="374b7925fd288014a1fbd1a0eb5a8a98" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288014a1fbd1a0eb5a8a98" title="10.5.3 浏览器自动化工具流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.5.3 浏览器自动化工具流程</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28809a912ed69175df503e" data-id="374b7925fd28809a912ed69175df503e"><span><div id="374b7925fd28809a912ed69175df503e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809a912ed69175df503e" title="10.5.4 浏览器工具速查表"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.5.4 浏览器工具速查表</span></span></h4><table class="notion-simple-table notion-block-374b7925fd28804a8ef8c48f036e06e9"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880b0923cd37a7f406974"><td class="" style="width:120px"><div class="notion-simple-table-cell">工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">必填参数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">可选参数</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28802da89bfa3c190886f0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_navigate</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">打开 URL</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">url</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880db8d6ec438e4765608"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_get_markdown</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">获取页面 Markdown</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880718dffe51089bfc599"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_get_text</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">获取页面纯文本</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28805c8c98c156db641add"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_read_links</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">获取所有链接</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880be9475c2540de4b00a"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_screenshot</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">截图</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">name</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">fullPage</code>, <code class="notion-inline-code">selector</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288041848acab9102cb870"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_get_clickable_elements</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">获取可交互元素</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28801bb57cdcb418f3209d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_click</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">点击元素</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">index</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809f9935f59603d89f91"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_form_input_fill</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">填写输入框</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">index</code>, <code class="notion-inline-code">value</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">clear</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288048b26aeca7a65d3fd0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_select</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">下拉选择</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">index</code>, <code class="notion-inline-code">value</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288046b5d1d23b3f2bfa85"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_press_key</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">按键</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">key</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880828b73c792800e3d87"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_scroll</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">滚动页面</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">amount</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880149fb9f7feb963dc25"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_evaluate</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">执行 JavaScript</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">script</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288026ad4efe4f44dd0513"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">browser_close</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">关闭浏览器</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr></tbody></table><hr class="notion-hr notion-block-374b7925fd2880d08b32fb9c14477a63"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880228004c8576be36684" data-id="374b7925fd2880228004c8576be36684"><span><div id="374b7925fd2880228004c8576be36684" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880228004c8576be36684" title="10.6 scheduler_mgr — 定时任务管理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.6 scheduler_mgr — 定时任务管理</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880d0bf2bc1f8bf8d52f7" data-id="374b7925fd2880d0bf2bc1f8bf8d52f7"><span><div id="374b7925fd2880d0bf2bc1f8bf8d52f7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880d0bf2bc1f8bf8d52f7" title="10.6.1 Skill 概述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.6.1 Skill 概述</span></span></h4><div class="notion-text notion-block-374b7925fd2880779455df3b195cadf3"><b>通俗理解</b>：scheduler_mgr Skill 是 XiaoPaw 的&quot;闹钟管理器&quot;。你可以通过它设置定时任务——比如&quot;每天早上 9 点发送工作摘要&quot;、&quot;每周五下午 5 点生成周报&quot;。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288049a004e41f7a484d15" data-id="374b7925fd288049a004e41f7a484d15"><span><div id="374b7925fd288049a004e41f7a484d15" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288049a004e41f7a484d15" title="10.6.2 三种触发模式详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.6.2 三种触发模式详解</span></span></h4><div class="notion-text notion-block-374b7925fd2880039e86cea45218e50f"><b>Cron 表达式语法</b>：</div><div class="notion-text notion-block-374b7925fd28807aaf74c2e821da7b53"><b>常用 Cron 表达式示例</b>：</div><table class="notion-simple-table notion-block-374b7925fd288005bff4d163c6f495a2"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd288092a800c15fd76ff2f9"><td class="" style="width:120px"><div class="notion-simple-table-cell">表达式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">含义</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880a9bc46d96861144c40"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">0 9 * * *</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每天 9:00</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288057be40d30ef7eb26e0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">0 9 * * 1-5</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工作日 9:00</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28800caa59dd90ecbcd547"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">0 9 1 * *</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每月 1 号 9:00</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288007a706c72c4760c56e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">*/30 * * * *</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每 30 分钟</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880c3810eee06d2a223b6"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">0 9,18 * * *</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每天 9:00 和 18:00</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880eab0fddbe69cac770d" data-id="374b7925fd2880eab0fddbe69cac770d"><span><div id="374b7925fd2880eab0fddbe69cac770d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880eab0fddbe69cac770d" title="10.6.3 任务数据结构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.6.3 任务数据结构</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880c99eb0cdb81519417c" data-id="374b7925fd2880c99eb0cdb81519417c"><span><div id="374b7925fd2880c99eb0cdb81519417c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c99eb0cdb81519417c" title="10.6.4 热加载机制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.6.4 热加载机制</span></span></h4><div class="notion-text notion-block-374b7925fd288076963dc35dede21b42"><b>重要提示</b>：scheduler_mgr Skill <b>只负责管理定时任务配置</b>，不负责执行。触发时的业务处理由主 Agent 配合其他 Skill 完成。<code class="notion-inline-code">payload.message</code> 必须是自然语言指令，描述&quot;要做什么&quot;。</div><hr class="notion-hr notion-block-374b7925fd288004914cc91339abc111"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28801a8a70c64259e45ceb" data-id="374b7925fd28801a8a70c64259e45ceb"><span><div id="374b7925fd28801a8a70c64259e45ceb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28801a8a70c64259e45ceb" title="10.7 history_reader — 历史阅读器"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.7 history_reader — 历史阅读器</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880dfb9b5fae65cd0ac37" data-id="374b7925fd2880dfb9b5fae65cd0ac37"><span><div id="374b7925fd2880dfb9b5fae65cd0ac37" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880dfb9b5fae65cd0ac37" title="10.7.1 Skill 概述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.7.1 Skill 概述</span></span></h4><div class="notion-text notion-block-374b7925fd2880b48d03d290e85bd8a9"><b>通俗理解</b>：history_reader 是 XiaoPaw 的&quot;记忆回溯器&quot;。当主 Agent 的上下文窗口只能容纳最近 20 条消息时，如果用户问&quot;你之前说的 xxx 是什么意思&quot;，history_reader 可以翻出更早的对话记录。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880869437e7021603dd45" data-id="374b7925fd2880869437e7021603dd45"><span><div id="374b7925fd2880869437e7021603dd45" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880869437e7021603dd45" title="10.7.2 为什么是 reference 型？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.7.2 为什么是 reference 型？</span></span></h4><div class="notion-text notion-block-374b7925fd288078912adb6be2f4ca02">history_reader 是唯一一个 reference 型的 Skill，它在 SkillLoaderTool 中<b>内联实现</b>（详见第 9 章），不需要沙盒或 Sub-Crew。</div><div class="notion-text notion-block-374b7925fd2880f89227ea2358761144"><b>原因</b>：</div><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880c48751ec447cdcf98d" style="list-style-type:decimal"><li><b>不需要沙盒</b>：只是内存中的列表分页操作，不涉及文件系统或代码执行</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd2880fdb541f89ae39e5525" style="list-style-type:decimal"><li><b>避免网络开销</b>：不启动 Sub-Crew，不需要 MCP 协议通信</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880268ba0d68359943a54" style="list-style-type:decimal"><li><b>安全性</b>：历史消息包含用户隐私数据，不应传入沙盒环境</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd2880c6b080e5762d324563" style="list-style-type:decimal"><li><b>可靠性</b>：减少中间环节，降低出错概率</li></ol><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28804a8350d17cd2eba058" data-id="374b7925fd28804a8350d17cd2eba058"><span><div id="374b7925fd28804a8350d17cd2eba058" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28804a8350d17cd2eba058" title="10.7.3 使用场景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.7.3 使用场景</span></span></h4><ul class="notion-list notion-list-disc notion-block-374b7925fd28805cbf09cbf7742ef64e"><li>用户询问&quot;回顾一下我们之前的对话&quot;</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880539280c387a8910eea"><li>历史截断后，Agent 需要查阅更早的消息</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880b78a31ffa78b0437f1"><li>用户询问特定历史话题（&quot;你上次说的那个 Python 库叫什么来着？&quot;）</li></ul><hr class="notion-hr notion-block-374b7925fd2880d4a42ddd8ecae69cf5"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28803cae9be526d6183429" data-id="374b7925fd28803cae9be526d6183429"><span><div id="374b7925fd28803cae9be526d6183429" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28803cae9be526d6183429" title="10.8 本章小结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.8 本章小结</span></span></h3><table class="notion-simple-table notion-block-374b7925fd2880bd940acb2f87868fb4"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880c887a5f463a8568379"><td class="" style="width:120px"><div class="notion-simple-table-cell">Skill</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心能力</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">关键技术</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">凭证来源</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28802fa252d237129fb3be"><td class="" style="width:120px"><div class="notion-simple-table-cell">pdf</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">PDF 文本提取与处理</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">pypdf, pdfplumber</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28800e9c55fd395faa2433"><td class="" style="width:120px"><div class="notion-simple-table-cell">docx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Word 文档创建与编辑</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">python-docx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880a2bd7cc1e2bfc32742"><td class="" style="width:120px"><div class="notion-simple-table-cell">pptx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">PowerPoint 文本提取</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">python-pptx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809ebb10ebec3cf16a1a"><td class="" style="width:120px"><div class="notion-simple-table-cell">xlsx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Excel 数据分析</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">pandas, openpyxl</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28801b907af7d9a7cb81a0"><td class="" style="width:120px"><div class="notion-simple-table-cell">feishu_ops</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">飞书消息/文档/日历</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">飞书 REST API + 16 个独立脚本</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/workspace/.config/feishu.json</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28806d83bbc7100e63d4c8"><td class="" style="width:120px"><div class="notion-simple-table-cell">baidu_search</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">百度搜索</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">百度千帆 Web Search API</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/workspace/.config/baidu.json</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288020b95df4dd0418011f"><td class="" style="width:120px"><div class="notion-simple-table-cell">web_browse</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">网页浏览与自动化</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">sandbox_convert_to_markdown + browser_* 工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288007a064f56cbb8b832e"><td class="" style="width:120px"><div class="notion-simple-table-cell">scheduler_mgr</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定时任务管理</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">读写 tasks.json + CronService 热加载</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880b2beb7e6551474cce4"><td class="" style="width:120px"><div class="notion-simple-table-cell">history_reader</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">历史分页读取</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">内联实现，内存分页</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd288053b35dee35f453ee07"><b>设计亮点</b>：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd288040a426eaf5b1f56301"><li><b>统一脚本模式</b>：所有 task 型 Skill 脚本遵循相同的参数解析 → 认证 → API 调用 → 响应检查 → 结果输出模式</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880608f21fd52e8b1de1c"><li><b>凭证隔离</b>：敏感信息通过文件系统注入沙盒，不经过 LLM</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd288002972bd94c9711e2d5"><li><b>独立可测试</b>：每个脚本可以独立运行和测试，不依赖整个系统</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880189923e115e3b9bbeb"><li><b>热加载</b>：scheduler_mgr 的配置变更无需重启</li></ul><hr class="notion-hr notion-block-374b7925fd2880fd9dd6e7f197ffa859"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880d8a6bac6bdd50242ba" data-id="374b7925fd2880d8a6bac6bdd50242ba"><span><div id="374b7925fd2880d8a6bac6bdd50242ba" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880d8a6bac6bdd50242ba" title="10.9 练习与思考"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10.9 练习与思考</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880d5b4d8eab9bbc740a3" style="list-style-type:decimal"><li><b>新增一个消息类型</b>：在 feishu_ops 中新增一个 <code class="notion-inline-code">send_markdown.py</code> 脚本，支持发送 Markdown 格式的消息。参考 send_text.py 和 send_post.py 的实现。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd28807c83b3f767bdfe396e" style="list-style-type:decimal"><li><b>搜索优化</b>：baidu_search 的 <code class="notion-inline-code">_get_api_key()</code> 每次都读取文件。如果改成缓存机制，应该如何设计？参考 feishu_ops 的 token 缓存思路。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880d0a98bcc3ef9569f99" style="list-style-type:decimal"><li><b>文件处理链</b>：用户上传了一个 Excel 文件，要求&quot;分析数据并生成 PDF 报告&quot;。这需要 chain 哪些 Skill？画出完整的调用链路。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd2880669272cd5ab4801955" style="list-style-type:decimal"><li><b>错误处理</b>：如果 baidu_search 的 API Key 过期了，脚本会输出什么？Sub-Crew Agent 会如何处理？主 Agent 会给用户什么回复？</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-374b7925fd288006bfe5fccbb962672a" style="list-style-type:decimal"><li><b>Cron 表达式</b>：用 Cron 表达式表示&quot;每月最后一天 18:00&quot;和&quot;每周一、三、五 9:00&quot;。</li></ol><div class="notion-text notion-block-374b7925fd2880e197f0e17317b62798">下一章将深入 LLM 适配器的实现——如何将阿里云的通义千问模型接入 CrewAI 框架。</div><hr class="notion-hr notion-block-374b7925fd2880079a9ff7957f5af4d4"/><div class="notion-blank notion-block-374b7925fd28802cbcf1c82766cd28d0"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-374b7925fd288036aaa0d2118d2b7c58" data-id="374b7925fd288036aaa0d2118d2b7c58"><span><div id="374b7925fd288036aaa0d2118d2b7c58" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288036aaa0d2118d2b7c58" title="第11章：LLM 适配器"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第11章：LLM 适配器</span></span></h2><blockquote class="notion-quote notion-block-374b7925fd28803e831dcff86700b41c"><div>本章目标：深入理解 CrewAI 的 LLM 接口机制，掌握 AliyunLLM 适配器的实现细节——重试机制、函数调用（Function Calling）、多模态图片输入、消息格式化、工具结果截断等。</div><div class="notion-text notion-block-374b7925fd2880118284f9aad1e76ad0">对应源码：<a class="notion-link" href="https://www.notion.so/xiaopaw/llm/aliyun_llm.py" target="_blank" rel="noopener noreferrer">xiaopaw/llm/aliyun_llm.py</a></div></blockquote><hr class="notion-hr notion-block-374b7925fd28804f8e22c5b316d3998c"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880369fe3e037f3469964" data-id="374b7925fd2880369fe3e037f3469964"><span><div id="374b7925fd2880369fe3e037f3469964" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880369fe3e037f3469964" title="11.1 为什么需要自定义 LLM 适配器？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.1 为什么需要自定义 LLM 适配器？</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288006af94e93a2e1e1131" data-id="374b7925fd288006af94e93a2e1e1131"><span><div id="374b7925fd288006af94e93a2e1e1131" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288006af94e93a2e1e1131" title="11.1.1 通俗理解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.1.1 通俗理解</span></span></h4><div class="notion-text notion-block-374b7925fd2880ac9e6fe6f5ede682c6">想象一下，你去国外旅行，发现当地的插座和你的充电器插头不匹配。你需要一个&quot;转换插头&quot;（适配器）才能给你的设备充电。</div><div class="notion-text notion-block-374b7925fd288009b5a6c85d674fc139">在 XiaoPaw 中，CrewAI 框架期望一个&quot;标准插座&quot;（OpenAI 格式），而阿里云通义千问（Qwen）提供的是一个&quot;不同形状的插头&quot;（DashScope API）。<b>AliyunLLM 就是这个&quot;转换插头&quot;</b>——它把 CrewAI 的请求翻译成 DashScope 能理解的格式，再把 DashScope 的响应翻译回 CrewAI 能理解的结果。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880ffbf33faa11b9cdfd6" data-id="374b7925fd2880ffbf33faa11b9cdfd6"><span><div id="374b7925fd2880ffbf33faa11b9cdfd6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880ffbf33faa11b9cdfd6" title="11.1.2 为什么不能直接用 OpenAI 的适配器？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.1.2 为什么不能直接用 OpenAI 的适配器？</span></span></h4><table class="notion-simple-table notion-block-374b7925fd288041930fdaf281bcd2c6"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880f38658da8b5a7935a6"><td class="" style="width:120px"><div class="notion-simple-table-cell">特性</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenAI</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">DashScope（通义千问）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28804f8f35ce03d4e70aa1"><td class="" style="width:120px"><div class="notion-simple-table-cell">API 端点</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">api.openai.com</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">dashscope.aliyuncs.com</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880448d88d53404b5dd2d"><td class="" style="width:120px"><div class="notion-simple-table-cell">认证方式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Bearer sk-xxx</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">Bearer sk-xxx</code>（相同）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28802ea85dfd1ca4d42dbb"><td class="" style="width:120px"><div class="notion-simple-table-cell">多地域</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">cn</code>（国内）/ <code class="notion-inline-code">intl</code>（国际）/ <code class="notion-inline-code">finance</code>（金融云）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880f5a250d6351dcddd97"><td class="" style="width:120px"><div class="notion-simple-table-cell">多模态模型</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">gpt-4o</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">qwen3-vl-plus</code>（需单独指定）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288019b177c9764fcb2d40"><td class="" style="width:120px"><div class="notion-simple-table-cell">Tool Calls 格式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">标准 JSON</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">兼容，但部分参数需要规范化</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880239c55c41a5af86935"><td class="" style="width:120px"><div class="notion-simple-table-cell">上下文窗口</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">基于模型名</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">基于模型名（<code class="notion-inline-code">long</code>→200K, <code class="notion-inline-code">max/plus/turbo</code>→131K）</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880bcb50cd5c4e4b149c9" data-id="374b7925fd2880bcb50cd5c4e4b149c9"><span><div id="374b7925fd2880bcb50cd5c4e4b149c9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880bcb50cd5c4e4b149c9" title="11.1.3 核心差异：多模态处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.1.3 核心差异：多模态处理</span></span></h4><div class="notion-text notion-block-374b7925fd2880dea06beb9bab7459a1">最大的差异在于<b>多模态图片处理</b>。CrewAI 对工具返回结果的 <code class="notion-inline-code">stringify</code>（字符串化）处理，会导致图片的 base64 编码被当作普通文本，DashScope 无法识别。AliyunLLM 需要<b>反向还原</b>这些字符串为多模态格式。</div><hr class="notion-hr notion-block-374b7925fd288017a1a9f2ddc8d7b5ce"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880168d20ee51560c03c1" data-id="374b7925fd2880168d20ee51560c03c1"><span><div id="374b7925fd2880168d20ee51560c03c1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880168d20ee51560c03c1" title="11.2 CrewAI BaseLLM 接口"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.2 CrewAI <code class="notion-inline-code">BaseLLM</code> 接口</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288036abbec11f5ffd1bf5" data-id="374b7925fd288036abbec11f5ffd1bf5"><span><div id="374b7925fd288036abbec11f5ffd1bf5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288036abbec11f5ffd1bf5" title="11.2.1 接口定义"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.2.1 接口定义</span></span></h4><div class="notion-text notion-block-374b7925fd28802d9daac02d05a80263">CrewAI 提供了 <code class="notion-inline-code">BaseLLM</code> 抽象类，自定义 LLM 需要继承它并实现以下方法：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28808e94dce2ec5d7e45a4" data-id="374b7925fd28808e94dce2ec5d7e45a4"><span><div id="374b7925fd28808e94dce2ec5d7e45a4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28808e94dce2ec5d7e45a4" title="11.2.2 消息格式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.2.2 消息格式</span></span></h4><div class="notion-text notion-block-374b7925fd28807c937ed9ec0fd425c7">CrewAI 传入 <code class="notion-inline-code">call()</code> 的消息是<b>已转换为 dict 格式</b>的对话历史：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880a595dec29d09e04abb" data-id="374b7925fd2880a595dec29d09e04abb"><span><div id="374b7925fd2880a595dec29d09e04abb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a595dec29d09e04abb" title="11.2.3 两种返回值模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.2.3 两种返回值模式</span></span></h4><div class="notion-text notion-block-374b7925fd2880e38e23c78925096ccc"><code class="notion-inline-code">call()</code> 方法可能返回两种不同的值，取决于 LLM 的决定：</div><div class="notion-text notion-block-374b7925fd288056aa3ef4d3e2f64161"><b>当返回 </b><code class="notion-inline-code"><b>tool_calls</b></code><b> 时</b>，CrewAI 会接管执行流程：</div><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880a480ccddaf85d05b19" style="list-style-type:decimal"><li>CrawlAI 的 executor 接收 tool_calls</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd2880c49792c6c5c997a1a5" style="list-style-type:decimal"><li>根据 <code class="notion-inline-code">function.name</code> 找到对应的工具函数</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880899145edc2d43df468" style="list-style-type:decimal"><li>执行工具函数，获得结果</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd2880d78598db96083df483" style="list-style-type:decimal"><li>将结果作为 <code class="notion-inline-code">tool</code> 消息追加到对话历史</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-374b7925fd28801ea5f5e2408319790e" style="list-style-type:decimal"><li>再次调用 <code class="notion-inline-code">call()</code>，让 LLM 基于工具结果继续推理</li></ol><hr class="notion-hr notion-block-374b7925fd288012bd4ec7b5fdae1650"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880b6b3a6f84675c1127d" data-id="374b7925fd2880b6b3a6f84675c1127d"><span><div id="374b7925fd2880b6b3a6f84675c1127d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880b6b3a6f84675c1127d" title="11.3 AliyunLLM 完整实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.3 AliyunLLM 完整实现</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288079af96c813c1b6c39b" data-id="374b7925fd288079af96c813c1b6c39b"><span><div id="374b7925fd288079af96c813c1b6c39b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288079af96c813c1b6c39b" title="11.3.1 类结构总览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.3.1 类结构总览</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28804fab7ec4df2d19e0bd" data-id="374b7925fd28804fab7ec4df2d19e0bd"><span><div id="374b7925fd28804fab7ec4df2d19e0bd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28804fab7ec4df2d19e0bd" title="11.3.2 初始化详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.3.2 初始化详解</span></span></h4><div class="notion-text notion-block-374b7925fd2880a2bbb1d3a83da6c7b1"><b>为什么重试次数默认是 2？</b></div><div class="notion-text notion-block-374b7925fd288012ab75d8945bd37063">这是一个经验值。太少（1次）可能不够覆盖偶发性的网络问题；太多（5次以上）会让用户等待过久。2 次重试（共 3 次尝试）在&quot;可靠性&quot;和&quot;响应速度&quot;之间达到了较好的平衡。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880a399ebd0664b8e3af1" data-id="374b7925fd2880a399ebd0664b8e3af1"><span><div id="374b7925fd2880a399ebd0664b8e3af1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a399ebd0664b8e3af1" title="11.3.3 多地域支持"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.3.3 多地域支持</span></span></h4><hr class="notion-hr notion-block-374b7925fd288031b05be604b4ad056e"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880c2aad7c08e3e8444b1" data-id="374b7925fd2880c2aad7c08e3e8444b1"><span><div id="374b7925fd2880c2aad7c08e3e8444b1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c2aad7c08e3e8444b1" title="11.4 核心流程：call() 方法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.4 核心流程：call() 方法</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288014bbc3ee217f780cd1" data-id="374b7925fd288014bbc3ee217f780cd1"><span><div id="374b7925fd288014bbc3ee217f780cd1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288014bbc3ee217f780cd1" title="11.4.1 调用流程全景图"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.4.1 调用流程全景图</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880c58a35e0febad303a2" data-id="374b7925fd2880c58a35e0febad303a2"><span><div id="374b7925fd2880c58a35e0febad303a2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c58a35e0febad303a2" title="11.4.2 重试机制详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.4.2 重试机制详解</span></span></h4><div class="notion-text notion-block-374b7925fd2880aebf77c7599e24df55">重试是 AliyunLLM 最关键的可靠性保障机制。不同于简单的&quot;失败就重试&quot;，它根据错误类型采取不同的策略：</div><div class="notion-text notion-block-374b7925fd28803c91c4d6c73f36e157"><b>重试策略总结</b>：</div><table class="notion-simple-table notion-block-374b7925fd28804fa0c9f38bdc69614f"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880dcb349d73c9794be90"><td class="" style="width:120px"><div class="notion-simple-table-cell">HTTP 状态码</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">含义</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">是否重试</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">原因</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809584a5f76eb1ae961d"><td class="" style="width:120px"><div class="notion-simple-table-cell">200</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">成功</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">正常响应</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880a19983c945f0c9bc04"><td class="" style="width:120px"><div class="notion-simple-table-cell">4xx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">客户端错误（参数错误等）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌ 不重试</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">请求本身有问题，重试不会改变结果</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880669a90e9419d358e5e"><td class="" style="width:120px"><div class="notion-simple-table-cell">429</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">限流（Rate Limit）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 重试</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">配额可能在下个时间窗口恢复</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28802c9eecf51cd16e47f0"><td class="" style="width:120px"><div class="notion-simple-table-cell">5xx</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">服务器错误</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 重试</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">服务端临时故障，重试大概率成功</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288054bd68e0c6938d12fd"><td class="" style="width:120px"><div class="notion-simple-table-cell">Timeout</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">超时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 重试</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">可能是网络抖动</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880dcac1dd069be7844be" data-id="374b7925fd2880dcac1dd069be7844be"><span><div id="374b7925fd2880dcac1dd069be7844be" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880dcac1dd069be7844be" title="11.4.3 空内容重试"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.4.3 空内容重试</span></span></h4><div class="notion-text notion-block-374b7925fd2880c89dfdc6d80382fcc3">LLM 偶尔会返回空内容（<code class="notion-inline-code">content=&quot;&quot;</code>），这通常是因为模型限流或偶发异常。AliyunLLM 对这个情况也做了专门处理：</div><div class="notion-text notion-block-374b7925fd28802d8116e7404c72f047"><b>为什么 _retry_on_empty 要设为 False？</b></div><div class="notion-text notion-block-374b7925fd28805bb69ad9fe24467e52">这防止了无限递归。如果设为 True，空内容重试内部再次遇到空内容，又会触发重试，形成死循环。设为 False 后，内层重试再遇到空内容就会直接抛出异常，终止循环。</div><hr class="notion-hr notion-block-374b7925fd28806cacf8e05813e56a4e"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28807897b6e99efc65c68f" data-id="374b7925fd28807897b6e99efc65c68f"><span><div id="374b7925fd28807897b6e99efc65c68f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28807897b6e99efc65c68f" title="11.5 消息格式化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.5 消息格式化</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880eda837c16daecdd766" data-id="374b7925fd2880eda837c16daecdd766"><span><div id="374b7925fd2880eda837c16daecdd766" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880eda837c16daecdd766" title="11.5.1 消息校验"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.5.1 消息校验</span></span></h4><div class="notion-text notion-block-374b7925fd28808eac3dc2e2184fb412">在发送请求前，AliyunLLM 会校验消息格式：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28809d9208c38932bd9df2" data-id="374b7925fd28809d9208c38932bd9df2"><span><div id="374b7925fd28809d9208c38932bd9df2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809d9208c38932bd9df2" title="11.5.2 工具结果截断"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.5.2 工具结果截断</span></span></h4><div class="notion-text notion-block-374b7925fd2880d4a87ef571bdf8f0c4">当工具返回数据过大时（如 Excel 解析结果可能包含大量文本），直接发送会导致 API 返回 500 错误。AliyunLLM 会自动截断过长的工具结果：</div><hr class="notion-hr notion-block-374b7925fd2880c7ab07fc7e1f0b6a53"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880549a04c2bb9ea9d7c4" data-id="374b7925fd2880549a04c2bb9ea9d7c4"><span><div id="374b7925fd2880549a04c2bb9ea9d7c4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880549a04c2bb9ea9d7c4" title="11.6 Function Calling 详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.6 Function Calling 详解</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880f992a7d7f0e471fd34" data-id="374b7925fd2880f992a7d7f0e471fd34"><span><div id="374b7925fd2880f992a7d7f0e471fd34" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880f992a7d7f0e471fd34" title="11.6.1 什么是 Function Calling？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.6.1 什么是 Function Calling？</span></span></h4><div class="notion-text notion-block-374b7925fd2880078251f2ff78840c19">Function Calling（函数调用/工具调用）是 LLM 的一项核心能力。它允许 LLM 在推理过程中&quot;调用&quot;外部函数来获取信息或执行操作。</div><div class="notion-text notion-block-374b7925fd288080a43ef6b10890abb3"><b>通俗理解</b>：就像你问助手&quot;今天天气怎么样&quot;，助手不会凭空编造，而是拿起手机查看天气预报 App，然后把结果告诉你。LLM 的 Function Calling 就是这个过程——它知道自己不能回答某些问题，所以&quot;调用&quot;外部工具来获取信息。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880869f5dfd18a51fdf2f" data-id="374b7925fd2880869f5dfd18a51fdf2f"><span><div id="374b7925fd2880869f5dfd18a51fdf2f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880869f5dfd18a51fdf2f" title="11.6.2 完整调用流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.6.2 完整调用流程</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28809cbffcf9129c6c2484" data-id="374b7925fd28809cbffcf9129c6c2484"><span><div id="374b7925fd28809cbffcf9129c6c2484" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809cbffcf9129c6c2484" title="11.6.3 两种 tool_calls 处理模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.6.3 两种 tool_calls 处理模式</span></span></h4><div class="notion-text notion-block-374b7925fd288035b63af87d1dca6d1f">AliyunLLM 的 <code class="notion-inline-code">call()</code> 方法根据 <code class="notion-inline-code">available_functions</code> 参数是否为 None，采取不同的处理方式：</div><div class="notion-text notion-block-374b7925fd2880dabafad48d1d0e2504"><b>为什么有两种模式？</b></div><table class="notion-simple-table notion-block-374b7925fd2880a6b99dfe427ee71a6d"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd28802da33aca1fb65deade"><td class="" style="width:120px"><div class="notion-simple-table-cell">模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">谁执行工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">适用场景</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28805fbcaefb7f391998d4"><td class="" style="width:120px"><div class="notion-simple-table-cell">模式 1（递归）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AliyunLLM 自己</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">LLM 内部的工具调用循环</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28804d876cdf40906a24b6"><td class="" style="width:120px"><div class="notion-simple-table-cell">模式 2（返回）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">CrewAI executor</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">CrewAI Agent 的工具调用流程</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd28804ab894c77af7c4002b">模式 2 是主要使用的方式。CrewAI 故意传 <code class="notion-inline-code">available_functions=None</code>，让 LLM 只返回原始 <code class="notion-inline-code">tool_calls</code>，由 CrewAI 的 <code class="notion-inline-code">_handle_native_tool_calls</code> 统一执行。这样 CrewAI 可以控制工具的生命周期、记录 trace、管理回调等。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880d69282fcae8193276d" data-id="374b7925fd2880d69282fcae8193276d"><span><div id="374b7925fd2880d69282fcae8193276d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880d69282fcae8193276d" title="11.6.4 MCP 参数规范化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.6.4 MCP 参数规范化</span></span></h4><div class="notion-text notion-block-374b7925fd2880b98b53d561b40a1306">MCP（Model Context Protocol）工具对参数类型有严格要求。LLM 有时会把列表参数传成字符串 <code class="notion-inline-code">&quot;None&quot;</code>，导致 schema 校验失败。AliyunLLM 在返回 tool_calls 前做规范化处理：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28804b962fc0dee156c9ca" data-id="374b7925fd28804b962fc0dee156c9ca"><span><div id="374b7925fd28804b962fc0dee156c9ca" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28804b962fc0dee156c9ca" title="11.6.5 递归 Function Calling"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.6.5 递归 Function Calling</span></span></h4><div class="notion-text notion-block-374b7925fd28804bad60c4f47b26bab1">当 <code class="notion-inline-code">available_functions</code> 不为 None 时，AliyunLLM 会递归处理工具调用：</div><hr class="notion-hr notion-block-374b7925fd2880829274e67ae2657f77"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880f9adfbec9ab1ffc633" data-id="374b7925fd2880f9adfbec9ab1ffc633"><span><div id="374b7925fd2880f9adfbec9ab1ffc633" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880f9adfbec9ab1ffc633" title="11.7 多模态图片处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.7 多模态图片处理</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880fdb72aed5e25579688" data-id="374b7925fd2880fdb72aed5e25579688"><span><div id="374b7925fd2880fdb72aed5e25579688" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880fdb72aed5e25579688" title="11.7.1 问题背景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.7.1 问题背景</span></span></h4><div class="notion-text notion-block-374b7925fd2880c68065d34e04b11b34">CrewAI 对工具返回结果做 <code class="notion-inline-code">stringify</code>（字符串化）时，会将图片的 base64 编码当作普通文本处理。但 DashScope 的视觉模型需要图片以特定的多模态格式传入。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880e7aa1ec10ca75a2bdb" data-id="374b7925fd2880e7aa1ec10ca75a2bdb"><span><div id="374b7925fd2880e7aa1ec10ca75a2bdb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880e7aa1ec10ca75a2bdb" title="11.7.2 多模态检测与还原"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.7.2 多模态检测与还原</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288012a756efb16c8d6bb1" data-id="374b7925fd288012a756efb16c8d6bb1"><span><div id="374b7925fd288012a756efb16c8d6bb1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288012a756efb16c8d6bb1" title="11.7.3 模型自动切换"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.7.3 模型自动切换</span></span></h4><div class="notion-text notion-block-374b7925fd2880b48507cbed2b101bc3">当检测到图片时，AliyunLLM 自动将 <code class="notion-inline-code">model</code> 切换为 <code class="notion-inline-code">image_model</code>：</div><div class="notion-text notion-block-374b7925fd28806bbca6df77eb7980ad"><b>为什么需要切换模型？</b></div><div class="notion-text notion-block-374b7925fd2880f895fcc74ed81a491a">通义千问的文本模型（如 <code class="notion-inline-code">qwen3.6-max-preview</code>）不支持图片输入。必须使用专门的视觉模型（如 <code class="notion-inline-code">qwen3-vl-plus</code>）才能处理图片。这个切换是自动的，对调用方透明。</div><div class="notion-text notion-block-374b7925fd2880d9985dc37d279bfb7c">![多模态模型切换流程]</div><hr class="notion-hr notion-block-374b7925fd2880bc9ba8d958d4b79ceb"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28801a9beefa64e2ac6fce" data-id="374b7925fd28801a9beefa64e2ac6fce"><span><div id="374b7925fd28801a9beefa64e2ac6fce" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28801a9beefa64e2ac6fce" title="11.8 上下文窗口大小"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.8 上下文窗口大小</span></span></h3><div class="notion-text notion-block-374b7925fd2880e4be87dd7f982f4002"><b>什么是 Token？</b></div><div class="notion-text notion-block-374b7925fd28806fac02d8cebca94342">Token 是 LLM 处理文本的最小单位。粗略地说：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd28804daea0edcf870f9586"><li>1 个中文字 ≈ 1.5-2 个 tokens</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880d2be8febf6f0c0ce5b"><li>1 个英文单词 ≈ 1-1.5 个 tokens</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880e5ad4ed31a39355671"><li>一段代码 ≈ 更多 tokens（各种符号都是独立的 token）</li></ul><hr class="notion-hr notion-block-374b7925fd2880a781aafe4f0a5d14ed"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28807a93dfdaa0712365e7" data-id="374b7925fd28807a93dfdaa0712365e7"><span><div id="374b7925fd28807a93dfdaa0712365e7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28807a93dfdaa0712365e7" title="11.9 异步调用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.9 异步调用</span></span></h3><div class="notion-text notion-block-374b7925fd2880438744efb39e1bce56"><b>为什么用 </b><code class="notion-inline-code"><b>asyncio.to_thread()</b></code><b> 而不是 </b><code class="notion-inline-code"><b>aiohttp</b></code><b>？</b></div><table class="notion-simple-table notion-block-374b7925fd2880ffb37dd93ab9129b8f"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880a98000f14379893b90"><td class="" style="width:120px"><div class="notion-simple-table-cell">方案</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">优点</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">缺点</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880f38624e8accc2ccefc"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">asyncio.to_thread()</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">代码简单，复用同步逻辑</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">占用线程池资源</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288029b529efac5e592ad8"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">aiohttp</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">真正异步，不占用线程</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">需要重写所有 HTTP 逻辑</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd2880a0a921dc726bdceba9">对于 XiaoPaw 的并发量（通常只有几个同时进行的对话），线程池的开销可以忽略不计，而代码简洁性更重要。</div><hr class="notion-hr notion-block-374b7925fd2880b5b400f52360538a28"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd288087a200e365ebc3c14a" data-id="374b7925fd288087a200e365ebc3c14a"><span><div id="374b7925fd288087a200e365ebc3c14a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288087a200e365ebc3c14a" title="11.10 调试模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.10 调试模式</span></span></h3><div class="notion-text notion-block-374b7925fd288031b6e5e413e795813e">当遇到 LLM 调用问题时，可以开启调试模式查看完整的请求内容：</div><div class="notion-text notion-block-374b7925fd2880fb9e8ae89030823895">调试模式下，日志会输出完整的请求 payload：</div><hr class="notion-hr notion-block-374b7925fd2880b5bffacebe03a956fb"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd288051a130feeac39e6698" data-id="374b7925fd288051a130feeac39e6698"><span><div id="374b7925fd288051a130feeac39e6698" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288051a130feeac39e6698" title="11.11 配置使用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.11 配置使用</span></span></h3><div class="notion-text notion-block-374b7925fd28802d83c7e29508fac0e8">在 <code class="notion-inline-code">_build_crew()</code> 中创建 Agent 时指定 LLM：</div><hr class="notion-hr notion-block-374b7925fd2880dbb686dcd11e5aef93"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880e785a2fdcf7c326696" data-id="374b7925fd2880e785a2fdcf7c326696"><span><div id="374b7925fd2880e785a2fdcf7c326696" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880e785a2fdcf7c326696" title="11.12 本章小结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.12 本章小结</span></span></h3><table class="notion-simple-table notion-block-374b7925fd2880ed8ee5e35ce101428f"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880d68068c294b214a0f4"><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">实现方式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">关键参数</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288088a31ff9172ae1804f"><td class="" style="width:120px"><div class="notion-simple-table-cell">多地域支持</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">3 个端点映射</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">region</code>: cn / intl / finance</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880f59c2ffc397007420b"><td class="" style="width:120px"><div class="notion-simple-table-cell">重试机制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">按状态码分类重试</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">retry_count</code>: 默认 2</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288049a6c4c2faf425e6d9"><td class="" style="width:120px"><div class="notion-simple-table-cell">空内容重试</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">递归调用，最多 2 次</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">_retry_on_empty</code> + <code class="notion-inline-code">_empty_retry_count</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28802c9d5cc6ced6946584"><td class="" style="width:120px"><div class="notion-simple-table-cell">Function Calling</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">两种模式（递归/返回）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">available_functions</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880b1850ae0e90504e73b"><td class="" style="width:120px"><div class="notion-simple-table-cell">MCP 参数规范化</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">字符串 &quot;None&quot; → []</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">_MCP_LIST_PARAMS</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288027a017f251748b042f"><td class="" style="width:120px"><div class="notion-simple-table-cell">工具结果截断</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">超 12000 字符自动截断</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">LLM_TOOL_RESULT_MAX_CHARS</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288013839dde45b346164b"><td class="" style="width:120px"><div class="notion-simple-table-cell">多模态图片</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">检测 + 还原 + 模型切换</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">image_model</code>: qwen3-vl-plus</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880e1999ee92679f7db7d"><td class="" style="width:120px"><div class="notion-simple-table-cell">消息校验</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">检查 role + tool_call_id</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">_validate_messages</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28803ab4dbcd68388d6481"><td class="" style="width:120px"><div class="notion-simple-table-cell">上下文窗口</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">基于模型名推断</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">get_context_window_size</code></div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809bbf43dd39a6820329"><td class="" style="width:120px"><div class="notion-simple-table-cell">调试模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">环境变量控制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">QWEN_DEBUG_PAYLOAD=1</code></div></td></tr></tbody></table><hr class="notion-hr notion-block-374b7925fd2880e3b2edfdfcf3873ce9"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28801b833fcae4e4a604ed" data-id="374b7925fd28801b833fcae4e4a604ed"><span><div id="374b7925fd28801b833fcae4e4a604ed" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28801b833fcae4e4a604ed" title="11.13 练习与思考"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">11.13 练习与思考</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd28808ca846f69e110697b0" style="list-style-type:decimal"><li><b>Token 计算</b>：一条 1000 字的中文消息大约消耗多少 tokens？如果上下文窗口是 131,072 tokens，大约能容纳多少条这样的消息？</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd288064bd4dcba09e525e8f" style="list-style-type:decimal"><li><b>重试策略</b>：为什么 4xx 错误不重试，而 5xx 错误要重试？如果 API 返回 408（Request Timeout），应该怎么处理？</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd288050beacdc4d8c2b2828" style="list-style-type:decimal"><li><b>多模态处理</b>：如果用户同时上传了 3 张图片，<code class="notion-inline-code">_normalize_multimodal_tool_result</code> 能否正确处理？如果不能，应该如何改进？</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd288023b80fc65042be464d" style="list-style-type:decimal"><li><b>工具结果截断</b>：如果 LLM 收到截断的工具结果后，仍然尝试基于不完整的信息做结论，会导致什么问题？截断后缀中的提示信息是否足够？</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-374b7925fd2880ed873ff95ca751f05d" style="list-style-type:decimal"><li><b>模型选择</b>：什么时候应该用 <code class="notion-inline-code">qwen-long</code>（200K 上下文）而不是 <code class="notion-inline-code">qwen-max</code>（131K 上下文）？多消耗的 tokens 成本是否值得？</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-374b7925fd288007ada7ec53f25ef134" style="list-style-type:decimal"><li><b>自定义适配器</b>：如果要把 XiaoPaw 改为使用 OpenAI 的 GPT-4，需要修改 AliyunLLM 的哪些部分？哪些部分可以复用？</li></ol><div class="notion-text notion-block-374b7925fd288074a7a9d4e6b2f665ef">下一章将深入 CronService 定时任务调度系统——如何实现精确的定时触发、任务热加载和调度状态管理。</div><div class="notion-blank notion-block-374b7925fd2880d6ad31ded12bb3e36b"> </div><hr class="notion-hr notion-block-374b7925fd2880d7851fd12970abb75f"/><div class="notion-blank notion-block-374b7925fd288032a35eff55317e834d"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-374b7925fd288027a705f05569df251e" data-id="374b7925fd288027a705f05569df251e"><span><div id="374b7925fd288027a705f05569df251e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288027a705f05569df251e" title="第12章：CronService 定时任务调度"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">第12章：CronService 定时任务调度</span></span></h2><blockquote class="notion-quote notion-block-374b7925fd2880929a9dd9cbf793095e"><div>本章目标：深入理解 CronService 的调度模型、三种调度模式（at / every / cron）、tick 主循环、mtime 热加载机制、任务状态持久化，以及由定时任务触发的消息如何在 Runner 中流转。</div><div class="notion-text notion-block-374b7925fd28808d9f00cdf8eead2176">对应源码：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd28801ab00dc0da4b32ccb2"><li><a class="notion-link" href="https://www.notion.so/xiaopaw/cron/service.py" target="_blank" rel="noopener noreferrer">xiaopaw/cron/service.py</a></li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880af8933f8a5592dab27"><li><a class="notion-link" href="https://www.notion.so/xiaopaw/cron/models.py" target="_blank" rel="noopener noreferrer">xiaopaw/cron/models.py</a></li></ul></blockquote><hr class="notion-hr notion-block-374b7925fd2880a9bc9af222651177b9"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880c6a47bf5817e44909a" data-id="374b7925fd2880c6a47bf5817e44909a"><span><div id="374b7925fd2880c6a47bf5817e44909a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c6a47bf5817e44909a" title="12.1 调度模型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.1 调度模型</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880ee8c6fe7a82a46db81" data-id="374b7925fd2880ee8c6fe7a82a46db81"><span><div id="374b7925fd2880ee8c6fe7a82a46db81" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880ee8c6fe7a82a46db81" title="12.1.1 通俗理解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.1.1 通俗理解</span></span></h4><div class="notion-text notion-block-374b7925fd288082bbbcdd89c80b5a5d">CronService 就像你的&quot;闹钟管家&quot;。你告诉它&quot;每天早上 9 点提醒我开会&quot;，它就会准时在你设定的时间&quot;响铃&quot;——把一条消息注入到 XiaoPaw 的处理管道中，就像有人给你发了消息一样。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288032a896f591f6f4b78f" data-id="374b7925fd288032a896f591f6f4b78f"><span><div id="374b7925fd288032a896f591f6f4b78f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288032a896f591f6f4b78f" title="12.1.2 数据模型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.1.2 数据模型</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288044ba72d8604d5cde48" data-id="374b7925fd288044ba72d8604d5cde48"><span><div id="374b7925fd288044ba72d8604d5cde48" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288044ba72d8604d5cde48" title="12.1.3 三种调度模式详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.1.3 三种调度模式详解</span></span></h4><hr class="notion-hr notion-block-374b7925fd2880698492c6cf48b60c79"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28801ea370db07aad23cb4" data-id="374b7925fd28801ea370db07aad23cb4"><span><div id="374b7925fd28801ea370db07aad23cb4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28801ea370db07aad23cb4" title="12.2 CronService 核心实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.2 CronService 核心实现</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880149d1ac28bfb60f9e4" data-id="374b7925fd2880149d1ac28bfb60f9e4"><span><div id="374b7925fd2880149d1ac28bfb60f9e4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880149d1ac28bfb60f9e4" title="12.2.1 类结构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.2.1 类结构</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288000bd4deca283ff96f5" data-id="374b7925fd288000bd4deca283ff96f5"><span><div id="374b7925fd288000bd4deca283ff96f5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288000bd4deca283ff96f5" title="12.2.2 生命周期管理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.2.2 生命周期管理</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880a686f0ed8c99c72c4e" data-id="374b7925fd2880a686f0ed8c99c72c4e"><span><div id="374b7925fd2880a686f0ed8c99c72c4e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a686f0ed8c99c72c4e" title="12.2.3 主循环详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.2.3 主循环详解</span></span></h4><div class="notion-text notion-block-374b7925fd2880ed971fc83fb008bfd3">这是 CronService 最核心的部分。每 0.05 秒执行一次 tick：</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28804ca3abdce65bd86be2" data-id="374b7925fd28804ca3abdce65bd86be2"><span><div id="374b7925fd28804ca3abdce65bd86be2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28804ca3abdce65bd86be2" title="12.2.4 触发逻辑"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.2.4 触发逻辑</span></span></h4><div class="notion-text notion-block-374b7925fd2880d0b1e4ccacc0d947ef"><b>为什么 msg_id 和 sender_id 是伪值？</b></div><div class="notion-text notion-block-374b7925fd2880c48f35cc919c969cb4">因为这不是飞书用户的消息，而是定时服务产生的。使用特殊的 msg_id 和 sender_id 可以：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd288036a518e713d0ac6d70"><li>日志中容易区分来源</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880bf8298ceb57fe92aac"><li>避免与真实飞书消息 ID 冲突</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd2880789541d053047cfff3"><li>支持去重（如果同一任务被重复触发）</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880c08229ce053208be15" data-id="374b7925fd2880c08229ce053208be15"><span><div id="374b7925fd2880c08229ce053208be15" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880c08229ce053208be15" title="12.2.5 触发后状态更新"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.2.5 触发后状态更新</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28809e863adb8185306ace" data-id="374b7925fd28809e863adb8185306ace"><span><div id="374b7925fd28809e863adb8185306ace" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809e863adb8185306ace" title="12.2.6 Cron 表达式计算"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.2.6 Cron 表达式计算</span></span></h4><hr class="notion-hr notion-block-374b7925fd288097a715edb4cc220f49"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd288063a531f30c6e5774aa" data-id="374b7925fd288063a531f30c6e5774aa"><span><div id="374b7925fd288063a531f30c6e5774aa" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288063a531f30c6e5774aa" title="12.3 热加载（Hot-Reload）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.3 热加载（Hot-Reload）</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd28809695a3d929e38ef34e" data-id="374b7925fd28809695a3d929e38ef34e"><span><div id="374b7925fd28809695a3d929e38ef34e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809695a3d929e38ef34e" title="12.3.1 为什么需要热加载？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.3.1 为什么需要热加载？</span></span></h4><div class="notion-text notion-block-374b7925fd2880a48960e79a000bcacd">定时任务不是静态配置——用户可以通过 <code class="notion-inline-code">scheduler_mgr</code> Skill 动态创建、修改、删除任务。这些变更写入 <code class="notion-inline-code">tasks.json</code> 后，CronService 需要立即感知，而不是等下次重启。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd2880128236c1c58b567391" data-id="374b7925fd2880128236c1c58b567391"><span><div id="374b7925fd2880128236c1c58b567391" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880128236c1c58b567391" title="12.3.2 mtime 检测机制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.3.2 mtime 检测机制</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288059bd58e61cc7788079" data-id="374b7925fd288059bd58e61cc7788079"><span><div id="374b7925fd288059bd58e61cc7788079" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288059bd58e61cc7788079" title="12.3.3 加载逻辑"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.3.3 加载逻辑</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-374b7925fd288033b104f91e629b8edb" data-id="374b7925fd288033b104f91e629b8edb"><span><div id="374b7925fd288033b104f91e629b8edb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288033b104f91e629b8edb" title="12.3.4 原子持久化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.3.4 原子持久化</span></span></h4><hr class="notion-hr notion-block-374b7925fd2880e588d0da009b392a03"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880a099dffb93d1c2b2ff" data-id="374b7925fd2880a099dffb93d1c2b2ff"><span><div id="374b7925fd2880a099dffb93d1c2b2ff" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880a099dffb93d1c2b2ff" title="12.4 tasks.json 格式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.4 tasks.json 格式</span></span></h3><hr class="notion-hr notion-block-374b7925fd28803c845dfc320aebe33d"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880ebab42cc52d50e1778" data-id="374b7925fd2880ebab42cc52d50e1778"><span><div id="374b7925fd2880ebab42cc52d50e1778" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880ebab42cc52d50e1778" title="12.5 完整调用链路"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.5 完整调用链路</span></span></h3><hr class="notion-hr notion-block-374b7925fd288052aac4ca65e9ae8b17"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd288047acd2ea24301a8105" data-id="374b7925fd288047acd2ea24301a8105"><span><div id="374b7925fd288047acd2ea24301a8105" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd288047acd2ea24301a8105" title="12.6 为什么不用 asyncio 精确定时器？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.6 为什么不用 asyncio 精确定时器？</span></span></h3><div class="notion-text notion-block-374b7925fd288050aaa0c3e8e4b8e51f">初版 CronService 使用了 <code class="notion-inline-code">asyncio.wait_for(self._sleep.wait(), timeout=...)</code> 的精确等待方式，但后来改为简单的 tick 轮询。原因如下：</div><table class="notion-simple-table notion-block-374b7925fd288067ae08faa6c8de4bb5"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880ad8fedc40ddc65a150"><td class="" style="width:120px"><div class="notion-simple-table-cell">方案</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">精度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">代码复杂度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">可靠性</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880318cf9c0742fe97822"><td class="" style="width:120px"><div class="notion-simple-table-cell">精确定时器</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">微秒级</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">高</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">需要处理 wakeup 和各种边界情况</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880fead0fdd0af7cd1fd0"><td class="" style="width:120px"><div class="notion-simple-table-cell">Tick 轮询</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">50ms</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">低</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">简单可靠，不易出错</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd2880efaf65d5d1c3572106">对于定时任务来说，50ms 的精度完全够用（用户不会因为 50ms 的延迟而感知到差异），但代码简洁性和可靠性大大提升。</div><hr class="notion-hr notion-block-374b7925fd288067a7efe14d0cab7b42"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd2880b78dadcaa5130e4890" data-id="374b7925fd2880b78dadcaa5130e4890"><span><div id="374b7925fd2880b78dadcaa5130e4890" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd2880b78dadcaa5130e4890" title="12.7 本章小结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.7 本章小结</span></span></h3><table class="notion-simple-table notion-block-374b7925fd2880f08e7dc4947c5c5ea0"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-374b7925fd2880b99801f8cf7f8cd840"><td class="" style="width:120px"><div class="notion-simple-table-cell">组件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">关键实现</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880838656e68183376ce5"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">CronSchedule</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">调度配置</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">三种模式互斥：at / every / cron</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28809a8984efa5831a656e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">CronPayload</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">触发内容</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">routing_key + message（自然语言）</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd28805cb7e2dd14196070c6"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">CronState</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">运行状态</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">next_run / last_run / 状态 / 错误</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288053b1c7f12aaf3eccb4"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">CronService._loop()</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">主循环</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每 50ms tick，检查到期任务</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288010a5b3ef8a4f929bb0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">CronService._fire()</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">触发任务</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">构造伪 InboundMessage → Runner</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880608825c7335c5b8754"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">CronService._check_mtime()</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">热加载检测</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">mtime + 文件大小双重比较</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd2880e8abb4cfcbbe1585f6"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">CronService._save_store()</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">原子持久化</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">write-then-rename</div></td></tr><tr class="notion-simple-table-row notion-block-374b7925fd288005bbd5ec5bb312663e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">_next_cron_ms()</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Cron 计算</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">croniter 库 + 时区支持</div></td></tr></tbody></table><div class="notion-text notion-block-374b7925fd2880af8368d1952ed4fdc3"><b>设计亮点</b>：</div><ul class="notion-list notion-list-disc notion-block-374b7925fd28805b9c25c8b54bf29109"><li><b>统一处理管道</b>：定时消息和用户消息走完全相同的 Runner 链路</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28806c9966fdfa245e7e88"><li><b>热加载</b>：mtime 检测 + 立即重载，无需重启进程</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28807fbc4ddf125d14deec"><li><b>原子写入</b>：write-then-rename 防止文件损坏</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28800fbb94ede94165bb7f"><li><b>disabled 保留</b>：禁用的任务不丢失，方便后续重新启用</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28802eb8e7e0ddddd3c8dd"><li><b>cron 重新计算</b>：每次加载都重新计算 cron 的 next_run，确保表达式变更立即生效</li></ul><hr class="notion-hr notion-block-374b7925fd288006b860def8c5b3bddb"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-374b7925fd28809ca181de4fa452800f" data-id="374b7925fd28809ca181de4fa452800f"><span><div id="374b7925fd28809ca181de4fa452800f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#374b7925fd28809ca181de4fa452800f" title="12.8 练习与思考"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">12.8 练习与思考</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-374b7925fd2880e6b8d7f77a9d7d3ecc" style="list-style-type:decimal"><li><b>精度分析</b>：如果 tick_interval 从 50ms 改为 1000ms（1 秒），对定时任务的精度有什么影响？什么场景下可以接受？</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-374b7925fd2880f4b22de9e6b390bd6e" style="list-style-type:decimal"><li><b>原子写入</b>：为什么 _save_store 使用 write-then-rename 而不是直接写入？如果写入过程中进程崩溃，两种方式分别会有什么后果？</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-374b7925fd2880378a5bfe19b0fe1deb" style="list-style-type:decimal"><li><b>cron 表达式</b>：写出以下场景的 cron 表达式：</li><ol class="notion-list notion-list-numbered notion-block-374b7925fd2880378a5bfe19b0fe1deb" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-374b7925fd288016af32d5820e12a311"><li>每月 15 号 10:00</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28805fb754ebe991cb7a1f"><li>每周一、三、五 9:00 和 18:00</li></ul><ul class="notion-list notion-list-disc notion-block-374b7925fd28806c93c4c6f563200a5b"><li>工作日每小时的第 30 分钟</li></ul></ol></ol><ol start="4" class="notion-list notion-list-numbered notion-block-374b7925fd288047a6f9f6e9416ecc6d" style="list-style-type:decimal"><li><b>错误处理</b>：如果 <code class="notion-inline-code">_fire()</code> 中 dispatch 失败，<code class="notion-inline-code">last_status</code> 会被设为 &quot;error&quot;。这个错误信息对用户有什么用？如何改进错误报告？</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-374b7925fd28803cba06d2d09196176d" style="list-style-type:decimal"><li><b>并发安全</b>：如果两个任务同时到期，<code class="notion-inline-code">_fire()</code> 是顺序执行还是并发执行？如果是顺序执行，会不会导致后面的任务延迟触发？</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-374b7925fd2880c0980cd635ef5b3980" style="list-style-type:decimal"><li><b>时区处理</b>：如果用户在日本（UTC+9）创建了一个 cron 任务 <code class="notion-inline-code">0 9 * * *</code>，但 tasks.json 中 tz 写的是 &quot;Asia/Shanghai&quot;（UTC+8），实际触发时间是什么？如何避免这种问题？</li></ol><div class="notion-text notion-block-374b7925fd2880c39393f31ccfef6818">下一章将深入可观测性与日志系统——如何监控 XiaoPaw 的运行状态、记录 LLM 调用轨迹、暴露 Prometheus 指标。</div><div class="notion-blank notion-block-374b7925fd2880f89685dfc9480a66b9"> </div><div class="notion-callout notion-gray_background_co notion-block-374b7925fd2880128480f2ae78fb6440"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">欢迎您在底部评论区留言，一起交流~</div></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harness Engineering - 搭建Mini Harness]]></title>
            <link>https://tangly1024.com/article/Harness-Engineering-002</link>
            <guid>https://tangly1024.com/article/Harness-Engineering-002</guid>
            <pubDate>Fri, 03 Apr 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[搭建Mini Harness]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-35cb7925fd2880f8bd71d8855f2515eb"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-35cb7925fd28811aa6e0c7da907d4753"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text"><div class="notion-blank notion-block-35cb7925fd2881bca4f7f270274aa0ac"> </div></div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-35cb7925fd28801f827bd2ff7087f1a3" data-id="35cb7925fd28801f827bd2ff7087f1a3"><span><div id="35cb7925fd28801f827bd2ff7087f1a3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28801f827bd2ff7087f1a3" title="手搓 Mini Harness：用 11 个机制从零搭建一个生产级 AI Agent 控制框架"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">手搓 Mini Harness：用 11 个机制从零搭建一个生产级 AI Agent 控制框架</span></span></h2><blockquote class="notion-quote notion-block-35cb7925fd2880598d3dfd03b8fcc92d"><div>不用 LangChain，不用 LangGraph，不用任何 Agent 框架。用最裸的 Python + OpenAI SDK，从零搭建一个包含 11 个安全机制的 AI Agent 控制平面，并诚实回答一个问题：<b>Harness 到底值不值？</b></div></blockquote><hr class="notion-hr notion-block-35cb7925fd28806da821eaf26e038a52"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd288017897fd88c5ed234f6" data-id="35cb7925fd288017897fd88c5ed234f6"><span><div id="35cb7925fd288017897fd88c5ed234f6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288017897fd88c5ed234f6" title="一、背景：Agent 不是智能体，是一个脆弱的循环"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一、背景：Agent 不是智能体，是一个脆弱的循环</span></span></h3><div class="notion-text notion-block-35cb7925fd288044b42ed7f4a5d89386">一个基本事实：<b>AI Agent 不是智能实体，而是一个由代码组成的、可以反复调用 LLM 的 while 循环。</b> 这个循环本身非常脆弱——它会循环失控、会吞掉工具报错、会在长会话中把自己搞傻、会无声无息地烧掉你的钱。</div><div class="notion-text notion-block-35cb7925fd288097aa93e6293dfb8e89">这些脆弱点被归纳为 <b>八大故障模式</b>：</div><table class="notion-simple-table notion-block-35cb7925fd288075a46cf6b8c5071077"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd28805c8ab7cc1d193e913f"><td class="" style="width:120px"><div class="notion-simple-table-cell">编号</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">故障模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">典型表现</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880e99a11e1ba8754849a"><td class="" style="width:120px"><div class="notion-simple-table-cell">①</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">循环失控</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 陷入无限循环，反复调用同一个工具</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288079afbefb11765d156f"><td class="" style="width:120px"><div class="notion-simple-table-cell">②</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Context 溢出</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">长会话中上下文窗口被撑爆</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880f4a7d0dbcc8347feca"><td class="" style="width:120px"><div class="notion-simple-table-cell">③</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Cache Miss</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">重复计算导致成本飙升</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28805bb7a0ecec5cc83cd6"><td class="" style="width:120px"><div class="notion-simple-table-cell">④</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Tool 错误吞</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具执行失败被静默忽略，Agent 基于错误结果继续推理</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880d68081f6c0c76160e8"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑤</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">状态丢失</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">任务中断后无法续跑，前功尽弃</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880cf8442e711471eaabf"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑥</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">缺权限闸</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 可能执行危险命令（如 <code class="notion-inline-code">rm -rf</code>）</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288029bd57cab1d29443a3"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑦</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">缺自动化评审</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">LLM 自审等于作者自审，天然有偏差</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880caa2c8e12b973e395c"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑧</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">成本失控</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">异常循环导致 API 费用无限增长</div></td></tr></tbody></table><div class="notion-text notion-block-35cb7925fd2880078be3ca6e5657486d">针对这八大故障模式，Harness Engineering 使用了 <b>11 个机制（8 核心 + 3 扩展）</b>：</div><table class="notion-simple-table notion-block-35cb7925fd28806cbd5fffc136954cc6"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd288030b3f2fdc42e002f15"><td class="" style="width:120px"><div class="notion-simple-table-cell">编号</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">机制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">救的故障模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">实现文件</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880a18694fe13c5e529e0"><td class="" style="width:120px"><div class="notion-simple-table-cell">①</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent Loop</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">① 循环失控</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">core.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880b091f6f30765fd375d"><td class="" style="width:120px"><div class="notion-simple-table-cell">②</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Tool Use</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">④ tool 错误吞</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">core.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880738385f58bf0cc506d"><td class="" style="width:120px"><div class="notion-simple-table-cell">③</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Progress Tracking</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑤ 状态丢失</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">progress.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288098b809c58ce54be7de"><td class="" style="width:120px"><div class="notion-simple-table-cell">④</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Context Management</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">② context 溢出 / ③ cache miss</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">context.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288058a135cc550507dbe4"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑤</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Feature List</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">② context 溢出（源头防控）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">planner.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28804f884df1b1849a4262"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑥</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Verification Loop</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">④ tool 错误吞（下游验证）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">verifier.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880b0bc4dd2eaa1122765"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑦</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Subagents</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">② context 溢出 / ⑧ 成本失控</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">subagent.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880c2bec4f52c5e100016"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑧</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Generator-Evaluator</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑦ 缺自动化评审</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">evaluator.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880d6bf37f6b7da43e00e"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑨</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Permission Gate</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑥ 缺权限闸</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">permission.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880d29bfdeeb4060e7474"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑩</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Hooks</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">贯穿所有机制的事件挂钩基础设施</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">hooks.py</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880b6be7fe0d5436e27c0"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑪</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Token Budget</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑧ 成本失控</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">budget.py</code></div></td></tr></tbody></table><div class="notion-text notion-block-35cb7925fd288003a92dcd449a47bbdb">本文将逐一拆解这 11 个机制的核心实现，并在最后用一组真实的 E2E 对比数据来回答那个核心问题。</div><hr class="notion-hr notion-block-35cb7925fd2880c9bfa6e5b90dcd4cd1"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd28800bac26d0df5f8df409" data-id="35cb7925fd28800bac26d0df5f8df409"><span><div id="35cb7925fd28800bac26d0df5f8df409" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28800bac26d0df5f8df409" title="二、项目骨架：11 个文件 = 1 个配置中心 + 10 个机制模块"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二、项目骨架：11 个文件 = 1 个配置中心 + 10 个机制模块</span></span></h3><div class="notion-text notion-block-35cb7925fd2880119243dbccee6a2234">整个 Mini Harness 刻意不使用任何 Agent 框架——目的不是省事，而是<b>看清裸骨架</b>：每一块肌肉是什么、做什么、怎么连接。框架会帮你隐藏复杂度，但代价是你不知道出了问题该去哪里找。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28801fb6b8cd024666a026" data-id="35cb7925fd28801fb6b8cd024666a026"><span><div id="35cb7925fd28801fb6b8cd024666a026" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28801fb6b8cd024666a026" title="配置中心：HarnessConfig"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">配置中心：HarnessConfig</span></span></h4><div class="notion-text notion-block-35cb7925fd288087aee1eb8a8df853b5">所有 11 个机制共享一个配置对象，避免参数散落各处：</div><div class="notion-text notion-block-35cb7925fd28809ebcf9fbcca0d4b633">注意 <code class="notion-inline-code">max_steps=50</code>——它是机制①防止循环失控的硬刹车。</div><hr class="notion-hr notion-block-35cb7925fd2880329841c7c13be4a037"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880bcb579f90ea18dba17" data-id="35cb7925fd2880bcb579f90ea18dba17"><span><div id="35cb7925fd2880bcb579f90ea18dba17" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880bcb579f90ea18dba17" title="三、核心机制详解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">三、核心机制详解</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28807cb977ccf67438feb4" data-id="35cb7925fd28807cb977ccf67438feb4"><span><div id="35cb7925fd28807cb977ccf67438feb4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28807cb977ccf67438feb4" title="机制①②：Agent Loop + Tool Use（core.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制①②：Agent Loop + Tool Use（<code class="notion-inline-code">core.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd288049a14bf14c97510f9f">这是整个 Mini Harness 的心脏。Agent Loop 的本质是一个 <code class="notion-inline-code">while</code> 循环，Tool Use 是循环体内的工具调度器。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28800792b4e7e2a21b3693" data-id="35cb7925fd28800792b4e7e2a21b3693"><span><div id="35cb7925fd28800792b4e7e2a21b3693" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28800792b4e7e2a21b3693" title="Agent Loop 核心结构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Agent Loop 核心结构</span></span></h4><div class="notion-text notion-block-35cb7925fd28804dbc32d4093702f320">关键设计点：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd288065aa18cecd29480f70"><li><code class="notion-inline-code"><b>max_steps</b></code><b> 硬刹车</b>：<code class="notion-inline-code">while steps &lt; config.max_steps</code> 确保循环不会无限执行</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880d0b271d44bd8e8ae8c"><li><code class="notion-inline-code"><b>BudgetExceeded</b></code><b> 优雅终止</b>：token 超限时抛异常，由外层 try/except 捕获</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880788bcbd2263c81a76e"><li><b>Permission Gate 挂载点</b>：<code class="notion-inline-code">trigger_gate(&quot;pre_tool_use&quot;)</code> 在工具执行前拦截危险命令</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288007a977f36e21382861" data-id="35cb7925fd288007a977f36e21382861"><span><div id="35cb7925fd288007a977f36e21382861" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288007a977f36e21382861" title="Tool Use：自动反射 + 结构化错误回传"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Tool Use：自动反射 + 结构化错误回传</span></span></h4><div class="notion-text notion-block-35cb7925fd2880199857c8de13d5fbf7">传统做法需要开发者手工维护一份 JSON Schema 配置文件，极易与代码脱节。Harness 使用 Python 的 <code class="notion-inline-code">inspect.signature</code> 做运行时反射，自动从函数签名生成 tool schema：</div><div class="notion-text notion-block-35cb7925fd28804b9f00e6c6a7a0e6a3"><b>核心收益</b>：业务源码与调用契约 100% 自动同源同步。你在 Python 里增删一个参数，给大模型的 JSON 契约瞬间自适应改变。</div><div class="notion-text notion-block-35cb7925fd2880699abec5c13899d25b">工具执行层的 <code class="notion-inline-code">dispatch_tool</code> 是另一个关键设计——<b>绝不吞报错</b>：</div><div class="notion-text notion-block-35cb7925fd28809fb321cacd35f34290">传统做法要么让程序崩溃（Agent 死机），要么 <code class="notion-inline-code">try...except: pass</code> 吞掉异常（LLM 产生幻觉）。<code class="notion-inline-code">dispatch_tool</code> 走第三条路：将错误包裹成结构化 JSON 回传给 LLM，让 LLM 自己读错误信息、修正参数、重新调用。这是 Agent <b>自我纠偏</b>的核心枢纽。</div><hr class="notion-hr notion-block-35cb7925fd288021b104e2e3088cfad8"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880859ea5c4a1007f2b0c" data-id="35cb7925fd2880859ea5c4a1007f2b0c"><span><div id="35cb7925fd2880859ea5c4a1007f2b0c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880859ea5c4a1007f2b0c" title="机制③：Progress Tracking（progress.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制③：Progress Tracking（<code class="notion-inline-code">progress.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd2880c292ebd592e068e3fa">故障模式⑤（状态丢失）的解药。<code class="notion-inline-code">ProgressTracker</code> 通过 HookManager 的三个事件点把会话过程记录到 <code class="notion-inline-code">progress.md</code>：</div><div class="notion-text notion-block-35cb7925fd2880968ccad8a9e80bd2fd">核心 API 是一行 <code class="notion-inline-code">tracker.register_to(agent.hooks)</code>——零侵入接入，不需要改动 <code class="notion-inline-code">run_agent</code> 内部任何代码。</div><hr class="notion-hr notion-block-35cb7925fd28806b88cdf1ad66b71efb"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880659041d83c005743a7" data-id="35cb7925fd2880659041d83c005743a7"><span><div id="35cb7925fd2880659041d83c005743a7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880659041d83c005743a7" title="机制④：Context Management（context.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制④：Context Management（<code class="notion-inline-code">context.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd2880eea4c3e5de7d5727b2">故障模式②（context 溢出）和③（cache miss）的解药。核心策略：<b>不改 toolset、不改 memory、不改 system prompt</b>（三铁律），只对 messages 做结构化压缩。</div><div class="notion-text notion-block-35cb7925fd288062b2d8fca43a9cbfd7">三铁律的出处是 <a class="notion-link" href="https://agents.md/" target="_blank" rel="noopener noreferrer">AGENTS.md</a> 规范——压缩时绝不能改变 agent 的能力边界（toolset）、已有知识（memory）和行为规范（system prompt）。</div><hr class="notion-hr notion-block-35cb7925fd28808a98dce097bf20f098"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28800e91cbc78da374ae12" data-id="35cb7925fd28800e91cbc78da374ae12"><span><div id="35cb7925fd28800e91cbc78da374ae12" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28800e91cbc78da374ae12" title="机制⑤：Feature List（planner.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制⑤：Feature List（<code class="notion-inline-code">planner.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd2880659d41eb6fb511bfd4">故障模式②（context 溢出）的源头防控。核心思想：<b>用一个外部数据结构承载任务状态，把&quot;全局规划的复杂性&quot;从 LLM 的 context 里剥离出去。</b></div><div class="notion-text notion-block-35cb7925fd2880a19d68df6bf3efdbb2">三种模式对应任务生命周期的三个阶段：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd288040baadcb474b5ee832"><li><b>替换模式</b>（<code class="notion-inline-code">merge=False</code>）：任务开始时创建清单</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880e797b3f29aec8a934a"><li><b>合并模式</b>（<code class="notion-inline-code">merge=True</code>）：执行过程中更新状态（<code class="notion-inline-code">pending → in_progress → completed</code>）</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd28800caae4c4590c829dfb"><li><b>查询模式</b>（<code class="notion-inline-code">todos=None</code>）：任务完成前检查是否全部完成</li></ul><div class="notion-text notion-block-35cb7925fd2880e88321f9b089670adc">在 E2E demo 的 7 步任务中，有 5 步是 todo 操作。这不是低效，而是刻意设计：<b>每步只做一件事的纪律，是防止 context 溢出的源头防控。</b></div><hr class="notion-hr notion-block-35cb7925fd288055b0bbdb440b0cc430"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880fd9899cf8fc0e4ca1d" data-id="35cb7925fd2880fd9899cf8fc0e4ca1d"><span><div id="35cb7925fd2880fd9899cf8fc0e4ca1d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880fd9899cf8fc0e4ca1d" title="机制⑥：Verification Loop（verifier.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制⑥：Verification Loop（<code class="notion-inline-code">verifier.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd2880058888f9c406918f1d">故障模式④（tool 错误吞）的下游验证。核心原则：<b>验证必须由工具完成，而不是由 LLM 完成。</b> LLM 的自我确认没有验证效力——它倾向于说&quot;我检查过了&quot;，但无法真正运行自己生成的代码。</div><div class="notion-text notion-block-35cb7925fd2880889f51e0023c6fead5">两层验证架构：</div><div class="notion-text notion-block-35cb7925fd288072861cc4089ae8c081"><b>第一层（引导层）</b>：通过 system prompt 植入验证思维：</div><div class="notion-text notion-block-35cb7925fd288015b2d8f95e0b37b3c1"><b>第二层（执行层）</b>：用真实工具验证——例如通过 <code class="notion-inline-code">subprocess</code> 调用 <code class="notion-inline-code">pytest</code> 验证生成的代码是否真的能跑通。工具返回的确定性结果（pass/fail）比 LLM 的自我确认可靠得多。</div><div class="notion-text notion-block-35cb7925fd2880539a10e2c279120b1c">与第二章错误回传的本质区别：</div><table class="notion-simple-table notion-block-35cb7925fd288033ba16e6b06bae5cce"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880a6bf27ce351e0f29f7"><td class="" style="width:120px"><div class="notion-simple-table-cell">机制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">触发时机</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">验证主体</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">作用</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880d6ab17fa994bb7dda0"><td class="" style="width:120px"><div class="notion-simple-table-cell">结构化错误回传</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具调用本身出错时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具执行层</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">确保错误不被吞掉</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880e4aa36c69cbc52c868"><td class="" style="width:120px"><div class="notion-simple-table-cell">Verification Loop</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具调用成功后</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">独立验证工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">确保结果本身是正确的</div></td></tr></tbody></table><hr class="notion-hr notion-block-35cb7925fd28805bbf3ce7cc6b35ab8b"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28802e9e4ecc1279f50497" data-id="35cb7925fd28802e9e4ecc1279f50497"><span><div id="35cb7925fd28802e9e4ecc1279f50497" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28802e9e4ecc1279f50497" title="机制⑦：Subagents（subagent.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制⑦：Subagents（<code class="notion-inline-code">subagent.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd28805c9832cbd9465b52f0">故障模式②（context 溢出）和⑧（成本失控）的解药。核心设计：<b>子 agent 拥有完全独立的 messages 列表，父 agent 的对话历史对子 agent 不可见。</b></div><div class="notion-text notion-block-35cb7925fd288010ac72da6faf366340"><b>父子迭代预算不是加法，是乘法。</b> 假设父 agent <code class="notion-inline-code">max_steps=50</code>，每步都 spawn 一个子 agent（<code class="notion-inline-code">max_steps=50</code>），最坏情况是 50 × 50 = 2500 步。这是 Manus 早期版本的真实教训。</div><div class="notion-text notion-block-35cb7925fd288092b532c98c326bcabc">三条子 agent 设计铁律：</div><ol start="1" class="notion-list notion-list-numbered notion-block-35cb7925fd2880f084e1cf4232dfca67" style="list-style-type:decimal"><li><b>独立迭代上限</b>：子 agent 步数上限必须比父更小（推荐父 50 / 子 10）</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-35cb7925fd288026960bc6587355eb39" style="list-style-type:decimal"><li><b>结果长度上限</b>：子任务返回内容必须截断，防止撑爆父 context</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-35cb7925fd28805cb74cc26040f04d62" style="list-style-type:decimal"><li><b>成本上限</b>：子任务必须设置 Token Budget，达到阈值强制终止</li></ol><hr class="notion-hr notion-block-35cb7925fd2880c38306d81d0ae7ce72"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880938b41c1378a8116e2" data-id="35cb7925fd2880938b41c1378a8116e2"><span><div id="35cb7925fd2880938b41c1378a8116e2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880938b41c1378a8116e2" title="机制⑧：Generator-Evaluator（evaluator.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制⑧：Generator-Evaluator（<code class="notion-inline-code">evaluator.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd28800b936acdcd861cd5bf">故障模式⑦（缺自动化评审）的解药。核心思想：<b>生成和评估分离，用独立 context 的另一个 LLM 做客观审查。</b></div><div class="notion-text notion-block-35cb7925fd28801587d1da40b576afe9">为什么 LLM 自审不可靠？LLM 在生成内容时，注意力已被当前推理路径&quot;锚定&quot;。当被要求&quot;检查自己的输出&quot;时，它倾向于沿着相同的推理路径再走一遍，而不是真正以批判视角重新审视。<b>生成者和审查者读的是同一份 messages 历史，思维起点相同，盲点也相同。</b></div><div class="notion-text notion-block-35cb7925fd28803eaae5ee53ad55476e">两个关键设计：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880378b02d502e0fbc7c7"><li><code class="notion-inline-code"><b>temperature=0.3</b></code>：评审需要稳定性和一致性，低温度保证同样的候选方案每次评审得分接近</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880788193f3e51448c9d0"><li><b>Evaluator 的 system prompt 完全独立</b>：它不知道 Generator 的内部推理过程，只看最终输出</li></ul><div class="notion-text notion-block-35cb7925fd2880dca2a6fec1f97d3bdd">与 Verification Loop 的关系：两者可以组合使用——先用 Verification Loop 做客观验证（pytest），再用 Generator-Evaluator 做主观质量评审，构成双重质量保障。</div><hr class="notion-hr notion-block-35cb7925fd28804f8944c7bca8589b6c"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd28800b90f6d4d3cde9e47a" data-id="35cb7925fd28800b90f6d4d3cde9e47a"><span><div id="35cb7925fd28800b90f6d4d3cde9e47a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28800b90f6d4d3cde9e47a" title="四、三个生产级扩展机制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">四、三个生产级扩展机制</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28804aae04f395598a44e8" data-id="35cb7925fd28804aae04f395598a44e8"><span><div id="35cb7925fd28804aae04f395598a44e8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28804aae04f395598a44e8" title="机制⑩：Hooks 事件总线（hooks.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制⑩：Hooks 事件总线（<code class="notion-inline-code">hooks.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd28807dafe7f0e3fd6bfdb4">Hooks 本身不直接救任何一条故障模式，而是为 Permission Gate、Progress Tracker 和 Budget Guard 提供挂载基础设施。它是整个 Harness 的&quot;神经系统&quot;。</div><div class="notion-text notion-block-35cb7925fd28806cb9b4e4a261bc6465"><b>六大标准事件</b>：</div><div class="notion-text notion-block-35cb7925fd2880228802d16cd963747f"><code class="notion-inline-code">HookManager</code> 提供两类接口：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd28802e8a72c99e5b8d831d"><li><code class="notion-inline-code"><b>trigger(event)</b></code>：普通事件，顺序调用所有 handler，单个失败不影响其他</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880128e98cae7e855d7ac"><li><code class="notion-inline-code"><b>trigger_gate(event)</b></code>：门控事件，任一 handler 返回 <code class="notion-inline-code">(False, reason)</code> 则立即 veto</li></ul><div class="notion-text notion-block-35cb7925fd28800f836de4a8507d6c4e">关键安全策略：普通事件 handler 失败只记录不中断；门控事件 handler 失败<b>视为拦截</b>——因为允许一个&quot;门坏了&quot;的危险命令执行比多记录一条日志严重得多。</div><hr class="notion-hr notion-block-35cb7925fd288068b8e4db36b6c56365"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288002ba8ff66aaf201ad8" data-id="35cb7925fd288002ba8ff66aaf201ad8"><span><div id="35cb7925fd288002ba8ff66aaf201ad8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288002ba8ff66aaf201ad8" title="机制⑨：Permission Gate（permission.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制⑨：Permission Gate（<code class="notion-inline-code">permission.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd2880fbb978c80854c05719">故障模式⑥（缺权限闸）的解药。挂在 <code class="notion-inline-code">pre_tool_use</code> gate 事件上，在执行前拦截危险命令。</div><div class="notion-text notion-block-35cb7925fd28805da9a4e4199ac2c45e">核心实现是一个正则黑名单，包含 14 条危险模式（如 <code class="notion-inline-code">rm -rf</code>、<code class="notion-inline-code">sudo</code>、<code class="notion-inline-code">chmod 777</code>、<code class="notion-inline-code">curl | bash</code> 等）。任何匹配的工具调用参数都会被 veto，返回 <code class="notion-inline-code">(False, reason)</code> 阻止执行。</div><hr class="notion-hr notion-block-35cb7925fd2880e48de4c683d4ca655b"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880948b0de1bd7fa464f4" data-id="35cb7925fd2880948b0de1bd7fa464f4"><span><div id="35cb7925fd2880948b0de1bd7fa464f4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880948b0de1bd7fa464f4" title="机制⑪：Token Budget（budget.py）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">机制⑪：Token Budget（<code class="notion-inline-code">budget.py</code>）</span></span></h4><div class="notion-text notion-block-35cb7925fd2880c9b7e5cde236d54fed">故障模式⑧（成本失控）的解药。<code class="notion-inline-code">BudgetGuard</code> 在每次 LLM 调用后累计 token 消耗，超限时抛出 <code class="notion-inline-code">BudgetExceeded</code> 异常，由 <code class="notion-inline-code">run_agent</code> 的 try/except 捕获后优雅终止。</div><hr class="notion-hr notion-block-35cb7925fd2880bf8015cd40d6380e31"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880a38f1de585be3e3d87" data-id="35cb7925fd2880a38f1de585be3e3d87"><span><div id="35cb7925fd2880a38f1de585be3e3d87" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880a38f1de585be3e3d87" title="五、E2E 真实数据：Harness 到底值不值？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">五、E2E 真实数据：Harness 到底值不值？</span></span></h3><div class="notion-text notion-block-35cb7925fd2880749947fd971cc91de6">以下是 2026-04-22 真实跑通的数据（模型：<code class="notion-inline-code">deepseek-chat</code>，任务：分析 <code class="notion-inline-code">main.py</code> 的重复代码并给出重构建议）：</div><table class="notion-simple-table notion-block-35cb7925fd288027ad5dcb9e18f5548d"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880b893edcc83c71da542"><td class="" style="width:120px"><div class="notion-simple-table-cell">维度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Baseline（单轮调用）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Full Harness（8 机制）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">倍率</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880a89456ffa5cd38969a"><td class="" style="width:120px"><div class="notion-simple-table-cell">步骤数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">7</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">7×</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288073b401e7a24d7de75d"><td class="" style="width:120px"><div class="notion-simple-table-cell">耗时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">35.45 s</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">94.02 s</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2.65×</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880d8915cd24f304fe67a"><td class="" style="width:120px"><div class="notion-simple-table-cell">总 tokens</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">1,104</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">15,053</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>13.6×</b></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880f398d1e53d2875d898"><td class="" style="width:120px"><div class="notion-simple-table-cell">答案字符数</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2,498</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2,819</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">+13%</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880dc866cf6b27c3d8a47"><td class="" style="width:120px"><div class="notion-simple-table-cell">成本 (USD)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">$0.0697</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28806f8d9cc2a1432742b3"><td class="" style="width:120px"><div class="notion-simple-table-cell">预算上限</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">$0.50</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28808594f4fb69da386d8d"><td class="" style="width:120px"><div class="notion-simple-table-cell">Permission 拦截</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">0</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">0（本次无危险命令）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880daafc9e79f7df22e0b"><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="http://progress.md/" target="_blank" rel="noopener noreferrer">progress.md</a></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">已落盘（7 条记录）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr></tbody></table><div class="notion-text notion-block-35cb7925fd2880c29b5ccd90e598b254"><b>13.6× tokens，2.65× 耗时。</b> 这不是 Harness 效率低，而是它的成本结构。你用 13 倍的 tokens 换来了三个用单轮调用永远买不到的属性：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880eb832cdfd2eb6ead4c"><li><b>可观察性</b>：<code class="notion-inline-code">progress.md</code> 落盘了 7 条记录，每一步做了什么、调用了哪个工具、结果是什么，全程可追溯。Baseline 跑完了，你只能看到最终答案。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880f2991ee8b38f641ad6"><li><b>可干预性</b>：Permission Gate 就绪，任何危险命令都会被在执行前拦截。Baseline 里 agent 直接执行任何工具，包括 <code class="notion-inline-code">rm -rf</code>——你没有机会干预。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880de920dee8ac3507595"><li><b>可控性</b>：Token Budget 守住了整个任务，$0.0697 &lt; $0.50 上限。如果任务出现异常循环，Budget 会触发优雅终止而不是无限烧钱。</li></ul><hr class="notion-hr notion-block-35cb7925fd2880158f28e60c50d19ece"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880ec9772f4cf3bc54966" data-id="35cb7925fd2880ec9772f4cf3bc54966"><span><div id="35cb7925fd2880ec9772f4cf3bc54966" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880ec9772f4cf3bc54966" title="六、三条核心结论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">六、三条核心结论</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880489448f4817c560c76" data-id="35cb7925fd2880489448f4817c560c76"><span><div id="35cb7925fd2880489448f4817c560c76" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880489448f4817c560c76" title="结论一：Harness 的 13× tokens 换的是&quot;三性&quot;，不是低效"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结论一：Harness 的 13× tokens 换的是&quot;三性&quot;，不是低效</span></span></h4><div class="notion-text notion-block-35cb7925fd288035b00cdef4ea71eaf8">成本直觉建立后，你才能判断&quot;这个任务值不值得上 Harness&quot;——不是所有任务都需要，但凡是你需要追溯、拦截、兜底的任务，这个成本就是必要的。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288061bcc1dcb1306883d2" data-id="35cb7925fd288061bcc1dcb1306883d2"><span><div id="35cb7925fd288061bcc1dcb1306883d2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288061bcc1dcb1306883d2" title="结论二：Harness 与底层模型解耦"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结论二：Harness 与底层模型解耦</span></span></h4><div class="notion-text notion-block-35cb7925fd288023a7c8cec82f01e835">Mini Harness 基于 OpenAI Python SDK 写成，但每个机制都能在 Claude Code、Codex 里找到对应实现。如果把 <code class="notion-inline-code">core.py</code> 的主循环换到 Anthropic SDK，只需要动 API 调用、循环结束判断、tool call 位置、结果回写格式、tool schema 字段这 5 处——Context Management、Progress Tracking、Permission Gate 等深层机制一行代码都不需要动。<b>Harness 的架构逻辑与模型提供商是完全解耦的。</b></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880cf9606e86fc996abf8" data-id="35cb7925fd2880cf9606e86fc996abf8"><span><div id="35cb7925fd2880cf9606e86fc996abf8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880cf9606e86fc996abf8" title="结论三：Harness 会 go stale，它是工具不是信仰"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结论三：Harness 会 go stale，它是工具不是信仰</span></span></h4><div class="notion-text notion-block-35cb7925fd288062ad8bfee76aae4c10">Anthropic 在 2026-03-24 的博客中坦率承认：&quot;Every component in a harness encodes an assumption about what the model can&#x27;t do on its own&quot;。今天你为 agent 加 Permission Gate，是因为模型可能误执行危险命令；如果未来模型默认就能做到&quot;不执行危险命令&quot;，这个组件就可以从 Harness 里移除。<b>随着模型能力提升，Harness 的组件会慢慢过时——这不是劝退，是让你建立正确的成本直觉。</b></div><hr class="notion-hr notion-block-35cb7925fd2880f68453d328cdd983fe"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd28802493b3f53f3033f39a" data-id="35cb7925fd28802493b3f53f3033f39a"><span><div id="35cb7925fd28802493b3f53f3033f39a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28802493b3f53f3033f39a" title="七、Mini Harness vs 生产级工具对照"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">七、Mini Harness vs 生产级工具对照</span></span></h3><table class="notion-simple-table notion-block-35cb7925fd288081b26ddf2746a86155"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880d68b01dbbe5e0f5353"><td class="" style="width:120px"><div class="notion-simple-table-cell">机制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Mini Harness</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Claude Code 生产版</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenAI Codex 生产版</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288096b2e3c790e15ef102"><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent Loop</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">while</code> + <code class="notion-inline-code">max_steps=50</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">多层事件驱动</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">App Server JSON-RPC</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28805fb6f4f384f29fa6ac"><td class="" style="width:120px"><div class="notion-simple-table-cell">Context</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">head(2)+tail(6)+middle summary</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">5 层 compaction pipeline</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="http://agents.md/" target="_blank" rel="noopener noreferrer">AGENTS.md</a> 渐进披露</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880d283e6fba86820e2ff"><td class="" style="width:120px"><div class="notion-simple-table-cell">Progress</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">progress.md</code> 追加写</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">claude-progress.txt</code> + git</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">待补充</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28809c8d7be1772e21b734"><td class="" style="width:120px"><div class="notion-simple-table-cell">Feature List</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">todo_tool</code> JSON 状态机</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">200+ 项结构化清单</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="http://plans.md/" target="_blank" rel="noopener noreferrer">PLANS.md</a> 持久化</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28808eaf13e06d918e33e6"><td class="" style="width:120px"><div class="notion-simple-table-cell">Verification</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">pytest subprocess</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Puppeteer MCP 真机</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">structural test</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28807f9e08ec01c933388c"><td class="" style="width:120px"><div class="notion-simple-table-cell">Subagents</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">delegate</code> 递归隔离</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/agent</code> + 独立 workflow</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">待补充</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880ff9878f50c95bc9bc0"><td class="" style="width:120px"><div class="notion-simple-table-cell">Permission</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">正则黑名单 14 条</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">27 个 hook + 规则矩阵</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">sandbox policy</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288089ad4cfbae1da70e35"><td class="" style="width:120px"><div class="notion-simple-table-cell">Hooks</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">HookManager</code> 6 事件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Claude Code 27 事件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">middleware 3 hook</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880088d9bd5486a5891d7"><td class="" style="width:120px"><div class="notion-simple-table-cell">Budget</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">BudgetGuard</code> + <code class="notion-inline-code">BudgetExceeded</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">token budget + iteration cap</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">per-model quota</div></td></tr></tbody></table><div class="notion-text notion-block-35cb7925fd288014956fcfcabdc1121c">Mini Harness 是&quot;裸骨架&quot;——功能极简，但结构透明；生产工具是成熟系统——功能丰富，但内部封装。学完骨架，以后读生产工具的源码时，你会认出每一块肌肉。</div><hr class="notion-hr notion-block-35cb7925fd2880b4ad65cbbba54708a7"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880b5a831f6b34f93ae68" data-id="35cb7925fd2880b5a831f6b34f93ae68"><span><div id="35cb7925fd2880b5a831f6b34f93ae68" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880b5a831f6b34f93ae68" title="附录：关键术语快速检索"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">附录：关键术语快速检索</span></span></h3><table class="notion-simple-table notion-block-35cb7925fd2880d38688e1e916d496d3"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880699488f28ae84626d8"><td class="" style="width:120px"><div class="notion-simple-table-cell">术语 / 机制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心文件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">关键函数 / 类</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880878e25efee207ba98e"><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent Loop</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">core.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">run_agent</code>, <code class="notion-inline-code">while steps &lt; config.max_steps</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28800f94d5fee02613e459"><td class="" style="width:120px"><div class="notion-simple-table-cell">Tool Use</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">core.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">dispatch_tool</code>, <code class="notion-inline-code">_build_tool_schemas</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288025a3c0c6528cb2d763"><td class="" style="width:120px"><div class="notion-simple-table-cell">Progress Tracking</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">progress.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">ProgressTracker.register_to</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28808b9fdec9764b7686a0"><td class="" style="width:120px"><div class="notion-simple-table-cell">Context Management</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">context.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">compress_if_needed</code>, <code class="notion-inline-code">estimate_tokens</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28806c8ee5e648e7f74595"><td class="" style="width:120px"><div class="notion-simple-table-cell">Feature List</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">planner.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">todo_tool</code>（替换/合并/查询三模式）</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880bb9592fc5aedaf5335"><td class="" style="width:120px"><div class="notion-simple-table-cell">Verification Loop</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">verifier.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">verify_by_pytest</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880518f0ef885d7772e06"><td class="" style="width:120px"><div class="notion-simple-table-cell">Subagents</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">subagent.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">delegate</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880588abcf7c4c7db2b5f"><td class="" style="width:120px"><div class="notion-simple-table-cell">Generator-Evaluator</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">evaluator.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">evaluate</code>, <code class="notion-inline-code">temperature=0.3</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28807c85ead2c4cb240f64"><td class="" style="width:120px"><div class="notion-simple-table-cell">Hooks</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">hooks.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">HookManager</code>, <code class="notion-inline-code">trigger_gate</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880f6bcdfd626bbac7aab"><td class="" style="width:120px"><div class="notion-simple-table-cell">Permission Gate</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">permission.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">PermissionGate.check</code>, 14 条黑名单</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28804086bfc63c0baa8948"><td class="" style="width:120px"><div class="notion-simple-table-cell">Token Budget</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">budget.py</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">BudgetGuard.add</code>, <code class="notion-inline-code">BudgetExceeded</code></div></td></tr></tbody></table><hr class="notion-hr notion-block-35cb7925fd288084be6ddf9e55577fd6"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd288017af5acb4d06a64a09" data-id="35cb7925fd288017af5acb4d06a64a09"><span><div id="35cb7925fd288017af5acb4d06a64a09" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288017af5acb4d06a64a09" title="参考引用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">参考引用</span></span></h3><table class="notion-simple-table notion-block-35cb7925fd2880b7a00fc9088ed0c52f"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd28809b8f3ce49e137286bf"><td class="" style="width:120px"><div class="notion-simple-table-cell">来源</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">日期</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">URL</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28808eb59bf9804ad24741"><td class="" style="width:120px"><div class="notion-simple-table-cell">Anthropic · Effective Harnesses for Long-Running Agents</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2025-11-26</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents" target="_blank" rel="noopener noreferrer">链接</a></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288063a715f5b3cc5cd746"><td class="" style="width:120px"><div class="notion-simple-table-cell">Anthropic · Harness Design for Long-Running Apps</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-03-24</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="https://www.anthropic.com/engineering/harness-design-long-running-apps" target="_blank" rel="noopener noreferrer">链接</a></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288054b48dc1f1a0633af5"><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenAI · Unlocking the Codex Harness</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-02-04</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="https://openai.com/index/unlocking-the-codex-harness/" target="_blank" rel="noopener noreferrer">链接</a></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880ef981de5d092cfd03b"><td class="" style="width:120px"><div class="notion-simple-table-cell">Phil Schmid · The Importance of Agent Harness in 2026</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-01-05</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="https://www.philschmid.de/agent-harness-2026" target="_blank" rel="noopener noreferrer">链接</a></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880c8919bdbe1be89ca6d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="http://agents.md/" target="_blank" rel="noopener noreferrer">AGENTS.md</a> 规范</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="https://agents.md/" target="_blank" rel="noopener noreferrer">链接</a></div></td></tr></tbody></table><hr class="notion-hr notion-block-35cb7925fd2880b7ae27eca051057263"/><div class="notion-text notion-block-35cb7925fd2880a08defe7fe3a3fddb2"><em>本文基于 2026 年 4 月技术状态编写，使用 </em><em><code class="notion-inline-code">deepseek-chat</code></em><em> 模型验证 E2E demo。依赖版本：</em><em><code class="notion-inline-code">openai==2.26.0</code></em><em>、</em><em><code class="notion-inline-code">python-dotenv==1.2.2</code></em><em>、</em><em><code class="notion-inline-code">pytest==9.0.3</code></em><em>、</em><em><code class="notion-inline-code">httpx==0.28.1</code></em><em>。</em></div><div class="notion-blank notion-block-35cb7925fd28808a9010f541357d052f"> </div><div class="notion-blank notion-block-35cb7925fd2881d28568c602fd27854f"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-35cb7925fd2881e0bd37fc2851f07b5b" data-id="35cb7925fd2881e0bd37fc2851f07b5b"><span><div id="35cb7925fd2881e0bd37fc2851f07b5b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2881e0bd37fc2851f07b5b" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-35cb7925fd28816189eaf1960590577f"><li><a class="notion-link" href="https://appze9inzwc2314.pc.xiaoe-tech.com/p/t_pc/goods_pc_detail/goods_detail/p_69defc29e4b0694c5baf93fd?product_id=p_69defc29e4b0694c5baf93fd" target="_blank" rel="noopener noreferrer">大模型Agent智能体开发实战</a></li></ul><div class="notion-blank notion-block-35cb7925fd288100a824e2444191d233"> </div><div class="notion-callout notion-gray_background_co notion-block-35cb7925fd28814d9fadd1ae34bd9d4c"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">欢迎您在底部评论区留言，一起交流~</div></div><div class="notion-blank notion-block-35cb7925fd2881559c7be4670920ea8c"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harness Engineering - 原理与概念]]></title>
            <link>https://tangly1024.com/article/Harness-Engineering-001</link>
            <guid>https://tangly1024.com/article/Harness-Engineering-001</guid>
            <pubDate>Fri, 03 Apr 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[原理与概念]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-35cb7925fd28807db491e095100325c8"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-35cb7925fd28801c8baec7e0bb5f43c1"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text"><blockquote class="notion-quote notion-block-35cb7925fd288092ae50daf099d419eb"><div>本文聚焦 Claude Code / Codex / Cursor 这类 AI 编程产品背后那套共同的工程系统——<b>驾驭工程（Harness Engineering）</b>。它是 <code class="notion-inline-code">Agent = Model + Harness</code> 公式的右半部分，也是 2025-2026 年 AI 工程社群共同识别出的新学科。</div><div class="notion-text notion-block-35cb7925fd2880ef99b3ea642fc9ff41">明明底层都是 Anthropic 或 OpenAI 的模型，为什么有的 Agent 能持续跑 30 分钟不失败，有的三轮就失控？为什么同样是 Sonnet 4.6，裸 API 调用和 Claude Code 的产出质量差了一个数量级？答案全部收敛到这套系统上。</div><div class="notion-text notion-block-35cb7925fd2880d1bcf6f215f55204aa">📅 <b>时效性说明</b>：本文全部数据与引用截止 2026 年 4 月。</div></blockquote></div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-35cb7925fd288014bee0e39d692e2e08" data-id="35cb7925fd288014bee0e39d692e2e08"><span><div id="35cb7925fd288014bee0e39d692e2e08" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288014bee0e39d692e2e08" title="Harness Engineering 驾驭工程：原理与概念"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Harness Engineering 驾驭工程：原理与概念</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd288031a3e3f09dfe5562b9" data-id="35cb7925fd288031a3e3f09dfe5562b9"><span><div id="35cb7925fd288031a3e3f09dfe5562b9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288031a3e3f09dfe5562b9" title="一、驾驭工程是什么"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一、驾驭工程是什么</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28809b9259c272f64351dc" data-id="35cb7925fd28809b9259c272f64351dc"><span><div id="35cb7925fd28809b9259c272f64351dc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28809b9259c272f64351dc" title="1.1 三层次能力对比"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.1 三层次能力对比</span></span></h4><div class="notion-text notion-block-35cb7925fd288094a0c9f893cc3b8add">很多人认为 ChatGPT、ChatGPT + Code Interpreter、Claude Code 三者的差距在于&quot;模型越来越强&quot;。这是一个典型误解。下面这张表用六个维度逐条比对：</div><div class="notion-text notion-block-35cb7925fd288053b927da22ff00f1b6"><b>表 1-1 三层次能力对比</b></div><table class="notion-simple-table notion-block-35cb7925fd2880b3b77ae1e28ce91dde"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd288061aac8d666abc44c60"><td class="" style="width:120px"><div class="notion-simple-table-cell">维度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">ChatGPT（裸对话）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">ChatGPT + Code Interpreter</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Claude Code</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288002bcfdeecc7bde33ca"><td class="" style="width:120px"><div class="notion-simple-table-cell">能写代码吗</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880e294f3dc09b73267c6"><td class="" style="width:120px"><div class="notion-simple-table-cell">能真跑代码吗</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能（沙箱内）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能（你本地）</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880c69b19fb1db6c42d73"><td class="" style="width:120px"><div class="notion-simple-table-cell">能读写你的文件系统吗</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否（只能沙箱临时文件）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能（整个项目目录）</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28801a8193d447648cbdff"><td class="" style="width:120px"><div class="notion-simple-table-cell">能跨工具编排吗（git/pytest/shell）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">部分（Python 内）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880378bc1e098ba5dd216"><td class="" style="width:120px"><div class="notion-simple-table-cell">能持续 30 分钟不失败吗</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否（context 溢出）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能（机制保护）</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28800f877df859a20b31ec"><td class="" style="width:120px"><div class="notion-simple-table-cell">任务失败时会自己补救吗</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">否</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">部分（在同一回合内）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">能（跨回合 + 跨 session）</div></td></tr></tbody></table><div class="notion-text notion-block-35cb7925fd28804da322e339452eb702"><b>前两行三列几乎没有差距</b>（都能写代码、都能在沙箱里跑），但从第 3 行开始三列几乎跨了三个时代。而三列用的模型——GPT-5 / GPT-5 / Sonnet 4.6——都是当前最前沿的旗舰，能力基础在同一梯队。造成巨大落差的只有一个变量：模型<b>外面</b>那一层，也就是 harness。</div><div class="notion-text notion-block-35cb7925fd28802ea514f2691aba67b3">换个更直接的说法：把 Claude Code 里的 Sonnet 4.6 换成 GPT-5，它还是比裸的 GPT-5 强；把裸 ChatGPT 的模型升级到 Sonnet 4.6，它也追不上最朴素的 Claude Code。因为一次裸 API 调用没有文件系统、没有 git commit 能力、没有跨 session 的进度文件——这些差异不在模型权重里，在<b>调用模型的那套系统</b>里。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880b58a51d70301d7878a" data-id="35cb7925fd2880b58a51d70301d7878a"><span><div id="35cb7925fd2880b58a51d70301d7878a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880b58a51d70301d7878a" title="1.2 Agent = Model + Harness"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.2 Agent = Model + Harness</span></span></h4><blockquote class="notion-quote notion-block-35cb7925fd2880a1b96ec0d341aab759"><div><b>Agent = Model + Harness</b></div><div class="notion-text notion-block-35cb7925fd2880cf90beed9676e97d92">—— Vivek Trivedy 在<a class="notion-link" href="https://vtrivedy.com/posts/claude-code-sdk-haas-harness-as-a-service" target="_blank" rel="noopener noreferrer">首篇 HaaS 博文</a>（2025-09-23）中给出这一公式化表达；Birgitta Böckeler 于 2026-04-02 在 <a class="notion-link" href="https://martinfowler.com/articles/harness-engineering.html" target="_blank" rel="noopener noreferrer">martinfowler.com</a> 整理传播。</div></blockquote><div class="notion-text notion-block-35cb7925fd288009b4a3facb573e76c5">这个公式可以类比成 F1 赛车：<b>Model 是引擎，Harness 是底盘、变速箱、空气动力学、刹车、方向盘</b>。引擎再强，没有底盘和刹车，跑不过 100 公里就失败；引擎差一点，但底盘调校好了，能在一个赛季跑满二十几个大奖赛。</div><div class="notion-text notion-block-35cb7925fd2880cbb234d002a4457310">先记住一个数字作为公式的第一块硬证据：<b>同模型只改 harness，Terminal Bench 2.0 从 52.8% → 66.5%，+13.7 个百分点</b>。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288015ab35d3bd4abf0cd4" data-id="35cb7925fd288015ab35d3bd4abf0cd4"><span><div id="35cb7925fd288015ab35d3bd4abf0cd4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288015ab35d3bd4abf0cd4" title="1.3 同任务三模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.3 同任务三模式</span></span></h4><div class="notion-text notion-block-35cb7925fd288008a76df701ce17696d">同一个任务&quot;帮我实现一个待办应用，包括前端 HTML 和后端 Python + pytest&quot;，三种模式的表现截然不同：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd28805ba94ef44fe04a48b8"><li><b>裸 API</b>：返回三块代码，但永远不会真的创建文件、运行测试、看到测试失败后自己改。它<b>只是在对话框里写字</b>。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880e089a2c0f346ee8269"><li><b>Code Interpreter</b>：真的创建 .py 文件、运行 pytest、看到失败。但没有访问本地项目的能力，没有 git，关闭窗口所有进度清零。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd288059b915c3cfd34f932b"><li><b>Claude Code</b>：在本地创建完整项目结构，写完代码跑 pytest，失败了就改，最后 commit 到 git，下次打开从进度文件接着跑。</li></ul><div class="notion-text notion-block-35cb7925fd2880b8a163dee9f02f33af">三个画面的差距，不是&quot;模型变聪明了&quot;，是&quot;模型外面被加了一层肉眼看不到的工程系统&quot;。</div><hr class="notion-hr notion-block-35cb7925fd288073a730f8d93564cd12"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880178d66cd002595726d" data-id="35cb7925fd2880178d66cd002595726d"><span><div id="35cb7925fd2880178d66cd002595726d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880178d66cd002595726d" title="二、承认抵触——为什么驾驭工程不是新瓶装旧酒"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二、承认抵触——为什么驾驭工程不是新瓶装旧酒</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880679d97d37d2d12400b" data-id="35cb7925fd2880679d97d37d2d12400b"><span><div id="35cb7925fd2880679d97d37d2d12400b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880679d97d37d2d12400b" title="2.1 你的软件工程师直觉没有错"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.1 你的软件工程师直觉没有错</span></span></h4><div class="notion-text notion-block-35cb7925fd2880c29bbcdc3d5f1bf020">听到&quot;Harness Engineering&quot;这个新词，很多工程师的第一反应是抵触：</div><blockquote class="notion-quote notion-block-35cb7925fd288018ba46ee8f0b3a0a12"><div>&quot;这不就是 feedback control 吗？控制系统搞了几十年了。&quot;
&quot;换个名字就能发博客涨粉。&quot;
&quot;LangChain 三年前就在做这件事，只是现在包装成新概念。&quot;</div></blockquote><div class="notion-text notion-block-35cb7925fd2880718f5ec59abe0830e6">这些工程直觉<b>都是对的</b>。对新术语保持怀疑，是一个成熟工程师该有的态度。但怀疑不等于否定——接下来用四条硬数据说话。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880ad943cfa9a7b8b8ffb" data-id="35cb7925fd2880ad943cfa9a7b8b8ffb"><span><div id="35cb7925fd2880ad943cfa9a7b8b8ffb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880ad943cfa9a7b8b8ffb" title="2.2 四条来自一手源的证据"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.2 四条来自一手源的证据</span></span></h4><div class="notion-text notion-block-35cb7925fd2880b59c53f1ed22dbc2f9"><b>表 2-1 硬数据反击表</b></div><table class="notion-simple-table notion-block-35cb7925fd2880589ba2da7229feb1fd"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880b58e22fa47a59d22a7"><td class="" style="width:120px"><div class="notion-simple-table-cell">数据</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">出处</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">含义</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288078ae1bd2df739145c5"><td class="" style="width:120px"><div class="notion-simple-table-cell">同模型仅改 harness，Terminal Bench 2.0 从 52.8% → 66.5%，<b>+13.7pp</b>，排名 Top 30 → Top 5</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">LangChain 博客 2026-02-17，Vivek Trivedy：<a class="notion-link" href="https://www.langchain.com/blog/improving-deep-agents-with-harness-engineering" target="_blank" rel="noopener noreferrer">Improving DeepAgents with Harness Engineering</a></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">harness 是可测量的工程变量</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880058043e0afc24ba764"><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenAI 内测产品：5 个月、<b>约 100 万行代码</b>、<b>约 1500 个 PR</b>、<b>全程零人工编码</b>、开发时间<b>约为传统方式的 1/10</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenAI 工程团队 2026-02-11：<a class="notion-link" href="https://openai.com/index/harness-engineering/" target="_blank" rel="noopener noreferrer">Harness engineering: leveraging Codex in an agent-first world</a></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">harness 可承担生产级工程强度</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880588ecee3da2cfb4404"><td class="" style="width:120px"><div class="notion-simple-table-cell">Manus 团队 6 个月内重构 harness <b>5 次</b>，每次都是删掉过时的复杂逻辑</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Phil Schmid 2026-01-05：<a class="notion-link" href="https://www.philschmid.de/agent-harness-2026" target="_blank" rel="noopener noreferrer">The importance of Agent Harness in 2026</a></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">harness 是活的工程系统</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288032b554c0dee8132ab1"><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-04-02 Birgitta Böckeler 在 <a class="notion-link" href="http://martinfowler.com/" target="_blank" rel="noopener noreferrer">martinfowler.com</a> 发表 &quot;Harness engineering for coding agent users&quot;</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><a class="notion-link" href="https://martinfowler.com/articles/harness-engineering.html" target="_blank" rel="noopener noreferrer">martinfowler.com</a></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">业界权威博客正式纳入</div></td></tr></tbody></table><div class="notion-text notion-block-35cb7925fd28800fa7f2f22352b3fa27">第一条告诉我们——<b>harness 是可以被 benchmark 量化的</b>。第二条告诉我们——<b>harness 可以承担生产级强度</b>。feedback control 没人给它发 +13.7pp 的 benchmark 证明，也没有公司敢说&quot;用它写了约 100 万行零人工代码&quot;。这不是换皮，是<b>一个已经能拉硬数据的新工程学科</b>。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880e7aadafffae9062a0f" data-id="35cb7925fd2880e7aadafffae9062a0f"><span><div id="35cb7925fd2880e7aadafffae9062a0f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880e7aadafffae9062a0f" title="2.3 译名锁定"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.3 译名锁定</span></span></h4><div class="notion-text notion-block-35cb7925fd2880499e71dacec634978c">本文主术语锁定为 <b>&quot;驾驭工程&quot;</b>。&quot;驾驭工程&quot;指代 Harness Engineering，&quot;harness&quot;（小写原词）指代具体的一套机制组合。</div><hr class="notion-hr notion-block-35cb7925fd2880edbcd3fa69f591b7cc"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd28805cbf21f8bfb74b6d79" data-id="35cb7925fd28805cbf21f8bfb74b6d79"><span><div id="35cb7925fd28805cbf21f8bfb74b6d79" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28805cbf21f8bfb74b6d79" title="三、三代工程的包含关系与术语边界"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">三、三代工程的包含关系与术语边界</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28809b8bd7d64e54223939" data-id="35cb7925fd28809b8bd7d64e54223939"><span><div id="35cb7925fd28809b8bd7d64e54223939" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28809b8bd7d64e54223939" title="3.1 三代工程：包含关系而非替代关系"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.1 三代工程：包含关系而非替代关系</span></span></h4><div class="notion-text notion-block-35cb7925fd2880deb862d65477377b58">你可能已经被&quot;上下文工程取代提示词工程&quot;这类标题党文章荼毒过。事实是——<b>没有谁取代谁，只有谁包含谁</b>。</div><div class="notion-text notion-block-35cb7925fd2880e19d90e4b6a83c74a8">三代工程是<b>同心圆式的包含关系</b>：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd28809db6a9e26bd4617c7b"><li><b>提示词工程（2022-2023）</b>：管单轮 LLM 对话里如何把问题问得更好。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd28807eb01fcfa5b0471b29"><li><b>上下文工程（2024-2025）</b>：管多轮对话里喂给 LLM 的信息如何更精准——包括 RAG、tool calling schema、对话历史管理、instruction caching。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880888646e5e961ef242d"><li><b>驾驭工程（2025-2026）</b>：管多轮工具调用 + 长时间运行时，整个系统如何不失败——包括循环刹车、状态持久化、验证闭环、子代理分治。</li></ul><div class="notion-text notion-block-35cb7925fd2880c6a290d5384c5dbfab">以 Claude Code 处理&quot;写登录功能&quot;为例：一次会话同时运行着三代工程的所有机制——Prompt Engineering 层的 system prompt、Context Engineering 层的 <a class="notion-link" href="http://claude.md/" target="_blank" rel="noopener noreferrer">CLAUDE.md</a> 读取和 tool schema 注入、Harness Engineering 层的 max_iterations 硬刹车和 progress 文件持久化。没有哪一层被&quot;替代&quot;，只有层层叠加。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28800b8de5f92093344e42" data-id="35cb7925fd28800b8de5f92093344e42"><span><div id="35cb7925fd28800b8de5f92093344e42" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28800b8de5f92093344e42" title="3.2 术语边界"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.2 术语边界</span></span></h4><div class="notion-text notion-block-35cb7925fd288015a910d6bd50627f72"><b>表 3-1 术语边界对照</b></div><table class="notion-simple-table notion-block-35cb7925fd2880d5b6e4cec8a33846d5"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880c5a564ea1d4316c545"><td class="" style="width:120px"><div class="notion-simple-table-cell">术语</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">是什么</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">与 Harness 的关系</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28805f82b8c444b59ce412"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Agent</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">一个&quot;会用工具完成任务&quot;的软件实体</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 是<b>目标</b>，Harness 是<b>让目标能持续运行的工程系统</b></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28804187a9c6fd498752a2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Scaffolding</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">prompt 到达模型前的组装层</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Scaffolding 是 Harness 的<b>一部分</b>（偏 context 装配层）</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28805386a1f18ec32b6f4e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Framework</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提供类库和抽象的开发工具包（LangChain 等）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Framework 是<b>积木</b>，Harness 是用积木<b>搭出来的整车</b></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28808a898bfdedf63dd2c3"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Runtime</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">负责执行 agent 逻辑的运行时引擎（LangGraph 等）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Runtime 是<b>发动机</b>，Harness 是发动机 + 底盘 + 传动</div></td></tr></tbody></table><blockquote class="notion-quote notion-block-35cb7925fd2880b1ab98ebba9e2bfc28"><div>⚠️ <b>常见误区</b>：把 scaffolding 当 harness 的同义词。很多博客把 &quot;prompt scaffolding&quot; 和 &quot;harness&quot; 混用，让读者低估 harness 的工程复杂度。真正的 harness 必须覆盖：(a) 循环终止刹车、(b) 跨 session 进度持久化、(c) 真机功能验证——三者缺一就不是完整 harness。</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880e1b59ef9195236824e" data-id="35cb7925fd2880e1b59ef9195236824e"><span><div id="35cb7925fd2880e1b59ef9195236824e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880e1b59ef9195236824e" title="3.3 LangChain 三层架构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3.3 LangChain 三层架构</span></span></h4><div class="notion-text notion-block-35cb7925fd28806f93c1d0eb56637dea">LangChain 创始人 Harrison Chase 在 2025-10-25 博文 <a class="notion-link" href="https://blog.langchain.com/agent-frameworks-runtimes-and-harnesses-oh-my/" target="_blank" rel="noopener noreferrer">Agent Frameworks, Runtimes, and Harnesses - oh my!</a> 里把产品线切成了三层：</div><div class="notion-text notion-block-35cb7925fd2880498bb5db6a02434b53"><b>表 3-2 LangChain 三层产品架构</b></div><table class="notion-simple-table notion-block-35cb7925fd28802d8d60d7dafb900ff6"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd28802ca32ffc26313e70a2"><td class="" style="width:120px"><div class="notion-simple-table-cell">层</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">LangChain 对应产品</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">角色</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">类比</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880c79fe2ed2239668d75"><td class="" style="width:120px"><div class="notion-simple-table-cell">Framework</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">langchain-core / integrations</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提供 LLM / tool / retriever 的抽象基类</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">积木</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288077b7c6cd72f3a8257b"><td class="" style="width:120px"><div class="notion-simple-table-cell">Runtime</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">LangGraph</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提供状态机 / checkpoint / interrupt 的执行引擎</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">发动机</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880cfb709cb96a78fbe42"><td class="" style="width:120px"><div class="notion-simple-table-cell">Harness</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">DeepAgents</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">把 LangGraph 组装成&quot;能跑长任务&quot;的完整系统</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">整车</div></td></tr></tbody></table><div class="notion-text notion-block-35cb7925fd28807b8c8ff859c7c12258">2026 年之后 LangChain 的主推产品从 AgentExecutor 转向 DeepAgents——前者是 Runtime 级别的抽象，后者本身就是一个 Harness 成品。大多数工程师需要的不是 runtime，是一个<b>能直接跑的 harness</b>。</div><hr class="notion-hr notion-block-35cb7925fd2880ea9c55fa369b6e6e83"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd28800896fbe3bd1e9f7b64" data-id="35cb7925fd28800896fbe3bd1e9f7b64"><span><div id="35cb7925fd28800896fbe3bd1e9f7b64" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28800896fbe3bd1e9f7b64" title="四、为什么此刻是驾驭工程的拐点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">四、为什么此刻是驾驭工程的拐点</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288072b961ffb5cde4cbf9" data-id="35cb7925fd288072b961ffb5cde4cbf9"><span><div id="35cb7925fd288072b961ffb5cde4cbf9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288072b961ffb5cde4cbf9" title="4.1 Karpathy 的判断：2025 Q3 是分水岭"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4.1 Karpathy 的判断：2025 Q3 是分水岭</span></span></h4><blockquote class="notion-quote notion-block-35cb7925fd28803da603e9a10926050d"><div>&quot;Agents basically didn&#x27;t work before December [2024]. Now they just barely work. And this is the window where harness engineering becomes real engineering.&quot;
—— Andrej Karpathy（YC AI Startup School 2025-06-17 主题演讲）</div></blockquote><div class="notion-text notion-block-35cb7925fd2880c299eefa72f203663d">关键词是&quot;<b>勉强（barely）</b>&quot;——不是说模型变神了，而是模型终于跨过了某个基准线，让&quot;在模型外面围一层系统让它长时间运行&quot;从不可能变成可行。</div><div class="notion-text notion-block-35cb7925fd2880758c23c4efd21d5d0f">那个基准线大致可以用 SWE-bench 60% 通过率来标。当 Claude 3.5 Sonnet 在 2025 Q3 把 SWE-bench Verified 带到 60% 量级，模型已经能&quot;完成多数简单任务&quot;，在外面加 harness 才有边际收益。模型只有 30% 通过率时，harness 设计再好也救不了；模型 90% 通过率时，harness 要做的事反而变少。<b>60-90% 这个区间，是驾驭工程的黄金窗口</b>——恰好从 2025 Q3 开始。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28809da9cccb53b027a53f" data-id="35cb7925fd28809da9cccb53b027a53f"><span><div id="35cb7925fd28809da9cccb53b027a53f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28809da9cccb53b027a53f" title="4.2 8 节点时间轴"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4.2 8 节点时间轴</span></span></h4><div class="notion-text notion-block-35cb7925fd2880c780f7d1e1d6cea0e5"><b>表 4-1 驾驭工程术语演化时间轴</b></div><table class="notion-simple-table notion-block-35cb7925fd288092a826f729d7587a59"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd288022940ec8239400ddea"><td class="" style="width:120px"><div class="notion-simple-table-cell">#</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">日期</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">事件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">作者</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880f3b903e7efb4eef7a6"><td class="" style="width:120px"><div class="notion-simple-table-cell">1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2025-09-23</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">博文首次使用 &quot;Agent Harness&quot; 术语</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Vivek Trivedy</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880a68d6ae36f3efa0d73"><td class="" style="width:120px"><div class="notion-simple-table-cell">2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2025-10-25</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">博文引用并传播该术语</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Harrison Chase (LangChain)</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880df9600dcb2fea6258d"><td class="" style="width:120px"><div class="notion-simple-table-cell">3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2025-11-26</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">官方首篇系统化博文</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Anthropic, Justin Young</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28806eaeb6d647589243a6"><td class="" style="width:120px"><div class="notion-simple-table-cell">4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-01-05</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提出 Bitter Lesson 三原则</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Phil Schmid</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880b5b9abf6618c7eea49"><td class="" style="width:120px"><div class="notion-simple-table-cell">5</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-02-11</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">用生产实证定型术语</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenAI 工程团队</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880258522cf535e5991a0"><td class="" style="width:120px"><div class="notion-simple-table-cell">6</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-02-17</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">+13.7pp 实证证据</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Vivek Trivedy @ LangChain</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880df8ee9c57d7a21eb1f"><td class="" style="width:120px"><div class="notion-simple-table-cell">7</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-02-18</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">三分框架推向大众</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Ethan Mollick</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288023bc8df9a5710b0c94"><td class="" style="width:120px"><div class="notion-simple-table-cell">8</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2026-03-24</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">GAN 启发的三角色架构</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Anthropic, Prithvi Rajasekaran</div></td></tr></tbody></table><div class="notion-text notion-block-35cb7925fd288067bd98c37973a4bfd2">规律很明显：<b>前 4 个节点是社群博客驱动的概念孵化</b>；<b>后 4 个节点是大厂用实证数据 + 官方架构博文把它钉成学科</b>。六个月完成了一门学科从诞生到定型的完整周期。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880998aa9c43b397d6359" data-id="35cb7925fd2880998aa9c43b397d6359"><span><div id="35cb7925fd2880998aa9c43b397d6359" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880998aa9c43b397d6359" title="4.3 两个决定性证据"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4.3 两个决定性证据</span></span></h4><blockquote class="notion-quote notion-block-35cb7925fd288032bae8e479efdac85f"><div><b>证据一（LangChain 2026-02-17）</b>：同模型、同 benchmark、只改 harness，Terminal Bench 2.0 从 52.8% → 66.5%，<b>+13.7 个百分点</b>。</div><div class="notion-text notion-block-35cb7925fd288026bd86cbff0930bfa7"><b>证据二（OpenAI 2026-02-11）</b>：一个内测产品，5 个月、<b>约 100 万行代码</b>、<b>约 1500 个 PR</b>、全程零人工编码、开发时间<b>约为传统方式的 1/10</b>。</div></blockquote><div class="notion-text notion-block-35cb7925fd2880bfa9a1f146597d403f">决定模型能不能上线的是模型本身，决定<b>能不能稳定交付</b>的是 harness。前者是 2023 年之前 AI 工程的核心问题，后者是 2026 年及以后的核心问题。</div><hr class="notion-hr notion-block-35cb7925fd2880439aa0f12685fc8aa2"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880e59696c49ce349c103" data-id="35cb7925fd2880e59696c49ce349c103"><span><div id="35cb7925fd2880e59696c49ce349c103" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880e59696c49ce349c103" title="五、Naive Agent 的八大故障模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">五、Naive Agent 的八大故障模式</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880399c4af8dbbc60885d" data-id="35cb7925fd2880399c4af8dbbc60885d"><span><div id="35cb7925fd2880399c4af8dbbc60885d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880399c4af8dbbc60885d" title="5.1 ~50 行 Naive Agent 完整代码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5.1 ~50 行 Naive Agent 完整代码</span></span></h4><div class="notion-text notion-block-35cb7925fd2880c9920be1ba29f939f6">下面是一段手写的 ~50 行 naive agent——它<b>没有</b>任何 harness 保护，所有 LLM + tool calling 就是教科书式的 <code class="notion-inline-code">while True + JSON schema</code>。代码里用 <code class="notion-inline-code"># 故障 ①～⑧</code> 注释标出了主要失效点。</div><div class="notion-text notion-block-35cb7925fd28804184d4cb6034283b74">这段代码是一个诚实的 &quot;tool-calling 教科书实现&quot;——100 行左右完成了所有&quot;必要的事&quot;。如果你是刚学 Agent 的人，这就是你会从 OpenAI cookbook 里抄来的版本。<b>它的罪不在写得差，在太朴素</b>——朴素到完全没有防御性设计，也就完全没有 harness。</div><blockquote class="notion-quote notion-block-35cb7925fd2880ef98ddfe68bafc515c"><div>⚠️ <b>踩坑预警</b>：<code class="notion-inline-code">subprocess.run</code> 的 <code class="notion-inline-code">returncode</code> 被丢弃。<code class="notion-inline-code">run_pytest</code> 函数只返回 <code class="notion-inline-code">result.stdout</code>，而 <code class="notion-inline-code">result.returncode</code> 被直接丢掉——这意味着即使 pytest 失败，agent 拿到的也只是一段普通字符串，它会<b>以为任务成功</b>。正确做法：显式保留 returncode——<code class="notion-inline-code">return {&quot;passed&quot;: result.returncode == 0, &quot;output&quot;: result.stdout + result.stderr}</code>。</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288034afe8e1618da4b08c" data-id="35cb7925fd288034afe8e1618da4b08c"><span><div id="35cb7925fd288034afe8e1618da4b08c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288034afe8e1618da4b08c" title="5.2 八大故障模式清单"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5.2 八大故障模式清单</span></span></h4><div class="notion-text notion-block-35cb7925fd288039a499f60137ef2834"><b>表 5-1 八大故障模式清单</b></div><table class="notion-simple-table notion-block-35cb7925fd288006ac79ef72f2eb0b73"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd28808d801ff0fc8a374fc0"><td class="" style="width:120px"><div class="notion-simple-table-cell">#</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">故障名</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">症状</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">在 naive agent 中的表现</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880128936dca5ae33415d"><td class="" style="width:120px"><div class="notion-simple-table-cell">①</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>循环失控</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 无限循环，永远不停止</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">while True</code> 无上限</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880ed9a4ef81aea944764"><td class="" style="width:120px"><div class="notion-simple-table-cell">②</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Context 溢出</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">messages 列表无限增长，超出 token 上限</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">messages.append(msg)</code> 无清理</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288065a8aae242e21770c3"><td class="" style="width:120px"><div class="notion-simple-table-cell">③</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Cache Miss</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">system prompt 每轮变化，prompt cache 全部失效</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">[session_iter={i}]</code> 破坏前缀</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28805f8d9ee34dab88db0d"><td class="" style="width:120px"><div class="notion-simple-table-cell">④</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Tool 错误吞</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">工具失败返回空字符串，agent 以为成功</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">except: result = &quot;&quot;</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880468c2ce129aa30bf5b"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑤</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>状态丢失</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">进程挂掉后进度全丢，无法续传</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无任何持久化</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880099a70dbe2f1f102dc"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑥</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>缺权限闸</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 可以执行任何危险操作</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无危险命令拦截</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28807c9d8ccfd5e4ed471d"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑦</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>缺自动化评审</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 自报完成即退出，无独立验证</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">else: break</code></div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880e3a8bde0fc4a4855e1"><td class="" style="width:120px"><div class="notion-simple-table-cell">⑧</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>成本失控</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无 token/cost 预算，跑多少烧多少</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无 budget 控制</div></td></tr></tbody></table><hr class="notion-hr notion-block-35cb7925fd2880ff9932d95315cdc2e9"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880b5b4e2edb3a208ba82" data-id="35cb7925fd2880b5b4e2edb3a208ba82"><span><div id="35cb7925fd2880b5b4e2edb3a208ba82" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880b5b4e2edb3a208ba82" title="六、八大机制——逐一击破故障模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">六、八大机制——逐一击破故障模式</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-35cb7925fd28804e9534eaa2bd46724a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/3ac3651a-fdac-4f11-b0c1-fd1716fe8dd9/image.png?table=block&amp;id=35cb7925-fd28-804e-9534-eaa2bd46724a&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=XHeaKStOj4TIoWcT0Sd5_rvU3tKLU8R6-PJPaga3o-Q&amp;t=35cb7925-fd28-804e-9534-eaa2bd46724a" alt="notion image" loading="lazy" decoding="async"/></div></figure><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880cc94baf85d353e7d97" data-id="35cb7925fd2880cc94baf85d353e7d97"><span><div id="35cb7925fd2880cc94baf85d353e7d97" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880cc94baf85d353e7d97" title="6.1 Agent Loop 四相循环（解 ① 循环失控）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.1 Agent Loop 四相循环（解 ① 循环失控）</span></span></h4><div class="notion-text notion-block-35cb7925fd288058b671d860aa68c15d"><b>一句话定义</b>：把一次 agent 迭代拆成 Gather Context（收集上下文）→ Take Action（执行动作）→ Verify（验证结果）→ Iterate（迭代改进）四个阶段，并硬性加上 max_iterations 和显式终止条件。</div><div class="notion-text notion-block-35cb7925fd28801fabe1fba523f6bc51"><b>类比</b>：驾校教练的四步口诀——&quot;看路况 → 踩油门 → 看前方 → 调整方向&quot;，跑 10 圈就必须停。</div><div class="notion-text notion-block-35cb7925fd2880b3ad2ec1800d268cf5"><b>解哪条故障</b>：故障 ① 循环失控——naive agent 的 <code class="notion-inline-code">while True</code> 在这里被替换成 <code class="notion-inline-code">for i in range(MAX_ITER)</code>，每轮还有显式的 verify 阶段做&quot;能不能停&quot;的判断。</div><div class="notion-text notion-block-35cb7925fd2880d580d4d9dde19772d0">最关键的一行是 <code class="notion-inline-code">for i in range(MAX_ITER)</code> 取代了 <code class="notion-inline-code">while True</code>。这个计数器背后的工程思维是：<b>agent 不该完全信任模型的自我终止判断，系统必须有一个强制出口</b>。</div><blockquote class="notion-quote notion-block-35cb7925fd288096bd46e00e9b7cb5c6"><div>官方出处：<a class="notion-link" href="https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk" target="_blank" rel="noopener noreferrer">Building agents with the Claude Agent SDK</a>（Anthropic，2025-09-29）</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880cf828fc61c68c27788" data-id="35cb7925fd2880cf828fc61c68c27788"><span><div id="35cb7925fd2880cf828fc61c68c27788" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880cf828fc61c68c27788" title="6.2 Tool Use 工具编排（解 ④ tool 错误吞）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.2 Tool Use 工具编排（解 ④ tool 错误吞）</span></span></h4><div class="notion-text notion-block-35cb7925fd288088a50ff3ccdf44b639"><b>一句话定义</b>：所有工具调用包裹在结构化 schema 里，失败时返回 <code class="notion-inline-code">{&quot;status&quot;: &quot;error&quot;, &quot;error&quot;: &quot;...&quot;}</code> 这样的结构化回传，<b>而不是空字符串或异常被吞</b>。</div><div class="notion-text notion-block-35cb7925fd2880eb827ac18573e825e6"><b>类比</b>：USB-C 接口——任何设备插上都能通过标准协议读到身份、能力、故障码。</div><div class="notion-text notion-block-35cb7925fd2880baa906ea2753305cef"><b>解哪条故障</b>：故障 ④ tool 错误吞——naive agent 里 <code class="notion-inline-code">except: result = &quot;&quot;</code> 是典型症状，修复方式是把 error 变成结构化 return，而不是字符串或异常。</div><div class="notion-text notion-block-35cb7925fd2880c4a438c6d89cbfce83">对比 naive agent 的 <code class="notion-inline-code">except: result = &quot;&quot;</code>——前者是&quot;失败了装作没事&quot;，后者是&quot;失败了把失败本身当作第一公民返回&quot;。agent 下一轮看到 <code class="notion-inline-code">status: error</code> 才会触发修复路径。<b>结构化错误是 agent 能跑长任务的第一块基石</b>。</div><blockquote class="notion-quote notion-block-35cb7925fd288022ad69e1b668fb5b05"><div>官方出处：<a class="notion-link" href="https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk" target="_blank" rel="noopener noreferrer">Building agents with the Claude Agent SDK</a>（Anthropic，2025-09-29）；MCP（Model Context Protocol）官方规范进一步标准化了这种 schema 契约。</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880a8a886d6a0688acfbf" data-id="35cb7925fd2880a8a886d6a0688acfbf"><span><div id="35cb7925fd2880a8a886d6a0688acfbf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880a8a886d6a0688acfbf" title="6.3 Progress Tracking 进度追踪（解 ⑤ 状态丢失）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.3 Progress Tracking 进度追踪（解 ⑤ 状态丢失）</span></span></h4><div class="notion-text notion-block-35cb7925fd28805b8a47d2b067d94958"><b>一句话定义</b>：把每一步的进度写到一个持久文件 + 在完成里程碑时打 git commit，这样即使 session 断了，重启时能读取进度文件从断点续传。</div><div class="notion-text notion-block-35cb7925fd288078899efad0f51962f8"><b>类比</b>：游戏存档——开放世界游戏每过一个小任务自动存档，断了能&quot;读档&quot;接着跑。</div><div class="notion-text notion-block-35cb7925fd288065846cc951663074c6"><b>解哪条故障</b>：故障 ⑤ 状态丢失——naive agent 里 session 关掉进度全丢，修复方式是把进度写磁盘 + 用 git 历史作为额外的 checkpoint。</div><div class="notion-text notion-block-35cb7925fd288083b153f6bf164b8516">没有它，agent 跑 30 分钟失败一次就得从零开始。Anthropic 官方的最佳实践更强：progress 文件 + git commit 双重 checkpoint——前者记录 agent 的思考过程，后者记录代码的物理改动。</div><blockquote class="notion-quote notion-block-35cb7925fd2880b7a644c733e7a06f98"><div>官方出处：<a class="notion-link" href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents" target="_blank" rel="noopener noreferrer">Effective Harnesses for Long-Running Agents</a>（Anthropic，2025-11-26，Justin Young）</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288031b15add1550dfe64f" data-id="35cb7925fd288031b15add1550dfe64f"><span><div id="35cb7925fd288031b15add1550dfe64f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288031b15add1550dfe64f" title="6.4 Context Management 上下文管理（解 ② context 溢出 / ③ cache miss）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.4 Context Management 上下文管理（解 ② context 溢出 / ③ cache miss）</span></span></h4><div class="notion-text notion-block-35cb7925fd288040a950cab8498d15d4"><b>一句话定义</b>：持续监控当前 messages 的 token 数，超过阈值时触发压缩（compaction）或重置（reset），同时<b>保持 system prompt 前缀稳定不变</b>以命中 prompt cache。</div><div class="notion-text notion-block-35cb7925fd288019a0d0e02197bbf1c6"><b>类比</b>：工位清理——文件堆到爬不动时，要么压缩（归档成一页摘要），要么重置（从空桌开始）。</div><div class="notion-text notion-block-35cb7925fd2880d5b0bdd573a441086e"><b>解哪条故障</b>：一次救两条——故障 ② context 溢出（压缩能降维度）和故障 ③ cache miss（保持前缀稳定才能命中 cache）。</div><div class="notion-text notion-block-35cb7925fd2880d99796ce7d89d30bf2">最容易被忽略的是 <code class="notion-inline-code">messages[0]</code> 这一行——<b>system prompt 永远不动</b>。prompt cache 是按前缀匹配的，前缀一变整个 cache 作废，延迟翻倍、费用翻倍。</div><blockquote class="notion-quote notion-block-35cb7925fd2880c89e20efc4e1b55369"><div>⚠️ <b>踩坑预警</b>：在 system prompt 里加时间戳、用户名、当前任务。很多开发者把当前任务状态写进 system prompt，以为&quot;让模型知道当前在做什么&quot;更好——实际上这会让每轮的 system prompt 前缀都不同，prompt cache 全部失效。正确做法：system prompt 只放固定的&quot;角色定义&quot;，当前任务全部放进 user 消息。</div></blockquote><blockquote class="notion-quote notion-block-35cb7925fd28803ab352ec603e4f3bf2"><div>官方出处：<a class="notion-link" href="https://platform.claude.com/cookbook/tool-use-automatic-context-compaction" target="_blank" rel="noopener noreferrer">Automatic Context Compaction Cookbook</a>（Claude Agent SDK 官方）</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288084b2f3f5673dee0ccc" data-id="35cb7925fd288084b2f3f5673dee0ccc"><span><div id="35cb7925fd288084b2f3f5673dee0ccc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288084b2f3f5673dee0ccc" title="6.5 Feature List 任务拆解（解 ② context 溢出的源头）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.5 Feature List 任务拆解（解 ② context 溢出的源头）</span></span></h4><div class="notion-text notion-block-35cb7925fd2880a6b77bcf7738ebbe42"><b>一句话定义</b>：把大任务拆成独立的子任务清单（JSON 文件存在磁盘上），强制 agent 单次只做一件事，从源头控制 context 膨胀。</div><div class="notion-text notion-block-35cb7925fd2880d5b59cdfe7c1b7e1f8"><b>类比</b>：待办清单——早上不会一口气处理 10 件事，而是列清单、做完一件划掉一件。</div><div class="notion-text notion-block-35cb7925fd288001b49fd0de6001bbc5"><b>解哪条故障</b>：故障 ② context 溢出的源头——naive agent 一次把 &quot;读文件 + 修 bug + 跑 pytest&quot; 全塞进去，context 自然爆。Feature List 把它切成 3 个独立子任务，每个子任务 context 小得多。</div><div class="notion-text notion-block-35cb7925fd28807f95e6f987b2b526b0">这张清单以 JSON 文件形式存在磁盘上，而不是放在 context 里——这样它不会随 messages 一起被压缩掉。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28804e8611e16efb89202a" data-id="35cb7925fd28804e8611e16efb89202a"><span><div id="35cb7925fd28804e8611e16efb89202a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28804e8611e16efb89202a" title="6.6 Verification Loop 验证闭环（解 ④ tool 错误的下游）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.6 Verification Loop 验证闭环（解 ④ tool 错误的下游）</span></span></h4><div class="notion-text notion-block-35cb7925fd2880bc86c3fbe0e92bd604"><b>一句话定义</b>：每个 feature 完成后，用 pytest / Playwright 等真机工具去<b>实际验证功能</b>，而不是只看 LLM 自己说&quot;我觉得做好了&quot;。验证失败就回退重做。</div><div class="notion-text notion-block-35cb7925fd2880e2b37ac4e1e0931aac"><b>类比</b>：QA 验收测试——开发说&quot;我修好了&quot;不算数，得 QA 真的点按钮、真的跑场景才算数。</div><div class="notion-text notion-block-35cb7925fd2880d38885ed7e7b2f3bec"><b>解哪条故障</b>：故障 ④ tool 错误吞的下游——光在工具调用层面返回 <code class="notion-inline-code">error</code> 不够，任务层面必须有&quot;真机验证&quot;才能确认功能真的跑通。</div><div class="notion-text notion-block-35cb7925fd28809397f0c194583b46ce">对比 naive agent 的 <code class="notion-inline-code">run_pytest</code>（丢掉了 returncode），这里显式保留 <code class="notion-inline-code">result.returncode == 0</code> 作为 passed 判定——<b>&quot;通过&quot;必须来自外部真实反馈，而不是 agent 自己说通过了</b>。</div><div class="notion-text notion-block-35cb7925fd2880c9b870c36d6d87d673">Anthropic 官方还额外约束：<b>&quot;不可接受删掉或修改测试，因为这会导致功能缺失或带 bug&quot;</b>——如果 agent 发现测试在报错，正确路径是&quot;去修实现&quot;，错误路径是&quot;把测试改成能过&quot;。</div><blockquote class="notion-quote notion-block-35cb7925fd2880519e41d245fa0b2db6"><div>官方出处：<a class="notion-link" href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents" target="_blank" rel="noopener noreferrer">Effective Harnesses for Long-Running Agents</a>（Anthropic，2025-11-26）</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd288013b177c434de132bd2" data-id="35cb7925fd288013b177c434de132bd2"><span><div id="35cb7925fd288013b177c434de132bd2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288013b177c434de132bd2" title="6.7 Subagents 子代理分治（解 ② context 溢出的另一种解法）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.7 Subagents 子代理分治（解 ② context 溢出的另一种解法）</span></span></h4><div class="notion-text notion-block-35cb7925fd28801abe2fc8fd0347367a"><b>一句话定义</b>：把特定子任务派发给一个<b>独立 context 的子 agent</b>，子 agent 在自己的 messages 列表里工作、完成后只把结果返回主 agent，主 agent 的 context 完全不受子任务中间过程污染。</div><div class="notion-text notion-block-35cb7925fd288045a792e4f2e9c95c55"><b>类比</b>：外包给顾问——CEO 把专业问题外包给咨询顾问，顾问自己开独立项目，几周后只交一份结论。CEO 的主 context 没有被中间文档污染。</div><div class="notion-text notion-block-35cb7925fd28807c8fa6e0497e944ad7"><b>解哪条故障</b>：故障 ② context 溢出的另一解法——主 agent context 保持干净，所有&quot;脏活&quot;（多轮试错、大量工具调用）都在子 agent 的独立 context 里消化。</div><div class="notion-text notion-block-35cb7925fd288096a0d0d1075e62c617"><code class="notion-inline-code">sub_messages = [...]</code> 不是从主 agent 的 messages 复制过来的，而是<b>全新的独立列表</b>。主 agent 拿到的只有子 agent 的最终 return 值，中间子 agent 跑了 20 轮工具调用主 agent 一无所知——正因为&quot;一无所知&quot;，主 context 才能保持干净。</div><blockquote class="notion-quote notion-block-35cb7925fd28806d9caccff919bea5df"><div>官方出处：<a class="notion-link" href="https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk" target="_blank" rel="noopener noreferrer">Building agents with the Claude Agent SDK</a>（Anthropic，2025-09-29）</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28807e961aee78e3363909" data-id="35cb7925fd28807e961aee78e3363909"><span><div id="35cb7925fd28807e961aee78e3363909" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28807e961aee78e3363909" title="6.8 Generator-Evaluator（GAN 启发的三角色架构，解 ⑦ 缺自动化评审）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.8 Generator-Evaluator（GAN 启发的三角色架构，解 ⑦ 缺自动化评审）</span></span></h4><div class="notion-text notion-block-35cb7925fd28809c8e4cfbc952a5aeaf"><b>一句话定义</b>：借鉴 GAN 的思路，把一个任务的处理流拆成<b>三个独立角色的 agent</b>——<b>Planner（规划者）拆任务</b>、<b>Generator（生成者）写代码</b>、<b>Evaluator（评价者）独立评审</b>。Evaluator 不看 Generator 的中间过程，只看最终产出，以&quot;怀疑者&quot;视角打分，不通过就打回。</div><div class="notion-text notion-block-35cb7925fd28808eb2a2eded8cab9991"><b>类比</b>：论文评审制度——作者写论文，审稿人不看写作过程只看论文本身，按评分标准打分；编辑在作者和审稿人之间做协调。三个角色分离才能保证质量。</div><div class="notion-text notion-block-35cb7925fd2880bdadc4f4ce06783141"><b>解哪条故障</b>：故障 ⑦ 缺自动化评审——naive agent 里没有任何独立评审角色，agent 自己说做完就做完；Generator-Evaluator 架构把&quot;评审&quot;作为一个独立 agent 机械执行的步骤，打破&quot;生成者自评偏见&quot;。</div><div class="notion-text notion-block-35cb7925fd288050a950c16e9467f6a2">Evaluator 的 docstring 强调——&quot;<b>不看生成过程</b>&quot;。这是整个机制的精髓：如果让同一个 LLM 既做生成又做评审，它会倾向于<b>为自己辩护</b>；但如果把评审单独抽成一个 agent，给它一个&quot;怀疑者&quot;角色的 prompt，它就会认真挑刺。<b>这就是 GAN 的核心——通过架构性约束制造对抗，而不是靠单 agent 的自我反思</b>。</div><blockquote class="notion-quote notion-block-35cb7925fd2880ce9162e4872242a7a9"><div>官方出处：<a class="notion-link" href="https://www.anthropic.com/engineering/harness-design-long-running-apps" target="_blank" rel="noopener noreferrer">Harness Design for Long-Running Application Development</a>（Anthropic，2026-03-24，Prithvi Rajasekaran）</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28801d90c7d3267b338750" data-id="35cb7925fd28801d90c7d3267b338750"><span><div id="35cb7925fd28801d90c7d3267b338750" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28801d90c7d3267b338750" title="6.9 机制 × 故障模式对照表"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6.9 机制 × 故障模式对照表</span></span></h4><div class="notion-text notion-block-35cb7925fd2880418386e36137cf900e"><b>表 6-1 八大机制 × 八大故障模式对照</b></div><table class="notion-simple-table notion-block-35cb7925fd28809fa48deedda7a8d582"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880328eaeeb48353c8372"><td class="" style="width:120px"><div class="notion-simple-table-cell">机制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">主解故障</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">辅解故障</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880eb877ed0b7b06e0fe1"><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent Loop 四相循环</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">① 循环失控</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑥ 缺权限限闸
⑧ 成本失控</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28804d9261d7aac64cf122"><td class="" style="width:120px"><div class="notion-simple-table-cell">Tool Use 工具编排</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">④ tool 错误吞</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880bd8467c08033c749a7"><td class="" style="width:120px"><div class="notion-simple-table-cell">Progress Tracking 进度追踪</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑤ 状态丢失</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288087b40ce049ab2a4b8e"><td class="" style="width:120px"><div class="notion-simple-table-cell">Context Management 上下文管理</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">② context 溢出 
③ cache miss</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑧ 成本失控</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880e3a774df3197325e47"><td class="" style="width:120px"><div class="notion-simple-table-cell">Feature List 任务拆解</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">② context 溢出（源头）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑧ 成本失控</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288082852ac35dfb7fe3bd"><td class="" style="width:120px"><div class="notion-simple-table-cell">Verification Loop 验证闭环</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">④ tool 错误吞（下游）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880c586f9c23c8fa10781"><td class="" style="width:120px"><div class="notion-simple-table-cell">Subagents 子代理分治</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">② context 溢出（另一解法）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑧ 成本失控</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880bdb477cbaf06ad5bf4"><td class="" style="width:120px"><div class="notion-simple-table-cell">Generator-Evaluator生成 - 评估对抗</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">⑦ 缺自动化评审</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">—</div></td></tr></tbody></table><blockquote class="notion-quote notion-block-35cb7925fd2880309848cbe8e431a766"><div>注：⑥ 缺权限闸和 ⑧ 成本失控的完整解决方案（Permission Gate 权限闸 / Token Budget 成本预算）后面讲解。</div></blockquote><hr class="notion-hr notion-block-35cb7925fd28809eb6f0d295bd1ae610"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd288077a78bd1226fc8ecb6" data-id="35cb7925fd288077a78bd1226fc8ecb6"><span><div id="35cb7925fd288077a78bd1226fc8ecb6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd288077a78bd1226fc8ecb6" title="七、三支柱正交视角"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">七、三支柱正交视角</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-35cb7925fd2880c7bda2f375f97cdd2c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/09dd2f8b-c6c2-4ca1-939a-c82dec27a3cf/image.png?table=block&amp;id=35cb7925-fd28-80c7-bda2-f375f97cdd2c&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=RBBtpLkS8WcaUKXhvKWdKjjEbfW59tTsoWfYrwZvWSY&amp;t=35cb7925-fd28-80c7-bda2-f375f97cdd2c" alt="notion image" loading="lazy" decoding="async"/></div></figure><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28807a965dc131f3182759" data-id="35cb7925fd28807a965dc131f3182759"><span><div id="35cb7925fd28807a965dc131f3182759" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28807a965dc131f3182759" title="7.1 三支柱定义"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.1 三支柱定义</span></span></h4><div class="notion-text notion-block-35cb7925fd2880f5a586d2dffe8f4569">除了按&quot;故障→机制&quot;的视角看 harness，还可以从三个工程维度——<b>三支柱</b>——来正交切分：</div><div class="notion-text notion-block-35cb7925fd2880548ae1fcd6f86a6e5a"><b>表 7-1 三支柱核心问题与判断规则</b></div><table class="notion-simple-table notion-block-35cb7925fd2880f18b54d6011ff5acf0"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880f5ab6ece194e8b8f4b"><td class="" style="width:120px"><div class="notion-simple-table-cell">支柱</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心问题</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">判断规则</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288038ad27fb4b08f6376a"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Context Engineering</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 能<b>看见</b>什么信息？看见的信息是否准确精简？</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">如果一个机制在&quot;整理 agent 接下来输入的信息&quot;，它属于这一柱</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28805481f3fe579f033167"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Architectural Constraints</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 能<b>做</b>什么、不能做什么？动作空间在哪里有边界？</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">如果一个机制在&quot;约束 agent 的能力或交互边界&quot;，它属于这一柱</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880e297ddda3ef94daf04"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Garbage Collection</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Agent 能<b>跑多久</b>？成本和资源怎么回收？</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">如果一个机制在&quot;清理过期状态 / 限制成本 / 回收资源&quot;，它属于这一柱</div></td></tr></tbody></table><blockquote class="notion-quote notion-block-35cb7925fd2880b2a00bcfd4f83d195c"><div>来源说明：三支柱是本课程综合 Martin Fowler 系博客（Böckeler 2026-04-02）、Anthropic Rajasekaran（2026-03-24）、Phil Schmid（2026-01-05）多来源抽象的工程维度框架。</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28805f9a0ef3e13a2ba653" data-id="35cb7925fd28805f9a0ef3e13a2ba653"><span><div id="35cb7925fd28805f9a0ef3e13a2ba653" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28805f9a0ef3e13a2ba653" title="7.2 三支柱视角的价值"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.2 三支柱视角的价值</span></span></h4><div class="notion-text notion-block-35cb7925fd2880c1bb47da1c0291d92a">以 Claude Code 为例走一次三支柱归类：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd28807b952eefb3c0ea379f"><li><b>Context Engineering (输入端：怎么在第一时间把对的资料喂给它)</b>：Claude Code 读取你项目目录里的 <a class="notion-link" href="http://claude.md/" target="_blank" rel="noopener noreferrer">CLAUDE.md</a>（相当于 RAG 系统 prompt）、在长会话时触发 session 压缩（compaction）、把进度写进 progress 文件——这三项都在&quot;整理 agent 看见的信息&quot;。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880388f07cb4151f70a05"><li><b>Architectural Constraints (控制流：它发疯的时候，你怎么硬生生把它按住)</b>：Claude Code 提供 27 种 hook 让你约束工具行为、内置 Permission Gate 控制危险操作、通过 Task tool（subagent 机制）做分治隔离——这三项都在&quot;约束 agent 能做什么&quot;（设红线、拉电闸）。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd28803687efcc660dcb533b"><li><b>Garbage Collection (状态流：内存快被撑爆时，怎么有策略地遗忘)</b>：Claude Code 有 token budget 防爆预算、做 session compaction 回收过期上下文；Anthropic 2025→2026 的工程路线注释也在从 compaction 逐步转向 reset——这条支柱核心是容错与动态收敛。</li></ul><div class="notion-text notion-block-35cb7925fd2880939f91f6f6ab823f41">看到一个新的 Agent 产品，可以立刻问两个问题：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880a08783c2dffcad0fd3"><li><b>按机制视角</b>：它解了八大故障模式里的哪几条？</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd28804babbae737e362441b"><li><b>按支柱视角</b>：它主要投资在哪一柱？</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880da9395caa7b9241f7d" data-id="35cb7925fd2880da9395caa7b9241f7d"><span><div id="35cb7925fd2880da9395caa7b9241f7d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880da9395caa7b9241f7d" title="7.3 八大机制 × 三支柱对照表"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7.3 八大机制 × 三支柱对照表</span></span></h4><div class="notion-text notion-block-35cb7925fd2880579244fe92646f38f0"><b>表 7-2 八大机制 × 三支柱归属</b></div><table class="notion-simple-table notion-block-35cb7925fd2880ec8c3dc230630bf1e2"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880c8a5e1ea25fd48cad3"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">机制</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell">Context Engineering</div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell">Architectural Constraints</div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">Garbage Collection</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">归属判断说明</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880ff8735da6e02c5e26e"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">1 Agent Loop 四相循环</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell">辅</div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">循环每轮都要整理 context；四相结构本身是架构约束</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880e6ba42c95cabef3586"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">2 Tool Use 工具编排</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">工具 schema 本身就是一个动作空间的约束</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28804fa79ddaec8af63a65"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">3 Progress Tracking</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell">辅</div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">跨 session 的状态持久化属于 context 延展</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28800dbf20dbbbdede0b96"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">4 Context Management</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">辅</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">本柱的核心；compaction 也有 GC 属性</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880f7941cfa45adaec62f"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">5 Feature List</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell">辅</div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">辅</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">JSON 清单是 context 的规划层</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880a7a23cce10f731a3d2"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">6 Verification Loop</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">事件驱动的错误显性化属于架构约束</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28801a8a07d7e3c6cbdc63"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">7 Subagents</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell">辅</div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">辅</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">分治隔离是架构性的边界划分</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880c994aaeefc33557b06"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">8 Generator-Evaluator</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">三角色分离是架构约束的典型实现</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28805185efe762a09e2dd3"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">9 Permission Gate（待补）</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">危险操作拦截属架构约束；第二节课补</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880688632faf9d4071c28"><td class="" style="width:152.8181915283203px"><div class="notion-simple-table-cell">11 Token Budget（待补）</div></td><td class="" style="width:115.17045593261719px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:130.9431915283203px"><div class="notion-simple-table-cell">-</div></td><td class="" style="width:107.19319152832031px"><div class="notion-simple-table-cell"><b>主</b></div></td><td class="" style="width:162.1591033935547px"><div class="notion-simple-table-cell">成本控制属 GC；第二节课补</div></td></tr></tbody></table><hr class="notion-hr notion-block-35cb7925fd2880199a1af9890743ad06"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880f4a4eeec9ae0c0d481" data-id="35cb7925fd2880f4a4eeec9ae0c0d481"><span><div id="35cb7925fd2880f4a4eeec9ae0c0d481" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880f4a4eeec9ae0c0d481" title="八、生态地图——坐标系的实战运用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">八、生态地图——坐标系的实战运用</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880bb9adac4bae581316d" data-id="35cb7925fd2880bb9adac4bae581316d"><span><div id="35cb7925fd2880bb9adac4bae581316d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880bb9adac4bae581316d" title="8.1 10+ 主流 Harness 产品全景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.1 10+ 主流 Harness 产品全景</span></span></h4><div class="notion-text notion-block-35cb7925fd28805db2aed081dcc17ab4"><b>表 8-1 主流 Harness 产品清单</b></div><table class="notion-simple-table notion-block-35cb7925fd2880b8853dfb814076e4f6"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880028b97cf04da31012e"><td class="" style="width:120px"><div class="notion-simple-table-cell">#</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">产品</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">开发方</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">一句定位</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28802b82e8d219944f3fe4"><td class="" style="width:120px"><div class="notion-simple-table-cell">1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Claude Code</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Anthropic</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">CLI-first 驾驭工程参考实现</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880acbd63f32e200546e7"><td class="" style="width:120px"><div class="notion-simple-table-cell">2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Codex CLI</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenAI</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">CLI-first，OpenAI 官方 harness 参考</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880f4bca5fdb7e2cdac4d"><td class="" style="width:120px"><div class="notion-simple-table-cell">3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Cursor</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Anysphere</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">IDE-native harness，VS Code 深度集成</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28806bad8cc50e930ee37b"><td class="" style="width:120px"><div class="notion-simple-table-cell">4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Windsurf</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Codeium</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">IDE-native，体验对标 Cursor</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880038a85f6184d4318a2"><td class="" style="width:120px"><div class="notion-simple-table-cell">5</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Cline</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">VS Code 社区</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">IDE-native 开源插件，autonomous agent</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28808b8d24e72561cacb94"><td class="" style="width:120px"><div class="notion-simple-table-cell">6</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Aider</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">开源社区</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">CLI-first 开源，git commit 深度集成</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288005bea4c29bfe194349"><td class="" style="width:120px"><div class="notion-simple-table-cell">7</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Amp</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Sourcegraph</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">CLI-first，代码搜索 + agent 结合</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288024811ad519c8be8306"><td class="" style="width:120px"><div class="notion-simple-table-cell">8</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Roo Code</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">开源社区</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">IDE-native VS Code 扩展</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28800abf6af955e6bf976a"><td class="" style="width:120px"><div class="notion-simple-table-cell">9</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">DeepAgents</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">LangChain</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">SDK-harness，基于 LangGraph 的 harness 组件库</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880b28920e5afa8e6f382"><td class="" style="width:120px"><div class="notion-simple-table-cell">10</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Devin</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Cognition</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Cloud-sandbox，完全托管的 autonomous agent</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880048835d22382b691d5"><td class="" style="width:120px"><div class="notion-simple-table-cell">11</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">JetBrains Junie</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">JetBrains</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">IDE-native，JetBrains 系 IDE 集成</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28809aabc1e4c9b06b8e79" data-id="35cb7925fd28809aabc1e4c9b06b8e79"><span><div id="35cb7925fd28809aabc1e4c9b06b8e79" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28809aabc1e4c9b06b8e79" title="8.2 四系家族树"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.2 四系家族树</span></span></h4><div class="notion-text notion-block-35cb7925fd2880f4b7efc436ee78aa84">11 个产品可以归成四个&quot;家族&quot;：</div><div class="notion-text notion-block-35cb7925fd28804bb5aef4edf90574e0"><b>表 8-2 四系家族特征对比</b></div><table class="notion-simple-table notion-block-35cb7925fd2880cdb591d048a54bd778"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd2880c38f2dee9c0980af23"><td class="" style="width:120px"><div class="notion-simple-table-cell">家族</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">主要特征</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">典型代表</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">适用场景</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">局限性</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288087a53bddfe7fb9e2b5"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>CLI-first</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">命令行为主入口，跑在本地 terminal</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Claude Code / Codex CLI / Aider</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">后端开发、系统工程</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">需要命令行习惯，无 GUI</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880be9061c7bbc8bf2878"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>IDE-native</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">IDE 内置集成，UI 优先</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Cursor / Windsurf / Cline / Junie</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">前端开发、IDE 生态依赖者</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">重依赖特定 IDE 生态</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288047958df0631213265c"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Cloud-sandbox</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">云端完全托管，无需本地环境</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Devin</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">团队协作、远程长任务托管</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">成本较高、数据隐私顾虑</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd288089a1fad9e2ca792ff1"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>SDK-harness</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">提供 SDK 自建 harness</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">DeepAgents (LangChain)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定制化场景、嵌入自家产品</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">集成复杂度高</div></td></tr></tbody></table><hr class="notion-hr notion-block-35cb7925fd288030aa03c4181ae74ecd"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880fb88f5c6b3839d0eb2" data-id="35cb7925fd2880fb88f5c6b3839d0eb2"><span><div id="35cb7925fd2880fb88f5c6b3839d0eb2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880fb88f5c6b3839d0eb2" title="九、三句官方警示——harness 不是银弹"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">九、三句官方警示——harness 不是银弹</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880e5b057e11b14bf08f0" data-id="35cb7925fd2880e5b057e11b14bf08f0"><span><div id="35cb7925fd2880e5b057e11b14bf08f0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880e5b057e11b14bf08f0" title="9.1 警示一：harness 会过时"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.1 警示一：harness 会过时</span></span></h4><blockquote class="notion-quote notion-block-35cb7925fd28808496fef5d6bc9c2ce1"><div>&quot;A harness encodes assumptions that go stale. What works for Claude 3.5 may not work for Claude 4.5.&quot;
——Anthropic 官方博文（2025-11-26，Justin Young）</div></blockquote><div class="notion-text notion-block-35cb7925fd288077b304c1f8d3585a5d">harness 固化了一组关于模型的假设，这些假设会过期。不要把 harness 当成一次性架构写死，要像管理软件一样持续迭代。</div><div class="notion-text notion-block-35cb7925fd2880f5b182faaddfce6529"><b>判断 harness 是否过时的信号</b>：同样任务的成功率下降 5pp 以上、需要频繁手动干预、新模型版本上线后 benchmark 反而退步。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd28802da92ae1308c72d547" data-id="35cb7925fd28802da92ae1308c72d547"><span><div id="35cb7925fd28802da92ae1308c72d547" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd28802da92ae1308c72d547" title="9.2 警示二：Build to Delete（建造以便删除）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.2 警示二：Build to Delete（建造以便删除）</span></span></h4><blockquote class="notion-quote notion-block-35cb7925fd2880bf8c77c24e908eb196"><div>&quot;The best harness is the one you&#x27;re most willing to throw away and rewrite. The dataset of failures from your current harness is more valuable than the harness itself.&quot;
——Phil Schmid（2026-01-05，Bitter Lesson 三原则之一）</div></blockquote><div class="notion-text notion-block-35cb7925fd288086bf32e54d436bf902">最好的 harness 是<b>最愿意扔掉重写的那个</b>。当前 harness 的失败样本比 harness 本身更有价值。不要给 harness 加舍不得删的复杂度。Manus 团队 6 个月重构 5 次的故事，本质就是这句话的实战演绎——每一次重构，都是因为上一版&quot;舍不得删的设计&quot;成了下一版的瓶颈。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-35cb7925fd2880809d51ca1438510d4b" data-id="35cb7925fd2880809d51ca1438510d4b"><span><div id="35cb7925fd2880809d51ca1438510d4b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880809d51ca1438510d4b" title="9.3 警示三：三大开放争议还没定论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9.3 警示三：三大开放争议还没定论</span></span></h4><div class="notion-text notion-block-35cb7925fd288052a7e1fcd8a733e219">驾驭工程作为新学科，有三个核心设计选择社群仍在争论：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd28807dbde5f87a995d8d2f"><li><b>多 Agent（Subagents 分治）vs 单 Loop（Feature List 拆分）</b>：多 Agent 隔离性更好但协调开销更大；单 Loop 简单可控但 context 膨胀压力全在一个 loop 里。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd288058bbcccec9e84cfbc7"><li><b>Compaction（压缩旧 context）vs Reset（重置 context 重来）</b>：compaction 保留历史但引入摘要噪声；reset 干净但丢失跨 session 推理链，强依赖 Progress Tracking 做外置记忆补救。</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd288066b671fec49ff37a17"><li><b>CLI-first vs IDE-native</b>：CLI-first 擅长长任务自主运行 + 脚本化编排；IDE-native 擅长行内交互式修改 + 视觉反馈。两种哲学尚未分出胜负。</li></ul><div class="notion-text notion-block-35cb7925fd28807aa69dc9b9a590a14b">如果有人告诉你&quot;正确答案就是 X&quot;，保持警惕——这门学科还在演化中。</div><hr class="notion-hr notion-block-35cb7925fd2880889358ce5347c54f3b"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35cb7925fd2880d2a7eccf032535bd01" data-id="35cb7925fd2880d2a7eccf032535bd01"><span><div id="35cb7925fd2880d2a7eccf032535bd01" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880d2a7eccf032535bd01" title="十、总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">十、总结</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-35cb7925fd2880899963e58e4d4ebdf2" style="list-style-type:decimal"><li><b>Agent = Model + Harness</b>（Vivek Trivedy 原创；Böckeler @ <a class="notion-link" href="http://martinfowler.com/" target="_blank" rel="noopener noreferrer">martinfowler.com</a> 传播）</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-35cb7925fd2880799b22c46b4f6f77ef" style="list-style-type:decimal"><li>八大故障模式——①循环失控 ②context 溢出 ③cache miss ④tool 错误吞 ⑤状态丢失 ⑥缺权限闸 ⑦缺自动化评审 ⑧成本失控</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-35cb7925fd28805b9d72cfe3c6db50b8" style="list-style-type:decimal"><li>八大机制——Agent Loop / Tool Use / Progress Tracking / Context Management / Feature List / Verification Loop / Subagents / Generator-Evaluator</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-35cb7925fd28800cb824e6db8e9b6778" style="list-style-type:decimal"><li>三支柱正交视角——Context Engineering / Architectural Constraints / Garbage Collection</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-35cb7925fd2880ae9551c33d02a5803c" style="list-style-type:decimal"><li>四系家族树——CLI-first / IDE-native / Cloud-sandbox / SDK-harness</li></ol><div class="notion-text notion-block-35cb7925fd288029ba5cec55ec03e267">驾驭工程不是&quot;feedback control 换皮&quot;，它是一套被八大故障模式逼出来、由八大机制实现、在三支柱坐标系下工作、在 10+ 个真实产品上落地、但<b>注定会过时所以必须准备随时删除</b>的工程学科。</div><hr class="notion-hr notion-block-35cb7925fd2880cda6fec7b77f294ec9"/><blockquote class="notion-quote notion-block-35cb7925fd28803580a0df009ee8d233"><div>📌 <b>信息源归属</b>：</div><ul class="notion-list notion-list-disc notion-block-35cb7925fd28800e9446fba531d8600b"><li>Agent = Model + Harness 公式：Vivek Trivedy（<a class="notion-link" href="https://vtrivedy.com/posts/claude-code-sdk-haas-harness-as-a-service" target="_blank" rel="noopener noreferrer">2025-09-23 首篇 HaaS 博文</a>）/ Birgitta Böckeler @ <a class="notion-link" href="https://martinfowler.com/articles/harness-engineering.html" target="_blank" rel="noopener noreferrer">martinfowler.com</a>（2026-04-02）</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd288066972dff984fd9f194"><li>Terminal Bench +13.7pp 实证数据：LangChain 博客 2026-02-17，Vivek Trivedy（<a class="notion-link" href="https://www.langchain.com/blog/improving-deep-agents-with-harness-engineering" target="_blank" rel="noopener noreferrer">原文链接</a>）</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd288004a5bcf96523545ff2"><li>OpenAI 约 100 万行 / 零人工编码 / 1/10 时间：<a class="notion-link" href="https://openai.com/index/harness-engineering/" target="_blank" rel="noopener noreferrer">OpenAI 工程团队博文 2026-02-11</a></li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880469b68ed7e1fd9a801"><li>八大机制主要出处：<a class="notion-link" href="https://www.anthropic.com/engineering/building-agents-with-the-claude-agent-sdk" target="_blank" rel="noopener noreferrer">Claude Agent SDK 博文</a>（2025-09-29）+ <a class="notion-link" href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents" target="_blank" rel="noopener noreferrer">Anthropic Effective Harnesses</a>（2025-11-26）+ <a class="notion-link" href="https://www.anthropic.com/engineering/harness-design-long-running-apps" target="_blank" rel="noopener noreferrer">Anthropic Harness Design</a>（2026-03-24）</li></ul><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880678eabd7d562331295"><li>术语首用节点：Vivek Trivedy（2025-09-23）</li></ul></blockquote><hr class="notion-hr notion-block-35cb7925fd2880dd83abccdb3797d551"/><blockquote class="notion-quote notion-block-35cb7925fd288014b12ade22310c3f8d"><div>📌 <b>术语</b>：</div><table class="notion-simple-table notion-block-35cb7925fd2880d6896ff052002795d5"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-35cb7925fd28807b8666ce72c82e6b20"><td class="" style="width:120px"><div class="notion-simple-table-cell">术语</div></td><td class="" style="width:431.99998474121094px"><div class="notion-simple-table-cell">含义</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28802d8fdcd47b3f1e574b"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>pp</b></div></td><td class="" style="width:431.99998474121094px"><div class="notion-simple-table-cell">percentage point，百分点。例 &quot;+13.7pp&quot; 即&quot;提升 13.7 个百分点&quot;</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28808a9fbcef5683c7f83f"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Terminal Bench 2.0</b></div></td><td class="" style="width:431.99998474121094px"><div class="notion-simple-table-cell">Stanford 推出的终端任务基准，考核 Agent 在真实 shell 环境完成复杂任务的通过率</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880eab86ac94473bc39c4"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>SWE-bench / SWE-bench Verified</b></div></td><td class="" style="width:431.99998474121094px"><div class="notion-simple-table-cell">Princeton 提出的 GitHub issue 修复基准；Verified 是经人工复核的高质量子集</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880989ebeeba8486eed44"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>prompt cache</b></div></td><td class="" style="width:431.99998474121094px"><div class="notion-simple-table-cell">LLM 按输入前缀命中的缓存机制，前缀不变可复用，前缀被改写则缓存全部作废</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd28806ba81ffe3d5f1e3b1b"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>HaaS</b></div></td><td class="" style="width:431.99998474121094px"><div class="notion-simple-table-cell">Harness-as-a-Service，由 Vivek Trivedy 在 2025-09-23 首篇博文中创造</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880d88900d65b61376eaf"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>GAN</b></div></td><td class="" style="width:431.99998474121094px"><div class="notion-simple-table-cell">Generative Adversarial Network，生成对抗网络，核心思路是&quot;生成者 vs 鉴别者&quot;对抗提升质量</div></td></tr><tr class="notion-simple-table-row notion-block-35cb7925fd2880dda011f2234e169a3e"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Bitter Lesson</b></div></td><td class="" style="width:431.99998474121094px"><div class="notion-simple-table-cell">Rich Sutton 2019 年 AI 经典论文——简单通用方法最终胜过复杂领域知识</div></td></tr></tbody></table></blockquote><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-35cb7925fd2880c98b23ddad3c6a75ff" data-id="35cb7925fd2880c98b23ddad3c6a75ff"><span><div id="35cb7925fd2880c98b23ddad3c6a75ff" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35cb7925fd2880c98b23ddad3c6a75ff" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-35cb7925fd2880feb70cf3f116c0e976"><li><a class="notion-link" href="https://appze9inzwc2314.pc.xiaoe-tech.com/p/t_pc/goods_pc_detail/goods_detail/p_69defc29e4b0694c5baf93fd?product_id=p_69defc29e4b0694c5baf93fd" target="_blank" rel="noopener noreferrer">大模型Agent智能体开发实战</a></li></ul><div class="notion-blank notion-block-35cb7925fd2880dfaabce6cecffb2e2f"> </div><div class="notion-callout notion-gray_background_co notion-block-35cb7925fd288069bf6cd9c8568c5f22"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">欢迎您在底部评论区留言，一起交流~</div></div><div class="notion-blank notion-block-35cb7925fd2880d29501f4681b62e720"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[07 Vibe Coding ]]></title>
            <link>https://tangly1024.com/article/VibeCoding-007</link>
            <guid>https://tangly1024.com/article/VibeCoding-007</guid>
            <pubDate>Fri, 10 Apr 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[OpenSpec]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-348b7925fd2880f2a4c0e45e551fd234"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-348b7925fd2880f2b242f32ad13050e7"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text"></div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-348b7925fd2880f6860ff5f9826b1adc" data-id="348b7925fd2880f6860ff5f9826b1adc"><span><div id="348b7925fd2880f6860ff5f9826b1adc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880f6860ff5f9826b1adc" title="SDD 三大框架对比"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">SDD 三大框架对比</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd28801e87b7e37fc3dda6e6" data-id="348b7925fd28801e87b7e37fc3dda6e6"><span><div id="348b7925fd28801e87b7e37fc3dda6e6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28801e87b7e37fc3dda6e6" title="1 三大框架核心信息"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 三大框架核心信息</span></span></h3><table class="notion-simple-table notion-block-348b7925fd288065b10ad32be8a23dfe"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880f5adccd9d9ab0bc8bf"><td class="" style="width:120px"><div class="notion-simple-table-cell">框架名称</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定位标签</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">背景与适用场景</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心流程/特点</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">特性</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880feb223f9bb326adc8c"><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenSpec</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">最轻量</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Fission-AI (YC) 出品
三步工作流
适合 Brownfield（遗留项目）+ 轻量变更</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">聚焦「为什么做这个变更」（变更上下文）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ <code class="notion-inline-code">/verify</code> 三维验证
✅ Delta Spec 增量更新
✅ 24+ AI 工具 零锁定</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880b2b224e17225136a4c"><td class="" style="width:120px"><div class="notion-simple-table-cell">spec-kit</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">最完整</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">GitHub 官方出品
四步流程
适合 Greenfield（全新项目）大型项目</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">聚焦「该构建什么」（规格说明）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ Constitution 深度约束
✅ 项目级规则强制执行
✅ 完整需求→代码全流程</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880b98b7fe329ee788aaf"><td class="" style="width:120px"><div class="notion-simple-table-cell">Superpowers</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">最自动</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">obra·Skills 框架
适合高质量交付场景</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">聚焦「代码写对了吗」（质量保证）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 自动 TDD 纪律性执行
✅ 行为驱动开发内置
✅ Skills 自动化流程</div></td></tr></tbody></table><hr class="notion-hr notion-block-348b7925fd2880608885d81514497bbb"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880d1b1a7ee2895dcf87e" data-id="348b7925fd2880d1b1a7ee2895dcf87e"><span><div id="348b7925fd2880d1b1a7ee2895dcf87e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880d1b1a7ee2895dcf87e" title="2 三框架核心差异（互补不互斥）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 三框架核心差异（互补不互斥）</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-348b7925fd28805f8b05f02b8e61562d" style="list-style-type:decimal"><li><b>OpenSpec</b>：负责「为什么做这个变更」——管理变更上下文，适配遗留项目与轻量迭代</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-348b7925fd2880848250cb2034a19c81" style="list-style-type:decimal"><li><b>spec-kit</b>：负责「该构建什么」——管理规格说明，为大型新项目提供完整流程与约束</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-348b7925fd288053b287d81edce2eba8" style="list-style-type:decimal"><li><b>Superpowers</b>：负责「代码写对了吗」——管理质量保证，通过自动化流程保障交付质量</li></ol><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-348b7925fd288000a144e6c5c0e74658"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/8e05347c-6958-4e12-b134-e1a643c762a2/image.png?table=block&amp;id=348b7925-fd28-8000-a144-e6c5c0e74658&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=qIX5SEHKX6EmCXsDRoolDx4uCpiYgOGTknR6xiFFoZs&amp;t=348b7925-fd28-8000-a144-e6c5c0e74658" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-348b7925fd2880e69615fc8de9ff3d34"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/9e2677f3-b061-445a-b6bd-10a3478b1782/image.png?table=block&amp;id=348b7925-fd28-80e6-9615-fc8de9ff3d34&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=agUDO-4Z3rI9L--FAEHXZY5CxANyt_hJDUApIGdjO3Y&amp;t=348b7925-fd28-80e6-9615-fc8de9ff3d34" alt="notion image" loading="lazy" decoding="async"/></div></figure><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-348b7925fd28805eaa73d4ef884c570f" data-id="348b7925fd28805eaa73d4ef884c570f"><span><div id="348b7925fd28805eaa73d4ef884c570f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28805eaa73d4ef884c570f" title="OpenSpec"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">OpenSpec</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880b6853af301e88c817c" data-id="348b7925fd2880b6853af301e88c817c"><span><div id="348b7925fd2880b6853af301e88c817c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880b6853af301e88c817c" title="OpenSpec 项目架构 &amp; 工作流"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">OpenSpec 项目架构 &amp; 工作流</span></span></h3><blockquote class="notion-quote notion-block-348b7925fd288056986dfedc579fc0d5"><div>核心定位：类 Git 逻辑，管理需求规格变更</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28808495d5e11036616f10" data-id="348b7925fd28808495d5e11036616f10"><span><div id="348b7925fd28808495d5e11036616f10" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28808495d5e11036616f10" title="1 项目架构（src/ 目录）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 项目架构（src/ 目录）</span></span></h4><table class="notion-simple-table notion-block-348b7925fd288011929aefd7cf55f2e9"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880ab8249e33056bc5980"><td class="" style="width:120px"><div class="notion-simple-table-cell">模块</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心内容</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28802797a0d49c2e1ec495"><td class="" style="width:120px"><div class="notion-simple-table-cell">cli/</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Commander.js 命令行入口</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28801d8244d39af79a23cd"><td class="" style="width:120px"><div class="notion-simple-table-cell">commands/</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">命令实现层，封装子命令逻辑</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288040bdfdf1a3991feb1b"><td class="" style="width:120px"><div class="notion-simple-table-cell">core/（重点）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">init.ts（29KB 核心文件）、archive.ts（归档+Delta 合并）、specs-apply.ts（Delta 合并算法）、Zod 验证、24 个 AI 工具适配器</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880e79b70d4ae24746ba4"><td class="" style="width:120px"><div class="notion-simple-table-cell">prompts/</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AI 交互 Prompt 模板</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880f8970fef8b98a33fa4"><td class="" style="width:120px"><div class="notion-simple-table-cell">schemas/</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">内置工作流 Schema 定义</div></td></tr></tbody></table><blockquote class="notion-quote notion-block-348b7925fd28809899a9cc2bf85e660f"><div>核心文件速记：init 控核心流程、archive 管归档、specs-apply 是 Delta 算法核心</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880d1ab25ed9d4877a43a" data-id="348b7925fd2880d1ab25ed9d4877a43a"><span><div id="348b7925fd2880d1ab25ed9d4877a43a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880d1ab25ed9d4877a43a" title="2 核心工作流（标准四步）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 核心工作流（标准四步）</span></span></h4><table class="notion-simple-table notion-block-348b7925fd28809397e9c3a0a91ace47"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd288026810ef95851ad073b"><td class="" style="width:120px"><div class="notion-simple-table-cell">步骤</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">操作</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心作用</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880898133c697f01f802f"><td class="" style="width:120px"><div class="notion-simple-table-cell">1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">openspec init</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">初始化项目，检测并配置 AI 工具</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28805bbe28d1a98a5c6973"><td class="" style="width:120px"><div class="notion-simple-table-cell">2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">/opsx:propose</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AI 生成提案（Why 变更原因+规格变更+任务清单）</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28808b8c70d7bb600ccb88"><td class="" style="width:120px"><div class="notion-simple-table-cell">3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">/opsx:apply</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">按任务清单，落地规格变更至代码</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288072aa59eb81268dd21e"><td class="" style="width:120px"><div class="notion-simple-table-cell">4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">openspec archive</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Delta 合并入主规格，归档 Why/What/How 变更记录</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28807b9c81fa3af50fb959" data-id="348b7925fd28807b9c81fa3af50fb959"><span><div id="348b7925fd28807b9c81fa3af50fb959" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28807b9c81fa3af50fb959" title="3 两种工作流模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3 两种工作流模式</span></span></h4><table class="notion-simple-table notion-block-348b7925fd288018b4c4ec3ac7d427a2"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28809a90e2dc653c726933"><td class="" style="width:120px"><div class="notion-simple-table-cell">模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">流程</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">特点</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28805b8733c1e875cb26a7"><td class="" style="width:120px"><div class="notion-simple-table-cell">Core（默认）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">propose → apply → archive</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">3 步完成，简洁高效，适配常规迭代</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880fe8c8effeb26d07ae3"><td class="" style="width:120px"><div class="notion-simple-table-cell">Expanded</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">new → continue → apply → verify → archive</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">5 步流程，支持精细控制，适配复杂变更</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880db9940d372934c1dbe" data-id="348b7925fd2880db9940d372934c1dbe"><span><div id="348b7925fd2880db9940d372934c1dbe" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880db9940d372934c1dbe" title="4 Delta 规格系统（类 Git diff）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4 Delta 规格系统（类 Git diff）</span></span></h4><table class="notion-simple-table notion-block-348b7925fd2880b1bce8d468b556a96c"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28804b81afc8b9aff9f492"><td class="" style="width:120px"><div class="notion-simple-table-cell">变更类型</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">标识</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心说明</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">示例</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880f1a309fd085349b842"><td class="" style="width:120px"><div class="notion-simple-table-cell">新增</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">ADDED</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">新增需求条目（含 Given/When/Then 场景）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">导出 PDF 功能</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288012a8f6eb65665b69b5"><td class="" style="width:120px"><div class="notion-simple-table-cell">修改</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">MODIFIED</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">调整已有需求</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">登录超时 30min→15min</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28809fbb55eaa0ad46bfd8"><td class="" style="width:120px"><div class="notion-simple-table-cell">删除</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">REMOVED</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">废弃需求（历史完整归档）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">旧版 API 过渡至 v2 后不再维护</div></td></tr></tbody></table><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880118affd0c23848448f" data-id="348b7925fd2880118affd0c23848448f"><span><div id="348b7925fd2880118affd0c23848448f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880118affd0c23848448f" title="OpenSpec 安装 &amp; 目录拆解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">OpenSpec 安装 &amp; 目录拆解</span></span></h3><blockquote class="notion-quote notion-block-348b7925fd2880019737d771765b7724"><div>核心定位：三步安装，快速搭建 AI 协作基础设施</div></blockquote><hr class="notion-hr notion-block-348b7925fd288065bcc8f1ff95a1de80"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28805ea301c0d47520b1e6" data-id="348b7925fd28805ea301c0d47520b1e6"><span><div id="348b7925fd28805ea301c0d47520b1e6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28805ea301c0d47520b1e6" title="1 安装三步流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 安装三步流程</span></span></h4><table class="notion-simple-table notion-block-348b7925fd288086812bf861aedca8a6"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28802cb26decd97497a9f4"><td class="" style="width:120px"><div class="notion-simple-table-cell">步骤</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">操作</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心说明</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880b8a6ffd9be1c82a6f1"><td class="" style="width:120px"><div class="notion-simple-table-cell">1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">npm install -g openspec</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">全局安装，要求 Node.js ≥ 20.19</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28801d91fec0b4cec2d356"><td class="" style="width:120px"><div class="notion-simple-table-cell">2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">openspec init</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">交互式生成项目目录结构</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28807193f0e98613fafd04"><td class="" style="width:120px"><div class="notion-simple-table-cell">3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">config profile</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">配置单/多命令，适配不同工作流</div></td></tr></tbody></table><hr class="notion-hr notion-block-348b7925fd28800c910dfcbf26cfb486"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288026b668cfcddf5cd596" data-id="348b7925fd288026b668cfcddf5cd596"><span><div id="348b7925fd288026b668cfcddf5cd596" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288026b668cfcddf5cd596" title="2 目录结构拆解（openspec/）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 目录结构拆解（<code class="notion-inline-code">openspec/</code>）</span></span></h4><table class="notion-simple-table notion-block-348b7925fd28806bb8f2cd662f6fe12e"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880b699f4ce3576f5e789"><td class="" style="width:120px"><div class="notion-simple-table-cell">目录/文件</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心作用</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288026917fe84699d9da51"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">config.yaml</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">项目配置，主动注入每次请求</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880cea2abf1d2bc6a8979"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">specs/</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">系统当前行为的完整描述（源真相）</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28800fa5bfc4061b39f09d"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">changes/</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">变更提案区，每个功能一个独立文件夹</div></td></tr></tbody></table><div class="notion-text notion-block-348b7925fd2880859650c94108b7ece1">🔗  Git 类比<div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-348b7925fd2880548800ea6c5ef96b33"><li>specs/   ≈ main 分支 — 「当前系统长什么样」</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd28801694bbd14422a080cf"><li>changes/ ≈ feature 分支 — 每个功能独立开发</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd28804b90f4d47892ce41c1"><li>archive  ≈ merge — 归档时合并变更到主 Spec</li></ul></div></div><hr class="notion-hr notion-block-348b7925fd288045a070e8c6f36bfbc5"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28806f898af2e307ed02b3" data-id="348b7925fd28806f898af2e307ed02b3"><span><div id="348b7925fd28806f898af2e307ed02b3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28806f898af2e307ed02b3" title="3 命令 Profile 类型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3 命令 Profile 类型</span></span></h4><table class="notion-simple-table notion-block-348b7925fd2880b2b662c3e430987bb2"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28808eb1eff59c6085e6d2"><td class="" style="width:120px"><div class="notion-simple-table-cell">类型</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">包含命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">特点</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288061b943ed720a50a56c"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">core profile</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">propose</code> / <code class="notion-inline-code">apply</code> / <code class="notion-inline-code">archive</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">仅 3 个核心命令，简洁高效</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880d19977f60808468ed1"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">custom profile</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">propose/apply</code> / <code class="notion-inline-code">archive/verify</code> / <code class="notion-inline-code">onboard/sync</code> 等</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">共 11 个命令，支持更精细的流程控制</div></td></tr></tbody></table><div class="notion-text notion-block-348b7925fd28809687f1cbd0fca2866e">切换命令示例：</div><hr class="notion-hr notion-block-348b7925fd288047af3dc0a84aaffc20"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880b69a98dd53e5fe5a0c" data-id="348b7925fd2880b69a98dd53e5fe5a0c"><span><div id="348b7925fd2880b69a98dd53e5fe5a0c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880b69a98dd53e5fe5a0c" title="4 跨工具语法差异"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4 跨工具语法差异</span></span></h4><table class="notion-simple-table notion-block-348b7925fd2880eab3e6dc293d4daf83"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880ea81e0d90f23013c79"><td class="" style="width:120px"><div class="notion-simple-table-cell">工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">命令语法</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">说明</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288006af29eafce5917ef7"><td class="" style="width:120px"><div class="notion-simple-table-cell">Claude Code</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/opsx:propose</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">冒号分隔</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288066a51fd741aff15986"><td class="" style="width:120px"><div class="notion-simple-table-cell">Cursor / Windsurf</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/opsx-propose</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">连字符分隔</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880a59bd3d58ac62f7e2b"><td class="" style="width:120px"><div class="notion-simple-table-cell">所有工具</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能完全相同</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">仅语法形式不同，逻辑一致</div></td></tr></tbody></table><hr class="notion-hr notion-block-348b7925fd288047942bf5b7b5011214"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd28800f9855ddc8d72f5451" data-id="348b7925fd28800f9855ddc8d72f5451"><span><div id="348b7925fd28800f9855ddc8d72f5451" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28800f9855ddc8d72f5451" title="config.yaml · 项目的「AI 宪法」"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">config.yaml · 项目的「AI 宪法」</span></span></h3><blockquote class="notion-quote notion-block-348b7925fd288007954dd8b5c6d33273"><div>核心定位：替代传统 <code class="notion-inline-code">project.md</code>，以 <b>主动注入</b> 替代 <b>被动读取</b>，保障 AI 协作确定性</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28803bbeb5ca2d7c559cda" data-id="348b7925fd28803bbeb5ca2d7c559cda"><span><div id="348b7925fd28803bbeb5ca2d7c559cda" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28803bbeb5ca2d7c559cda" title="1 为什么用 config.yaml？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 为什么用 config.yaml？</span></span></h4><table class="notion-simple-table notion-block-348b7925fd28807d98c0fb9968977ad5"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd288056a5bdf6f9f9c2adf5"><td class="" style="width:120px"><div class="notion-simple-table-cell">对比项</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">旧方案（<a class="notion-link" href="http://project.md/" target="_blank" rel="noopener noreferrer">project.md</a>）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">新方案（config.yaml）</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288089a9dff3e25daf8fc4"><td class="" style="width:120px"><div class="notion-simple-table-cell">读取机制</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">被动读取，AI 可能读不到</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>主动注入</b>，100% 生效，无遗漏</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28806d8d7fce13ad1906c6"><td class="" style="width:120px"><div class="notion-simple-table-cell">稳定性</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不确定（读/不读全看 AI）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">100% 稳定，强制注入每个请求</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880a69b74f356c5d39c89"><td class="" style="width:120px"><div class="notion-simple-table-cell">定位</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">文档参考</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>AI 协作核心配置</b>（项目的“宪法”）</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28808a9f0bd91b95103717" data-id="348b7925fd28808a9f0bd91b95103717"><span><div id="348b7925fd28808a9f0bd91b95103717" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28808a9f0bd91b95103717" title="2 三层结构（从基础到核心）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 三层结构（从基础到核心）</span></span></h4><table class="notion-simple-table notion-block-348b7925fd2880e7ae9fcee07b9faaca"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd288075b6aef1232332701c"><td class="" style="width:120px"><div class="notion-simple-table-cell">层级</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">作用</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">特点</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288057ac1bd21fbf47a354"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>schema</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定义工作流类型</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">基础配置，<b>一般不改</b></div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28801fa8d9e50fb46fff8b"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>context</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">全局上下文，核心层</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">极度精炼，<b>主动注入每个请求</b></div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880ff9566ecdf6a222f18"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>rules</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">格式规则约束</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">按 artifact 类型分层（proposal/specs/design/tasks 各有标准）</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288030b50ccc654fac3d61" data-id="348b7925fd288030b50ccc654fac3d61"><span><div id="348b7925fd288030b50ccc654fac3d61" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288030b50ccc654fac3d61" title="3 context 三铁律（核心准则）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3 context 三铁律（核心准则）</span></span></h4><table class="notion-simple-table notion-block-348b7925fd28805c9782d3679cf436bd"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd288071881bff1859e4765f"><td class="" style="width:120px"><div class="notion-simple-table-cell">原则</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心要求</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">目的</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288079bb47e4dca9ef118c"><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 极度精炼</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">只写 AI 不知道的项目特殊约定；通用最佳实践不用写</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">减少 token 消耗，避免冗余</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28800a8a3fd2431f5ed844"><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 活文档</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AI 忽略了就加，膨胀了就剪</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">始终保持精炼、有效</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880b2a4c0e8681bd47468"><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 超 10 行审视</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">context 每字都是 token 成本</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">控制长度，优化性能</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880ab9831d7435b066275" data-id="348b7925fd2880ab9831d7435b066275"><span><div id="348b7925fd2880ab9831d7435b066275" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880ab9831d7435b066275" title="4 核心结论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4 核心结论</span></span></h4><blockquote class="notion-quote notion-block-348b7925fd2880b291bccc2dcd5670ea"><div><b>主动注入 &gt; 被动读取</b>
context 每一字节都是 token 成本 → <b>精炼是优化性能的第一步</b></div></blockquote><hr class="notion-hr notion-block-348b7925fd2880398b71c7a8c16fee99"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880e6b5cac1bee80d103e" data-id="348b7925fd2880e6b5cac1bee80d103e"><span><div id="348b7925fd2880e6b5cac1bee80d103e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880e6b5cac1bee80d103e" title="CLAUDE.md 分阶段交互"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a class="notion-link" href="http://claude.md/" target="_blank" rel="noopener noreferrer">CLAUDE.md</a> 分阶段交互</span></span></h3><blockquote class="notion-quote notion-block-348b7925fd2880e9a790c89088e2a06a"><div>核心目标：通过分阶段控制，防止 AI 「错上加错」，大幅降低修复成本</div></blockquote><hr class="notion-hr notion-block-348b7925fd2880fab9daede0900da93c"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288040bd00ef4a8fa56f6b" data-id="348b7925fd288040bd00ef4a8fa56f6b"><span><div id="348b7925fd288040bd00ef4a8fa56f6b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288040bd00ef4a8fa56f6b" title="1 核心规则"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 核心规则</span></span></h4><div class="notion-text notion-block-348b7925fd28801fb54deab055f14e06">在 <code class="notion-inline-code">CLAUDE.md</code> 中写明交互规则：</div><blockquote class="notion-quote notion-block-348b7925fd28805e8678c9b504dd5be4"><div>每完成一个 Phase → 暂停总结 → 等待用户确认 → 再继续下一个阶段</div></blockquote><hr class="notion-hr notion-block-348b7925fd28805ab70dc43c85f3c157"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288099bfe1e46e1e2561ac" data-id="348b7925fd288099bfe1e46e1e2561ac"><span><div id="348b7925fd288099bfe1e46e1e2561ac" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288099bfe1e46e1e2561ac" title="2 两种交互模式对比"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 两种交互模式对比</span></span></h4><table class="notion-simple-table notion-block-348b7925fd2880a7a859c79c5f56a626"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28806ba0f8d6e2d431a5b3"><td class="" style="width:120px"><div class="notion-simple-table-cell">对比项</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">无分阶段规则（AI 默认行为）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">有分阶段规则（<a class="notion-link" href="http://claude.md/" target="_blank" rel="noopener noreferrer">CLAUDE.md</a> 控制）</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28806cbd1ee88a30386514"><td class="" style="width:120px"><div class="notion-simple-table-cell">执行逻辑</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AI 一口气写完所有 Phase，追求快速交付</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每完成一个 Phase 必须暂停，先总结变更，等待确认再继续</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28809f90f4e997b8a84913"><td class="" style="width:120px"><div class="notion-simple-table-cell">偏差处理</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Phase 1 出现理解偏差后，后续阶段在错误上继续堆叠</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Phase 1 完成即可发现偏差，仅需修正约 50 行代码，损失最小</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880c8b857cd454ba83286"><td class="" style="width:120px"><div class="notion-simple-table-cell">问题暴露时机</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">写 500-1000 行代码后，才发现方向根本错误</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">偏差早期暴露，可立即调整方向，后续阶段在正确基础上推进</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28802cbd74f18b1ae07da8"><td class="" style="width:120px"><div class="notion-simple-table-cell">修复成本</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">极高，几乎等于全部重写</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">极低，仅需修正少量代码，避免大规模返工</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880d18be3fb26a7d44225"><td class="" style="width:120px"><div class="notion-simple-table-cell">核心效果</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">错上加错，越走越偏</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">小步快跑，精准迭代，全程可控</div></td></tr></tbody></table><hr class="notion-hr notion-block-348b7925fd28808e8948d83c19fd34d7"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880ccbf86d3bc48a4af4d" data-id="348b7925fd2880ccbf86d3bc48a4af4d"><span><div id="348b7925fd2880ccbf86d3bc48a4af4d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880ccbf86d3bc48a4af4d" title="3 关键结论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3 关键结论</span></span></h4><ul class="notion-list notion-list-disc notion-block-348b7925fd2880c9aa5ef08f8a861866"><li><b>分阶段控制是 AI 协作的“刹车”</b>，能把错误扼杀在早期阶段</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd28801c8f67cdd8d13916c1"><li>修复成本差异巨大：50 行 vs 1000 行，本质是「小修小改」和「推倒重来」的区别</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd2880b08994d03685028cc2"><li><code class="notion-inline-code">CLAUDE.md</code> 规则的核心，就是强制 AI 进入「暂停-确认-继续」的循环，避免一次性写死</li></ul><hr class="notion-hr notion-block-348b7925fd28808d81a0e02748776855"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd28807384d5d2d6b793e531" data-id="348b7925fd28807384d5d2d6b793e531"><span><div id="348b7925fd28807384d5d2d6b793e531" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28807384d5d2d6b793e531" title="OpenSpec 三步核心工作流 + 四件制品"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">OpenSpec 三步核心工作流 + 四件制品</span></span></h3><blockquote class="notion-quote notion-block-348b7925fd2880c89da5e8babea9b22e"><div>核心目标：用「先设计、后编码」的方式，把返工时间压到最低</div></blockquote><hr class="notion-hr notion-block-348b7925fd28803a9b07f39b39e000d3"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288077a20dc62f5540bfed" data-id="348b7925fd288077a20dc62f5540bfed"><span><div id="348b7925fd288077a20dc62f5540bfed" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288077a20dc62f5540bfed" title="1 完整工作流（含可选步骤）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 完整工作流（含可选步骤）</span></span></h4><ul class="notion-list notion-list-disc notion-block-348b7925fd2880088014c7efb2587f9a"><li>关键节点：<code class="notion-inline-code">propose</code> 阶段生成全部四件制品，是整个流程的核心输入</li></ul><hr class="notion-hr notion-block-348b7925fd2880f0b730c622ecf2139b"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288017b7c4c3ca2be60a09" data-id="348b7925fd288017b7c4c3ca2be60a09"><span><div id="348b7925fd288017b7c4c3ca2be60a09" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288017b7c4c3ca2be60a09" title="2 四件制品详解（核心交付物）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 四件制品详解（核心交付物）</span></span></h4><table class="notion-simple-table notion-block-348b7925fd288098a0dedb69ada53976"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880e4a73bda59038816a4"><td class="" style="width:120px"><div class="notion-simple-table-cell">制品</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定位</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心内容</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28803d8bc2e86e667eb948"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">proposal.md</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">为什么做</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">意图：变更要解决的问题&lt;br&gt;范围：影响的模块&lt;br&gt;方法：大致实现思路&lt;br&gt;out-of-scope：明确不做什么，防止 AI 越界</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28805eb189cf01c0d4e5a6"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">specs/</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">做什么</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Delta Spec 格式（只写变化部分）：&lt;br&gt;• ADDED 新增需求&lt;br&gt;• MODIFIED 修改已有需求&lt;br&gt;• REMOVED 删除需求&lt;br&gt;（不重写整个文件，是 OpenSpec 高效的关键）</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288079a1d3c1becd0a09c2"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">design.md</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">怎么做</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">技术方案选型&lt;br&gt;架构决策及理由&lt;br&gt;数据流描述&lt;br&gt;涉及的文件清单</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880b28288f95d577920aa"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">tasks.md</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">执行清单</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">带 checkbox 的分阶段任务&lt;br&gt;按 Phase 分组，每个 Phase 有验证步骤&lt;br&gt;AI apply 时逐个标记 [x]&lt;br&gt;checkpoint 防止 AI 跑偏</div></td></tr></tbody></table><hr class="notion-hr notion-block-348b7925fd28808f9d65fa4be181511c"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28808e8698c31067c5ac9e" data-id="348b7925fd28808e8698c31067c5ac9e"><span><div id="348b7925fd28808e8698c31067c5ac9e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28808e8698c31067c5ac9e" title="3 效率对比：直接写代码 vs OpenSpec 流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3 效率对比：直接写代码 vs OpenSpec 流程</span></span></h4><table class="notion-simple-table notion-block-348b7925fd288070ba23cfe25b51c20b"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880749064fb28d9daccee"><td class="" style="width:120px"><div class="notion-simple-table-cell">方式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">时间投入</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">结果</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880f1a591ce32d2d49dbc"><td class="" style="width:120px"><div class="notion-simple-table-cell">直接写代码</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2h 编码 + 1h 返工 = 3h ❌</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">返工成本高，方向错误代价极大</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880d68604e70743966608"><td class="" style="width:120px"><div class="notion-simple-table-cell">OpenSpec 流程</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">propose 5min + review 10min + apply 1.5h + verify 5min ≈ 2h ✅</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">省的不是编码时间，是返工时间</div></td></tr></tbody></table><hr class="notion-hr notion-block-348b7925fd2880bb9aacc58906e933b9"/><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288051a92fe1c981f39912" data-id="348b7925fd288051a92fe1c981f39912"><span><div id="348b7925fd288051a92fe1c981f39912" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288051a92fe1c981f39912" title="4 核心认知"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4 核心认知</span></span></h4><ul class="notion-list notion-list-disc notion-block-348b7925fd2880089c93c314d5c5c052"><li><code class="notion-inline-code">propose</code> 不是写代码，而是<b>交出设计方案给你审查</b></li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd28803bba1edf43e5599254"><li>审查几十行的设计，比审查几百行的代码容易 10 倍</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd288037888bd1beeb7c4bad"><li>上游花 10 分钟打磨 proposal，能省下下游 2 小时返工</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd288042927ac0f9c0f5f1a6"><li>工程实践：先结构化需求 + 总结架构，再进行 propose</li></ul><hr class="notion-hr notion-block-348b7925fd2880428dd2fb6bd9f059ba"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880e5b9cfdf9c4a32835a" data-id="348b7925fd2880e5b9cfdf9c4a32835a"><span><div id="348b7925fd2880e5b9cfdf9c4a32835a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880e5b9cfdf9c4a32835a" title="out-of-scope 关键点 &amp; Review 不可跳过 "><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">out-of-scope 关键点 &amp; Review 不可跳过 </span></span></h3><blockquote class="notion-quote notion-block-348b7925fd288011937eea0c18f940cf"><div>核心原则：明确“不做什么” + 严格执行评审，杜绝 AI 越界与返工</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880aebde4c4c5d67dfb8d" data-id="348b7925fd2880aebde4c4c5d67dfb8d"><span><div id="348b7925fd2880aebde4c4c5d67dfb8d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880aebde4c4c5d67dfb8d" title="1 AI 的「善意」陷阱"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 AI 的「善意」陷阱</span></span></h4><table class="notion-simple-table notion-block-348b7925fd288049be00d05547288681"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880cab7eed9fd3dc43dc9"><td class="" style="width:120px"><div class="notion-simple-table-cell">场景</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">风险表现</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心逻辑</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28808497d9d348d46acc9f"><td class="" style="width:120px"><div class="notion-simple-table-cell">需求不完整</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">只要求导航栏，AI 顺带引入动画库、搜索功能</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AI 会基于“善意”补充未明确需求</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880e2ba2ce47e09713f8f"><td class="" style="width:120px"><div class="notion-simple-table-cell">后果</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">功能溢出，偏离预期</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">未声明“不做什么”，AI 无法判断边界</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28805d929bdeef07db1e4a"><td class="" style="width:120px"><div class="notion-simple-table-cell">关键认知</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">告诉 AI「不做什么」，和告诉它「做什么」<b>同等重要</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">双向定义才能精准控制范围</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28804aaac9f228187aeb19" data-id="348b7925fd28804aaac9f228187aeb19"><span><div id="348b7925fd28804aaac9f228187aeb19" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28804aaac9f228187aeb19" title="2 out-of-scope 实操"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 out-of-scope 实操</span></span></h4><table class="notion-simple-table notion-block-348b7925fd2880c1b791ca61040477d2"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28801b97e0fda8aced382f"><td class="" style="width:120px"><div class="notion-simple-table-cell">操作</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">具体示例</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">效果</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28808f9d57fa9958000801"><td class="" style="width:120px"><div class="notion-simple-table-cell">在 <code class="notion-inline-code">proposal.md</code> 中明确写出「不做」清单</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 不做动画效果&lt;br&gt;✅ 不做搜索功能&lt;br&gt;✅ 不接入后端 API</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AI 严格遵守，绝不越界，100% 可控</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288014a925c786838b4172" data-id="348b7925fd288014a925c786838b4172"><span><div id="348b7925fd288014a925c786838b4172" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288014a925c786838b4172" title="3 Review 不可跳过"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3 Review 不可跳过</span></span></h4><table class="notion-simple-table notion-block-348b7925fd2880fca34ceb42fc690367"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28804ba232d80b738caa35"><td class="" style="width:120px"><div class="notion-simple-table-cell">环节</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">内容</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">成本对比</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288077a5ebf346bda24671"><td class="" style="width:120px"><div class="notion-simple-table-cell">时机</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">propose</code> 阶段之后</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288059af4bfc84fbab742a"><td class="" style="width:120px"><div class="notion-simple-table-cell">审查对象</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">「设计方案」（几十行），而非直接看代码（几百行）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">设计评审成本远低于代码返工</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd288028a6bfc0e5cf376780"><td class="" style="width:120px"><div class="notion-simple-table-cell">耗时</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">仅需 5-10 分钟</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">-</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28802c9162eea37a34b49d"><td class="" style="width:120px"><div class="notion-simple-table-cell">价值</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">发现问题 → 改设计方案，<b>成本极低</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">避免后续生成 1000 行错误代码的大规模返工</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28800fb836d5d7503dd8ec"><td class="" style="width:120px"><div class="notion-simple-table-cell">核心结论</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>越早发现问题，修改代价越小</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">本质是“止损”，而非节省时间</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28802ca742f537fcf6baf8" data-id="348b7925fd28802ca742f537fcf6baf8"><span><div id="348b7925fd28802ca742f537fcf6baf8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28802ca742f537fcf6baf8" title="4 反模式 #2：跳过提案打磨，直接 apply"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4 反模式 #2：跳过提案打磨，直接 apply</span></span></h4><table class="notion-simple-table notion-block-348b7925fd288081bbb6e698f70ce303"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28802c905ad20f07061f88"><td class="" style="width:120px"><div class="notion-simple-table-cell">反模式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">形象类比</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">后果</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28803f9835d30374d399f2"><td class="" style="width:120px"><div class="notion-simple-table-cell">不做 <code class="notion-inline-code">propose</code> 和 <code class="notion-inline-code">review</code>，直接执行代码生成</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不看建筑图纸直接开工</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">最常见的反模式，<b>代价最高</b>，必然返工</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28801992e9e76136d003ca" data-id="348b7925fd28801992e9e76136d003ca"><span><div id="348b7925fd28801992e9e76136d003ca" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28801992e9e76136d003ca" title="5 完整 OpenSpec 闭环"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5 完整 OpenSpec 闭环</span></span></h4><blockquote class="notion-quote notion-block-348b7925fd28806a83bfd9047dcc8846"><div><b>完整 OpenSpec = in-scope 清单 + out-of-scope 清单 + review 通过 → AI 精准执行，绝不越界</b></div></blockquote><hr class="notion-hr notion-block-348b7925fd2880d19477ee95aacc82f4"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880fdaf25c6e0a6b8a61d" data-id="348b7925fd2880fdaf25c6e0a6b8a61d"><span><div id="348b7925fd2880fdaf25c6e0a6b8a61d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880fdaf25c6e0a6b8a61d" title="/opsx:verify 三维验证 · 一页速记清单"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">/opsx:verify 三维验证 · 一页速记清单</span></span></h3><blockquote class="notion-quote notion-block-348b7925fd2880278c61f50ec975c3fc"><div>核心定位：<b>事后验证</b>（代码写完后），通过 3C 模型查漏补缺，确保交付质量，而非“唯一防线”</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28800f8afbf6dc905e9f31" data-id="348b7925fd28800f8afbf6dc905e9f31"><span><div id="348b7925fd28800f8afbf6dc905e9f31" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28800f8afbf6dc905e9f31" title="1 三维验证框架（3C Model）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 三维验证框架（3C Model）</span></span></h4><table class="notion-simple-table notion-block-348b7925fd2880a2b10dd00027a8c9ec"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd28804da8a6cab5e1465207"><td class="" style="width:120px"><div class="notion-simple-table-cell">维度</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">核心问题</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">检查要点</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28805fa2f1c8af285812be"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Completeness（完整性）</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">所有任务完成了吗？需求都有对应代码吗？</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 全任务 Check 状态&lt;br&gt;✅ 全需求覆盖代码实现</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880bba46febd441f6a7f4"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Correctness（正确性）</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">实现匹配规格意图吗？边界条件处理了吗？</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 实现与 Spec 一致&lt;br&gt;✅ 边缘场景已处理</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28805fabe4fb0f7acae5e4"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>Coherence（一致性）</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">design.md</code> 方案在代码中体现了吗？命名一致吗？</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ 代码落地设计方案&lt;br&gt;✅ 命名/结构无冲突</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28806291bcfcb6c546996e" data-id="348b7925fd28806291bcfcb6c546996e"><span><div id="348b7925fd28806291bcfcb6c546996e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28806291bcfcb6c546996e" title="2 真实输出样例"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 真实输出样例</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880329764dd92b762e5a3" data-id="348b7925fd2880329764dd92b762e5a3"><span><div id="348b7925fd2880329764dd92b762e5a3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880329764dd92b762e5a3" title="3 输出三级判定"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3 输出三级判定</span></span></h4><table class="notion-simple-table notion-block-348b7925fd28803aa144ef84e09651f3"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd288089aec3e0d430551352"><td class="" style="width:120px"><div class="notion-simple-table-cell">等级</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定义</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">处理策略</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880b4809ac729f67cf3cf"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>CRITICAL</b>（必须修复）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">阻断归档的致命问题</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">必须修复，否则无法归档</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28808eab08eb7db3b4cf0c"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>WARNING</b>（建议修复）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">不阻断归档的潜在风险</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">建议修复，不强制阻断</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28808d84efe6390f2cbfb7"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>SUGGESTION</b>（锦上添花）</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">优化建议，非硬性要求</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">按需采纳，提升质量</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288054afb2e2849027e0dd" data-id="348b7925fd288054afb2e2849027e0dd"><span><div id="348b7925fd288054afb2e2849027e0dd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288054afb2e2849027e0dd" title="4 关键认知与边界"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4 关键认知与边界</span></span></h4><div class="notion-text notion-block-348b7925fd288001b973e1002d8c8c13">🚨 啊哈时刻<div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-348b7925fd2880868c65c496a320156e"><li>AI 跑完 <code class="notion-inline-code">apply</code> 可能自认“搞定”，但 <code class="notion-inline-code">/opsx:verify</code> 能快速暴露 <code class="notion-inline-code">WARNING</code></li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd2880359512fca94e4526e4"><li>验证的核心价值：<b>在“以为做完”的瞬间，用规范判定实际未完成</b></li></ul></div></div><div class="notion-text notion-block-348b7925fd288017ba52f037fb75551f">🆚 与 /analyze 的区别</div><table class="notion-simple-table notion-block-348b7925fd288094becbf305c4d8e652"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880048a54d3aa41bf05a1"><td class="" style="width:120px"><div class="notion-simple-table-cell">命令</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">阶段</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">定位</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">关系</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28807c9733fe4e6a82f259"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/opsx:verify</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">事后验证</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">代码写完后，校验交付物</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>两者互补，不替代</b></div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880cbaaafc80ad2d598eb"><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">/opsx:analyze</code></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">事前检查</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">文档/提案阶段，预排风险</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28801c8f32e3b8cd87e335" data-id="348b7925fd28801c8f32e3b8cd87e335"><span><div id="348b7925fd28801c8f32e3b8cd87e335" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28801c8f32e3b8cd87e335" title="5 核心原则"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5 核心原则</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-348b7925fd2880a4ad55c2655588cbde" style="list-style-type:decimal"><li><b>verify 不阻止归档</b>：即使存在 <code class="notion-inline-code">WARNING</code>，用户仍可选择归档，拥有最终决定权</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-348b7925fd28805e8f6de7ef7908eb78" style="list-style-type:decimal"><li><b>第一道防线</b>：<code class="notion-inline-code">verify</code> 是质量把关的<b>首要环节</b>，但不是唯一防线</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-348b7925fd28800aa16ccda223ec717a" style="list-style-type:decimal"><li><b>省返工</b>：通过早期校验，把问题扼杀在归档前，降低后期维护成本</li></ol><hr class="notion-hr notion-block-348b7925fd288080925cfe6812ad80a8"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd288088a9c0c5cf818c54c9" data-id="348b7925fd288088a9c0c5cf818c54c9"><span><div id="348b7925fd288088a9c0c5cf818c54c9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288088a9c0c5cf818c54c9" title="Delta Spec——只写变化，不重写整个需求"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Delta Spec——只写变化，不重写整个需求</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288046b586e06bb250d210" data-id="348b7925fd288046b586e06bb250d210"><span><div id="348b7925fd288046b586e06bb250d210" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288046b586e06bb250d210" title="1 全量 Spec vs Delta Spec 对比"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1 全量 Spec vs Delta Spec 对比</span></span></h4><table class="notion-simple-table notion-block-348b7925fd28805f9999d22ee21f114b"><tbody><tr class="notion-simple-table-row notion-simple-table-header-row notion-block-348b7925fd2880898f15f57a91f9a511"><td class="" style="width:120px"><div class="notion-simple-table-cell">方式</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">操作</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">缺点</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd2880ef854ec9dc66b083b4"><td class="" style="width:120px"><div class="notion-simple-table-cell">❌ 全量 Spec</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每次改需求都要重读整个 spec 文件、重写全部章节内容</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AI 需处理大量 token，容易「丢东西」</div></td></tr><tr class="notion-simple-table-row notion-block-348b7925fd28800599aecd75fe5a7c3f"><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ Delta Spec</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">每个 change 只描述自己的变化，spec 文件很小</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">AI 精准处理，不容易「丢东西」</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880a0b77df97468e1f821" data-id="348b7925fd2880a0b77df97468e1f821"><span><div id="348b7925fd2880a0b77df97468e1f821" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880a0b77df97468e1f821" title="2 Delta Spec 三种变更类型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2 Delta Spec 三种变更类型</span></span></h4><ul class="notion-list notion-list-disc notion-block-348b7925fd2880ba90c3ed1050b7b22b"><li><code class="notion-inline-code">ADDED</code>：新增需求</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd288088ad88ea5f2d106895"><li><code class="notion-inline-code">MODIFIED</code>：修改已有需求</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd28803f9355e77c6d9a883e"><li><code class="notion-inline-code">REMOVED</code>：删除需求</li></ul><div class="notion-text notion-block-348b7925fd2880f4be46dd95282bd7da">实操场景示例<div class="notion-text-children"><div class="notion-text notion-block-348b7925fd2880fb983ad787a3e1149f">以 <code class="notion-inline-code">add-projects-section</code> 变更为例：</div><ul class="notion-list notion-list-disc notion-block-348b7925fd2880bcb3f0fbda1664b6e3"><li><code class="notion-inline-code">ADDED</code>: 新增 Projects 展示区域</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd288014b66cec68776fb269"><li><code class="notion-inline-code">MODIFIED</code>: Hero CTA 按钮锚点改为跳转 → #projects</li></ul></div></div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880d1a9a2f711ed9024ad" data-id="348b7925fd2880d1a9a2f711ed9024ad"><span><div id="348b7925fd2880d1a9a2f711ed9024ad" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880d1a9a2f711ed9024ad" title="3 归档行为"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3 归档行为</span></span></h4><ul class="notion-list notion-list-disc notion-block-348b7925fd2880bda0e6fa6695ab50bc"><li><code class="notion-inline-code">ADDED</code>：追加到主 spec</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd288099b5f7f0dadedbd87a"><li><code class="notion-inline-code">MODIFIED</code>：替换对应部分</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd2880f6ad2fc612611e786e"><li><code class="notion-inline-code">REMOVED</code>：从主 spec 删除</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28801ea17dd9b47c6a578d" data-id="348b7925fd28801ea17dd9b47c6a578d"><span><div id="348b7925fd28801ea17dd9b47c6a578d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28801ea17dd9b47c6a578d" title="4 为什么高效"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4 为什么高效</span></span></h4><ul class="notion-list notion-list-disc notion-block-348b7925fd288023bbfcdf6e6044bb42"><li>每个 change spec 文件很小 → AI token 消耗少</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd2880f09dd5c2c5746094c8"><li>不容易「丢东西」</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd288001beebe0e62386f94b"><li>精准聚焦当前变化</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880939997eedfcfbc6ece" data-id="348b7925fd2880939997eedfcfbc6ece"><span><div id="348b7925fd2880939997eedfcfbc6ece" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880939997eedfcfbc6ece" title="5 MODIFIED vs 新建 spec 决策规则"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5 MODIFIED vs 新建 spec 决策规则</span></span></h4><ul class="notion-list notion-list-disc notion-block-348b7925fd288063b22ee568e212ff97"><li>扩展已有模块 → 使用 <code class="notion-inline-code">MODIFIED</code></li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd2880d485c3f762467e4aa0"><li>全新业务域（首次） → <code class="notion-inline-code">ADDED</code> 新文件</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd2880708b68cae6874c91c2"><li>判断依据：主 spec 里有没有对应内容？</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880ad80b2de280cb9d428" data-id="348b7925fd2880ad80b2de280cb9d428"><span><div id="348b7925fd2880ad80b2de280cb9d428" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880ad80b2de280cb9d428" title="6 核心结论"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6 核心结论</span></span></h4><div class="notion-text notion-block-348b7925fd2880978131fce10b8262a4">每个 Delta Spec 文件只有变化部分 → AI 精准聚焦 → 不丢需求，不错改</div><hr class="notion-hr notion-block-348b7925fd2880e2bbf8e1e88a1072ee"/><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-348b7925fd2880109ca1df4b9dee0490" data-id="348b7925fd2880109ca1df4b9dee0490"><span><div id="348b7925fd2880109ca1df4b9dee0490" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880109ca1df4b9dee0490" title="项目：开发一个可部署的个人品牌站"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">项目：开发一个可部署的个人品牌站</span></span></h2><div class="notion-text notion-block-348b7925fd288079bc6ade7c4e74621a">OpenSpec SDD 驱动开发工作流</div><div class="notion-callout notion-gray_background_co notion-block-348b7925fd28801f99bced8ca926024b"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🗒️">🗒️</span></div><div class="notion-callout-text"><div class="notion-text notion-block-348b7925fd2880b68b80dadbc63d81ed">模版</div><div class="notion-text notion-block-348b7925fd2880bca862e6d010c66739">config.yaml</div><div class="notion-text notion-block-348b7925fd28806da2c7fc8618b44333">CLAUDE.md</div></div></div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880c6b577de6ca03ce20d" data-id="348b7925fd2880c6b577de6ca03ce20d"><span><div id="348b7925fd2880c6b577de6ca03ce20d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880c6b577de6ca03ce20d" title="初始项目环境搭建+ OpenSpec 初始化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">初始项目环境搭建+ OpenSpec 初始化</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880a49474c6c4e95bf64f" data-id="348b7925fd2880a49474c6c4e95bf64f"><span><div id="348b7925fd2880a49474c6c4e95bf64f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880a49474c6c4e95bf64f" title="Step 1 全局配置 OpenSpec"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 1 全局配置 OpenSpec</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880f29473fea7212b587c" data-id="348b7925fd2880f29473fea7212b587c"><span><div id="348b7925fd2880f29473fea7212b587c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880f29473fea7212b587c" title="Step 2 创建前端项目脚手架"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 2 创建前端项目脚手架</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880559174e19c1f8c8e68" data-id="348b7925fd2880559174e19c1f8c8e68"><span><div id="348b7925fd2880559174e19c1f8c8e68" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880559174e19c1f8c8e68" title="Step 3 配置 OpenSpec 的 宪法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 3 配置 OpenSpec 的 宪法</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288078a10ff25cbffd8c5b" data-id="348b7925fd288078a10ff25cbffd8c5b"><span><div id="348b7925fd288078a10ff25cbffd8c5b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288078a10ff25cbffd8c5b" title="Step 4 创建项目宪法（CLAUDE.md）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 4 创建项目宪法（<a class="notion-link" href="http://claude.md/" target="_blank" rel="noopener noreferrer">CLAUDE.md</a>）</span></span></h4><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd288086b800d11f6f4f0039" data-id="348b7925fd288086b800d11f6f4f0039"><span><div id="348b7925fd288086b800d11f6f4f0039" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288086b800d11f6f4f0039" title="Change 1 ：开发品牌站的 Hero-Section"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Change 1 ：开发品牌站的 Hero-Section</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880bc8ed2eeab6bd71b6b" data-id="348b7925fd2880bc8ed2eeab6bd71b6b"><span><div id="348b7925fd2880bc8ed2eeab6bd71b6b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880bc8ed2eeab6bd71b6b" title="Step 5 使用 Open Spec 的探索模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 5 使用 Open Spec 的探索模式</span></span></h4><div class="notion-text notion-block-348b7925fd2880db9f74d642d10aa2c8">/opsx：explore </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288023a58debd40d83d4a1" data-id="348b7925fd288023a58debd40d83d4a1"><span><div id="348b7925fd288023a58debd40d83d4a1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288023a58debd40d83d4a1" title="Step 6 确定 Change 1的 提案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 6 确定 Change 1的 提案</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880b99661d7f5ca8c828d" data-id="348b7925fd2880b99661d7f5ca8c828d"><span><div id="348b7925fd2880b99661d7f5ca8c828d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880b99661d7f5ca8c828d" title="Step 7 开始分阶段执行Change 1的 代码生成"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 7 开始分阶段执行Change 1的 代码生成</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288023b525c07a6ca09515" data-id="348b7925fd288023b525c07a6ca09515"><span><div id="348b7925fd288023b525c07a6ca09515" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288023b525c07a6ca09515" title="Step 8 针对 Change 1的apply 结果进行三维校验"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 8 针对 Change 1的apply 结果进行三维校验</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880ffa4c6d2b2d6cfd4f0" data-id="348b7925fd2880ffa4c6d2b2d6cfd4f0"><span><div id="348b7925fd2880ffa4c6d2b2d6cfd4f0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880ffa4c6d2b2d6cfd4f0" title="Step 9 针对 Change 1 完成Spec归档"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 9 针对 Change 1 完成Spec归档</span></span></h4><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880f88befe91f63834338" data-id="348b7925fd2880f88befe91f63834338"><span><div id="348b7925fd2880f88befe91f63834338" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880f88befe91f63834338" title="Change 2 ：开发品牌站的 navigation"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Change 2 ：开发品牌站的 navigation</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880f2ad42ef96ff787bcf" data-id="348b7925fd2880f2ad42ef96ff787bcf"><span><div id="348b7925fd2880f2ad42ef96ff787bcf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880f2ad42ef96ff787bcf" title="Step 10 确定 Change 2的 提案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 10 确定 Change 2的 提案</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288094a0d8eaa1d3fe8225" data-id="348b7925fd288094a0d8eaa1d3fe8225"><span><div id="348b7925fd288094a0d8eaa1d3fe8225" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288094a0d8eaa1d3fe8225" title="Step 11 确定 Change 2的 提案并开始构建代码！"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 11 确定 Change 2的 提案并开始构建代码！</span></span></h4><div class="notion-text notion-block-348b7925fd288091a226da430d360ce9">加快节奏</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880d3b05df3c7563acad2" data-id="348b7925fd2880d3b05df3c7563acad2"><span><div id="348b7925fd2880d3b05df3c7563acad2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880d3b05df3c7563acad2" title="Step 12 针对 Change 2的apply 结果进行三维校验"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 12 针对 Change 2的apply 结果进行三维校验</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880348fd0d445226183f4" data-id="348b7925fd2880348fd0d445226183f4"><span><div id="348b7925fd2880348fd0d445226183f4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880348fd0d445226183f4" title="Step 13 针对 Change 2 完成Spec归档"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 13 针对 Change 2 完成Spec归档</span></span></h4><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880379acadb85cc4528cc" data-id="348b7925fd2880379acadb85cc4528cc"><span><div id="348b7925fd2880379acadb85cc4528cc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880379acadb85cc4528cc" title="Change 3 ：OpenSpec Delta Spec 的功能标记"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Change 3 ：OpenSpec Delta Spec 的功能标记</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd28802380e3ef6030dfd18e" data-id="348b7925fd28802380e3ef6030dfd18e"><span><div id="348b7925fd28802380e3ef6030dfd18e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd28802380e3ef6030dfd18e" title="Step 14 Change 3 提案 并 测试 修改的功能标记"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 14 Change 3 提案 并 测试 修改的功能标记</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880da9610ebbdfb9607cf" data-id="348b7925fd2880da9610ebbdfb9607cf"><span><div id="348b7925fd2880da9610ebbdfb9607cf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880da9610ebbdfb9607cf" title="Step 15 一次性完成 Change 3 的所有变更流程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 15 一次性完成 Change 3 的所有变更流程</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880848a17c44d8ed1372c" data-id="348b7925fd2880848a17c44d8ed1372c"><span><div id="348b7925fd2880848a17c44d8ed1372c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880848a17c44d8ed1372c" title="Step 16 针对 Change 3 完成Spec归档"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 16 针对 Change 3 完成Spec归档</span></span></h4><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-348b7925fd2880d49eb6ca35c487e8b6" data-id="348b7925fd2880d49eb6ca35c487e8b6"><span><div id="348b7925fd2880d49eb6ca35c487e8b6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880d49eb6ca35c487e8b6" title="Change 4 ： 配置 About Section + SEO优化 + 部署上线"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Change 4 ： 配置 About Section + SEO优化 + 部署上线</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880b1a1b3d20767267506" data-id="348b7925fd2880b1a1b3d20767267506"><span><div id="348b7925fd2880b1a1b3d20767267506" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880b1a1b3d20767267506" title="Step 17 Change 4 继续丰富个人品牌站"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 17 Change 4 继续丰富个人品牌站</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd2880faa8d1c18140dbb610" data-id="348b7925fd2880faa8d1c18140dbb610"><span><div id="348b7925fd2880faa8d1c18140dbb610" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880faa8d1c18140dbb610" title="Step 18 Change 4 添加网站的 SEO优化策略"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 18 Change 4 添加网站的 SEO优化策略</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288059915dc5830910f810" data-id="348b7925fd288059915dc5830910f810"><span><div id="348b7925fd288059915dc5830910f810" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288059915dc5830910f810" title="Step 19 单次执行多步的提案文件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 19 单次执行多步的提案文件</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-348b7925fd288026a7adde88dcf78ac1" data-id="348b7925fd288026a7adde88dcf78ac1"><span><div id="348b7925fd288026a7adde88dcf78ac1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd288026a7adde88dcf78ac1" title="Step 20 个人品牌站部署上线"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Step 20 个人品牌站部署上线</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-348b7925fd288065b772f8dde17de649"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://file.notion.com/f/f/f6bb7925-fd28-8149-9b46-00037e868248/7166868a-0ad3-4778-85de-3524c05ab8b6/image.png?table=block&amp;id=348b7925-fd28-8065-b772-f8dde17de649&amp;spaceId=f6bb7925-fd28-8149-9b46-00037e868248&amp;expirationTimestamp=1788278400000&amp;signature=bgqmFGWiMPc6POubldcXhLncClAWyhYa4ztBa4zSMRQ&amp;t=348b7925-fd28-8065-b772-f8dde17de649" alt="notion image" loading="lazy" decoding="async"/></div></figure><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-35bb7925fd288052ac52fdef76c6ed95" data-id="35bb7925fd288052ac52fdef76c6ed95"><span><div id="35bb7925fd288052ac52fdef76c6ed95" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35bb7925fd288052ac52fdef76c6ed95" title="项目升级-全栈"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">项目升级-全栈</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-35bb7925fd28802a9ec3d997eb69230c" data-id="35bb7925fd28802a9ec3d997eb69230c"><span><div id="35bb7925fd28802a9ec3d997eb69230c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35bb7925fd28802a9ec3d997eb69230c" title="项目初始化，OpenSpec 配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">项目初始化，OpenSpec 配置</span></span></h3><div class="notion-text notion-block-35bb7925fd28804aa8bbdbf402666b04">Step 1 切换 OpenSpec 的配置模式</div><div class="notion-blank notion-block-35bb7925fd28803193b5f9dbd8d1536f"> </div><div class="notion-blank notion-block-35bb7925fd28805c86d8d0ec7fe087c7"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-348b7925fd2880a58f69e653f20c3329" data-id="348b7925fd2880a58f69e653f20c3329"><span><div id="348b7925fd2880a58f69e653f20c3329" class="notion-header-anchor"></div><a class="notion-hash-link" href="#348b7925fd2880a58f69e653f20c3329" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-348b7925fd288088b273ca33838cd83d"><li>一些引用</li></ul><ul class="notion-list notion-list-disc notion-block-348b7925fd28809e8f95e76e6b290a99"><li>引用文章</li></ul><div class="notion-blank notion-block-348b7925fd288031ae0cc7f04f7853e5"> </div><div class="notion-callout notion-gray_background_co notion-block-348b7925fd28803fae6de1d653547287"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">欢迎您在底部评论区留言，一起交流~</div></div><div class="notion-blank notion-block-348b7925fd2880a3a62aee19ea5e55bf"> </div><div class="notion-blank notion-block-348b7925fd28807aa7a9e7ab1f4362ef"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[08 Vibe Coding ]]></title>
            <link>https://tangly1024.com/article/VibeCoding-008</link>
            <guid>https://tangly1024.com/article/VibeCoding-008</guid>
            <pubDate>Fri, 10 Apr 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Spec-Kit]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-35bb7925fd2880d0bbd8f1c32c5e152e"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-35bb7925fd288149811ce8c4525b16cd"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text"></div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-35bb7925fd28809da6d9d3622350a457" data-id="35bb7925fd28809da6d9d3622350a457"><span><div id="35bb7925fd28809da6d9d3622350a457" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35bb7925fd28809da6d9d3622350a457" title="Spec-Kit"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Spec-Kit</span></span></h2><div class="notion-blank notion-block-35bb7925fd28807da170e5b6dcc6abbf"> </div><div class="notion-blank notion-block-35bb7925fd28800a869dcd7ff97b1434"> </div><div class="notion-blank notion-block-35bb7925fd288027bb97f451a91f8648"> </div><div class="notion-blank notion-block-35bb7925fd288018b5e5eda2eb0e5131"> </div><div class="notion-blank notion-block-35bb7925fd2880ecb3f5f0727b13d0e2"> </div><div class="notion-blank notion-block-35bb7925fd2880ce806bc2dce1973923"> </div><div class="notion-blank notion-block-35bb7925fd28804c8ba7f06b19ba8a99"> </div><div class="notion-blank notion-block-35bb7925fd2880f1a68acdfb4b0ad0bb"> </div><div class="notion-blank notion-block-35bb7925fd2880959410c97146b3e566"> </div><div class="notion-blank notion-block-35bb7925fd28809d8141f9d60c76a583"> </div><div class="notion-blank notion-block-35bb7925fd2880b3a2e6efb5c1c89334"> </div><div class="notion-blank notion-block-35bb7925fd28803a9810e27a2afed20d"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-35bb7925fd28817fb3afc56f38fc71b5" data-id="35bb7925fd28817fb3afc56f38fc71b5"><span><div id="35bb7925fd28817fb3afc56f38fc71b5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#35bb7925fd28817fb3afc56f38fc71b5" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-35bb7925fd288190afb4cb07e1c8fcf5"><li>一些引用</li></ul><ul class="notion-list notion-list-disc notion-block-35bb7925fd2881ce9ae6d5cc8b4e1f2f"><li>引用文章</li></ul><div class="notion-blank notion-block-35bb7925fd28819fa9b7fa9316c91e0d"> </div><div class="notion-callout notion-gray_background_co notion-block-35bb7925fd288137800df6c38c966ae6"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">欢迎您在底部评论区留言，一起交流~</div></div><div class="notion-blank notion-block-35bb7925fd288192bbbcfddebde6887c"> </div><div class="notion-blank notion-block-35bb7925fd2881b49d5ad4466f0edd11"> </div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>