<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="720" viewBox="0 0 1200 720">
  <rect x="0" y="0" width="1200" height="720" fill="#f6f9ff"/>
  <rect x="40" y="30" width="1120" height="660" rx="22" fill="#ffffff" stroke="#d8e2f1"/>
  <text x="600" y="78" text-anchor="middle" font-family="Arial, sans-serif" font-size="32" fill="#1f2d3d">Tool Calling + MCP + Agent 循环</text>

  <rect x="80" y="118" width="1040" height="88" rx="14" fill="#edf3ff"/>
  <text x="600" y="168" text-anchor="middle" font-family="Arial, sans-serif" font-size="21" fill="#3a506b">目标：让 LLM 在受控边界内调用外部能力，并可观测地完成多步任务</text>

  <rect x="80" y="238" width="210" height="120" rx="16" fill="#ffd37f"/>
  <text x="185" y="292" text-anchor="middle" font-family="Arial, sans-serif" font-size="24" fill="#1f2d3d">用户请求</text>
  <text x="185" y="320" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" fill="#3b4c62">Task + Constraints</text>

  <rect x="320" y="238" width="240" height="120" rx="16" fill="#7be5cc"/>
  <text x="440" y="292" text-anchor="middle" font-family="Arial, sans-serif" font-size="24" fill="#1f2d3d">LLM Planner</text>
  <text x="440" y="320" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" fill="#3b4c62">Tool Selection + Args</text>

  <rect x="590" y="238" width="250" height="120" rx="16" fill="#b8d1ff"/>
  <text x="715" y="292" text-anchor="middle" font-family="Arial, sans-serif" font-size="24" fill="#1f2d3d">MCP Adapter</text>
  <text x="715" y="320" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" fill="#3b4c62">Schema / Transport / Auth</text>

  <rect x="870" y="238" width="250" height="120" rx="16" fill="#ffbecd"/>
  <text x="995" y="292" text-anchor="middle" font-family="Arial, sans-serif" font-size="24" fill="#1f2d3d">Tools Runtime</text>
  <text x="995" y="320" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" fill="#3b4c62">DB / Search / Code / API</text>

  <line x1="290" y1="298" x2="320" y2="298" stroke="#8aa0bf" stroke-width="4"/>
  <line x1="560" y1="298" x2="590" y2="298" stroke="#8aa0bf" stroke-width="4"/>
  <line x1="840" y1="298" x2="870" y2="298" stroke="#8aa0bf" stroke-width="4"/>

  <rect x="80" y="392" width="500" height="258" rx="18" fill="#eef3fb"/>
  <text x="330" y="436" text-anchor="middle" font-family="Arial, sans-serif" font-size="29" fill="#1f2d3d">Agent Loop（执行控制）</text>
  <text x="110" y="474" font-family="Arial, sans-serif" font-size="19" fill="#34475f">1) Plan：拆解子任务与依赖</text>
  <text x="110" y="506" font-family="Arial, sans-serif" font-size="19" fill="#34475f">2) Act：发起 Tool Calling</text>
  <text x="110" y="538" font-family="Arial, sans-serif" font-size="19" fill="#34475f">3) Observe：读取结果与错误信号</text>
  <text x="110" y="570" font-family="Arial, sans-serif" font-size="19" fill="#34475f">4) Refine：修正参数并继续循环</text>
  <text x="110" y="612" font-family="Arial, sans-serif" font-size="18" fill="#5a6f88">退出条件：达成目标 / 达到步数上限 / 触发安全策略</text>

  <rect x="620" y="392" width="500" height="258" rx="18" fill="#eaf9f2"/>
  <text x="870" y="436" text-anchor="middle" font-family="Arial, sans-serif" font-size="29" fill="#1f2d3d">工程控制点</text>
  <text x="650" y="474" font-family="Arial, sans-serif" font-size="19" fill="#34475f">- 权限最小化：按 Tool 白名单暴露能力</text>
  <text x="650" y="506" font-family="Arial, sans-serif" font-size="19" fill="#34475f">- 参数校验：Schema + 类型约束</text>
  <text x="650" y="538" font-family="Arial, sans-serif" font-size="19" fill="#34475f">- 可观测性：Trace / Step Logs / Cost Metrics</text>
  <text x="650" y="570" font-family="Arial, sans-serif" font-size="19" fill="#34475f">- 回退策略：Tool 失败时降级到纯文本回复</text>
  <text x="650" y="612" font-family="Arial, sans-serif" font-size="18" fill="#5a6f88">关键指标：Success Rate, Latency, Token Cost, Hallucination Risk</text>
</svg>
