Agent Loop

Agent 的主循环基本都是一致的:

Agent Loop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
research_log = []
status = "Searching"

while status != "Complete":
# 1. Decide next action based on current progress
action = llm.plan_next(user_goal, research_log)

# 2. Execute tool
results = tools.execute(action.query)

# 3. Critique and Store
is_valuable = llm.critique(results)
if is_valuable:
research_log.append(results)

# 4. Check if the task is done
if llm.check_stop_condition(research_log):
status = "Complete"

return llm.generate_report(research_log)

Agent Design

所有 Agent 的设计都包含四个部分:

  • Planning
  • Memory
  • Tool Use
  • Interaction

这里注意的是,Agent 的本质是围绕 LLM 搭建的 System (即刚刚提到的 Memory + Planning + Tools + Interaction 的 entity),而不是 LLM 本质.

一些 Agent 的例子

  • Deep Research Agent

Deep Research 的核心在于 Information Retrieval -> Summarization -> Generation

基于这个思路,我们可以这样设计 Agent 的四个部分:

  • Planning
  • Memory
    • 跟踪上下文和用户需求(e.g. latency vs memory)
    • 总结并分析现有文档
  • Tool Use
    • Web Search via ArXiv
    • Read and Extract Key Insights
  • Interaction
    • User <-> Agents <-> LLM <-> Tools
    • sub-Agent 1 <-> sub-Agent 2