34 lines
774 B
Markdown
34 lines
774 B
Markdown
|
|
---
|
||
|
|
tags:
|
||
|
|
- claude-code
|
||
|
|
- mermaid
|
||
|
|
create time: 2026-06-08 00:00
|
||
|
|
---
|
||
|
|
|
||
|
|
# Agent Loop 简易流程
|
||
|
|
|
||
|
|
## 概述
|
||
|
|
|
||
|
|
Claude Code Agent 的核心执行循环:输入经过 Context 管理后交给 LLM 流式输出,若返回 `tool_use` 则执行工具并将结果回注 Context,循环往复;否则结束。
|
||
|
|
|
||
|
|
## 正文
|
||
|
|
|
||
|
|
```mermaid
|
||
|
|
flowchart TB
|
||
|
|
START((输入)) --> CTX["Context 管理"]
|
||
|
|
CTX --> LLM["LLM 流式输出"]
|
||
|
|
LLM --> TC{"tool_use?"}
|
||
|
|
|
||
|
|
TC --> |是| EXEC["执行工具"]
|
||
|
|
EXEC --> CTX
|
||
|
|
|
||
|
|
TC --> |否| DONE((完成))
|
||
|
|
|
||
|
|
classDef proc fill:#eef,stroke:#66c,color:#224
|
||
|
|
classDef decision fill:#fee,stroke:#c66,color:#422
|
||
|
|
classDef io fill:#eff,stroke:#6cc,color:#244
|
||
|
|
|
||
|
|
class CTX,LLM,EXEC proc
|
||
|
|
class TC decision
|
||
|
|
class START,DONE io
|
||
|
|
```
|