vault backup: 2026-06-09 23:15:17

This commit is contained in:
2026-06-09 23:15:17 +08:00
parent 31fd89aafe
commit e92c0327d9
111 changed files with 7276 additions and 8846 deletions
+23 -6
View File
@@ -1,12 +1,25 @@
---
tags: [agent-loop, mermaid, claude-code, 流程图]
create time: 2026-06-09 22:30
---
# Agent Loop 完整流程
## 概述
Claude Code Agent 的完整执行循环,包含 Context 管理、Pre/Post-sampling Hook、权限审批、工具并发执行、子 Agent 递归调用、Stop Hook 和 Token Budget 控制等全部环节。
## 正文
```mermaid
flowchart TB
START((输入)) --> CTX["Context 管理"]
START(("输入")) --> CTX["Context 管理"]
CTX --> PRE["Pre-sampling Hook"]
PRE --> LLM["LLM 流式输出"]
LLM --> TC{tool_use?}
LLM --> TC{"tool_use?"}
TC --> |是| PERM{需权限?}
PERM --> |是| USER["👤 用户审批"]
TC --> |是| PERM{"需权限?"}
PERM --> |是| USER["用户审批"]
USER --> |allow| TOOL_PRE
USER --> |deny| DENIED["拒绝"]
PERM --> |否| TOOL_PRE["Pre-tool Hook"]
@@ -20,7 +33,7 @@ flowchart TB
STOP --> |不通过| CTX
STOP --> |通过| BUDGET{"Token Budget"}
BUDGET --> |继续| CTX
BUDGET --> |完成| DONE((完成))
BUDGET --> |完成| DONE(("完成"))
subgraph SUB["子 Agent"]
FORK["AgentTool"] --> RECURSE["递归调用"]
@@ -39,4 +52,8 @@ flowchart TB
class PRE,TOOL_PRE,TOOL_POST,POST hook
class START,DONE,USER,DENIED io
class FORK,RECURSE sub
```
```
## 关联笔记
- [[agent-loop-simple]] - Agent Loop 简易流程