Files
ai-agent-book/book-zhtw/images/fig2-13.svg
T
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

191 lines
18 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 40 860 500" width="860" height="500" style="background:#ffffff">
<defs><marker id="ah" markerWidth="12" markerHeight="8" refX="12" refY="4" orient="auto"><polygon points="0 0, 12 4, 0 8" fill="#333333"/></marker></defs>
<!-- Column headers -->
<text x="145" y="62" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="15" fill="#333333" text-anchor="middle" dominant-baseline="central" font-weight="bold">Turn 1 完成時</text>
<text x="400" y="62" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="15" fill="#333333" text-anchor="middle" dominant-baseline="central" font-weight="bold">Turn 2 完成時</text>
<text x="655" y="62" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="15" fill="#333333" text-anchor="middle" dominant-baseline="central" font-weight="bold">Turn 3 完成時</text>
<text x="145" y="82" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#666666" text-anchor="middle" dominant-baseline="central">(首次載入 PPTX skill)</text>
<text x="400" y="82" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#666666" text-anchor="middle" dominant-baseline="central">(讀取 PDF 檔案)</text>
<text x="655" y="82" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#666666" text-anchor="middle" dominant-baseline="central">(寫出 HTML)</text>
<!-- Column dividers -->
<line x1="270" y1="55" x2="270" y2="430" stroke="#dddddd" stroke-width="1"/>
<line x1="525" y1="55" x2="525" y2="430" stroke="#dddddd" stroke-width="1"/>
<!-- ===================================================== -->
<!-- Helper: 11 rows of fixed labels positioned at y = 100 + i*24 -->
<!-- Row labels: -->
<!-- 0: system (NEW T1, HIT T2, HIT T3) -->
<!-- 1: tools (NEW T1, HIT T2, HIT T3) -->
<!-- 2: user_q1 (NEW T1, HIT T2, HIT T3) -->
<!-- 3: ★ skill_listing (NEW T1, HIT T2, HIT T3) -->
<!-- 4: asst: Skill(pptx) (NEW T1, HIT T2, HIT T3) -->
<!-- 5: tool_result (NEW T1, HIT T2, HIT T3) -->
<!-- 6: ★ skill_content (NEW T1, HIT T2, HIT T3) -->
<!-- 7: asst: Read(pdf) (— T1, NEW T2, HIT T3) -->
<!-- 8: tool_result (— T1, NEW T2, HIT T3) -->
<!-- 9: asst: Write(html) (— T1, — T2, NEW T3) -->
<!-- 10: tool_result (— T1, — T2, NEW T3) -->
<!-- ===================================================== -->
<!-- ============== COLUMN 1: Turn 1 ============== -->
<!-- Rows 0-6: NEW (yellow) -->
<rect x="25" y="100" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="33" y="111" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">system</text>
<text x="258" y="111" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<rect x="25" y="124" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="33" y="135" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">tools</text>
<text x="258" y="135" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<rect x="25" y="148" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="33" y="159" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">user_q1</text>
<text x="258" y="159" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<rect x="25" y="172" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="33" y="183" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">★ skill_listing</text>
<text x="258" y="183" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<rect x="25" y="196" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="33" y="207" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">asst: Skill(pptx)</text>
<text x="258" y="207" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<rect x="25" y="220" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="33" y="231" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">tool_result</text>
<text x="258" y="231" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<rect x="25" y="244" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="33" y="255" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">★ skill_content</text>
<text x="258" y="255" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<!-- Rows 7-10: future (dashed empty) -->
<rect x="25" y="268" width="240" height="22" rx="3" fill="none" stroke="#cccccc" stroke-width="1" stroke-dasharray="4,3"/>
<rect x="25" y="292" width="240" height="22" rx="3" fill="none" stroke="#cccccc" stroke-width="1" stroke-dasharray="4,3"/>
<rect x="25" y="316" width="240" height="22" rx="3" fill="none" stroke="#cccccc" stroke-width="1" stroke-dasharray="4,3"/>
<rect x="25" y="340" width="240" height="22" rx="3" fill="none" stroke="#cccccc" stroke-width="1" stroke-dasharray="4,3"/>
<!-- Column 1 footer: cost -->
<rect x="25" y="378" width="240" height="44" rx="4" fill="#fff8e1" stroke="#e6a817" stroke-width="1.5"/>
<text x="145" y="392" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#333333" text-anchor="middle" dominant-baseline="central" font-weight="bold">本輪 cache_creation</text>
<text x="145" y="410" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" fill="#a06a00" text-anchor="middle" dominant-baseline="central" font-weight="bold">≈ 2.5k tokens</text>
<!-- ============== COLUMN 2: Turn 2 ============== -->
<!-- Rows 0-6: CACHED (gray) -->
<rect x="280" y="100" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="288" y="111" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">system</text>
<text x="513" y="111" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="280" y="124" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="288" y="135" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">tools</text>
<text x="513" y="135" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="280" y="148" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="288" y="159" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">user_q1</text>
<text x="513" y="159" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="280" y="172" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="288" y="183" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">★ skill_listing</text>
<text x="513" y="183" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="280" y="196" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="288" y="207" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">asst: Skill(pptx)</text>
<text x="513" y="207" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="280" y="220" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="288" y="231" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">tool_result</text>
<text x="513" y="231" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="280" y="244" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="288" y="255" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">★ skill_content</text>
<text x="513" y="255" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<!-- Rows 7-8: NEW (yellow) -->
<rect x="280" y="268" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="288" y="279" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">asst: Read(pdf)</text>
<text x="513" y="279" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<rect x="280" y="292" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="288" y="303" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">tool_result</text>
<text x="513" y="303" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<!-- Rows 9-10: future (dashed) -->
<rect x="280" y="316" width="240" height="22" rx="3" fill="none" stroke="#cccccc" stroke-width="1" stroke-dasharray="4,3"/>
<rect x="280" y="340" width="240" height="22" rx="3" fill="none" stroke="#cccccc" stroke-width="1" stroke-dasharray="4,3"/>
<!-- Column 2 footer: cost -->
<rect x="280" y="378" width="240" height="44" rx="4" fill="#fff8e1" stroke="#e6a817" stroke-width="1.5"/>
<text x="400" y="392" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#333333" text-anchor="middle" dominant-baseline="central" font-weight="bold">本輪 cache_creation</text>
<text x="400" y="410" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" fill="#a06a00" text-anchor="middle" dominant-baseline="central" font-weight="bold">≈ 0.5k tokens</text>
<!-- ============== COLUMN 3: Turn 3 ============== -->
<!-- Rows 0-8: CACHED (gray) -->
<rect x="535" y="100" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="111" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">system</text>
<text x="768" y="111" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="535" y="124" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="135" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">tools</text>
<text x="768" y="135" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="535" y="148" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="159" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">user_q1</text>
<text x="768" y="159" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="535" y="172" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="183" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">★ skill_listing</text>
<text x="768" y="183" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="535" y="196" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="207" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">asst: Skill(pptx)</text>
<text x="768" y="207" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="535" y="220" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="231" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">tool_result</text>
<text x="768" y="231" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="535" y="244" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="255" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">★ skill_content</text>
<text x="768" y="255" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="535" y="268" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="279" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">asst: Read(pdf)</text>
<text x="768" y="279" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<rect x="535" y="292" width="240" height="22" rx="3" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="543" y="303" font-family="'Courier New', Courier, monospace" font-size="11" fill="#777777" dominant-baseline="central">tool_result</text>
<text x="768" y="303" font-family="Arial, sans-serif" font-size="10" fill="#666666" text-anchor="end" dominant-baseline="central">HIT</text>
<!-- Rows 9-10: NEW (yellow) -->
<rect x="535" y="316" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="543" y="327" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">asst: Write(html)</text>
<text x="768" y="327" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<rect x="535" y="340" width="240" height="22" rx="3" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="543" y="351" font-family="'Courier New', Courier, monospace" font-size="11" fill="#333333" dominant-baseline="central">tool_result</text>
<text x="768" y="351" font-family="Arial, sans-serif" font-size="10" fill="#c9a227" text-anchor="end" dominant-baseline="central" font-weight="bold">NEW</text>
<!-- Column 3 footer: cost -->
<rect x="535" y="378" width="240" height="44" rx="4" fill="#fff8e1" stroke="#e6a817" stroke-width="1.5"/>
<text x="655" y="392" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#333333" text-anchor="middle" dominant-baseline="central" font-weight="bold">本輪 cache_creation</text>
<text x="655" y="410" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" fill="#a06a00" text-anchor="middle" dominant-baseline="central" font-weight="bold">≈ 0.4k tokens</text>
<!-- Legend -->
<rect x="40" y="450" width="20" height="14" rx="2" fill="#fff3cd" stroke="#e6a817" stroke-width="1.5"/>
<text x="68" y="457" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#333333" dominant-baseline="central">NEW = 該輪新增 token,付一次 cache_creation</text>
<rect x="40" y="472" width="20" height="14" rx="2" fill="#f0f0f0" stroke="#aaaaaa" stroke-width="1"/>
<text x="68" y="479" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#333333" dominant-baseline="central">HIT = 已在快取字首,本輪免費命中</text>
<rect x="40" y="494" width="20" height="14" rx="2" fill="none" stroke="#cccccc" stroke-width="1" stroke-dasharray="4,3"/>
<text x="68" y="501" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#333333" dominant-baseline="central">— 該輪尚未生成的內容</text>
<text x="450" y="479" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#666666" dominant-baseline="central">★ 標記 emit-once 的 attachment:僅 Turn 1 付一次 cache_creation</text>
<text x="450" y="497" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="12" fill="#666666" dominant-baseline="central"> 之後所有輪次永久 HIT,邊際成本為零。</text>
<!-- Bottom note about position -->
<text x="410" y="525" font-family="Arial, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif" font-size="13" fill="#333333" text-anchor="middle" dominant-baseline="central" font-style="italic">注意:每條訊息的索引位置一旦插入就不再移動;新內容只追加到 array 末尾。</text>
</svg>