「有 LLM 就是 agent」是常見的誤解。實際上 agentic system 可以依自主性、工具使用、動態規劃分成五層,從最簡單的單次呼叫,到生產級的控制平面。這篇主要照 Anthropic 的 Building Effective Agents(Dec 2024),再對一下 OpenAI 和幾篇 arXiv 研究,整理成這五層加一張選型決策樹。
5 級 Agent 架構金字塔
| Level | 核心特徵 | 代表 |
|---|---|---|
| L1 Augmented LLM | 單次呼叫 + 工具/RAG | ChatGPT 網頁版 / RAG QA |
| L2 Workflows | 預定義路徑 orchestration | Prompt Chaining / Routing |
| L3 Autonomous Agents | 動態規劃 + 環境回饋 | Claude Code / SWE-bench |
| L4 Multi-Agent | 角色分工 + Agent 通訊 | AutoGen / LangGraph Multi-Agent |
| L5 Agent Harness | 控制平面 + 驗證 + 審計 | OpenAI Codex Harness / Azure SRE |
決策原則(Anthropic):「用最簡單能解決問題的最低 level」。 L3 以上引入動態規劃 → 系統變得不可預測 → debug、成本、安全代價都跟著升,不要為了 buzzword 升級。
L2 vs L3 的分界線:有沒有 LLM 動態決定下一步。
Level 1: Augmented LLM(增強型語言模型)
Anthropic 定義:“The basic building block of agentic systems is an LLM enhanced with augmentations such as retrieval, tools, and memory”
特徵
| 特徵 | 說明 |
|---|---|
| 核心能力 | 單次 LLM 呼叫 + 檢索/工具/記憶 |
| 無 | 無自主規劃、無多步執行 |
| 適用 | 簡單問答、資訊檢索 |
程式碼範例
# Level 1: 單次呼叫
response = llm.chat(
messages=[{"role": "user", "content": question}],
tools=[search_tool]
)
例子
- ChatGPT 網頁版問問題
- RAG 問答系統
- 單一工具調用
Level 2: Workflows(工作流)
Anthropic 定義:“Workflows are systems where LLMs and tools are orchestrated through predefined code paths”
五種標準模式(Anthropic + LangChain 共識)
| 模式 | 圖示 | 適用場景 |
|---|---|---|
| Prompt Chaining | A → B → C | 任務可分解為固定子任務 |
| Routing | Input → Classifier → Specialist | 不同類型需要不同處理 |
| Parallelization | A → [B₁, B₂, B₃] → Aggregate | 需要多視角或速度 |
| Orchestrator-Workers | Orchestrator → [Dynamic Workers] → Synthesize | 複雜任務,子任務不可預測 |
| Evaluator-Optimizer | Generator ↔ Evaluator (loop) | 有明確評估標準的迭代任務 |
程式碼範例
# Level 2: Workflow(預定義路徑)
def workflow(input):
step1 = llm_call(prompt_a, input)
if check(step1): # 門禁
step2 = llm_call(prompt_b, step1)
return step2
例子
- 行銷文案生成 → 翻譯
- 大綱檢查 → 文件撰寫
- 客服路由(一般問題/退款/技術支援)
Level 3: Autonomous Agents(自主智能體)
Anthropic 定義:“Agents are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks”
關鍵特徵
Anthropic、OpenAI 和幾篇 arXiv 研究對這層的描述大致一致:模型自己動態規劃、自己選工具,從環境拿回饋(Anthropic 講的 “ground truth from environment”),多輪執行(“many turns”)直到滿足停止條件。
程式碼範例
# Level 3: Agent Loop
def agent_loop(task):
while not is_complete():
thought = llm.think(context)
action = llm.select_tool(thought)
result = execute(action) # 環境回饋
context.append((action, result))
return context.final_answer
例子
- Claude Code:單一自主 agent + 檔案/terminal 工具
- SWE-bench 解題 agent:Anthropic 實作
- Computer Use:Claude 操作電腦
- Cursor Copilot:IDE 整合 agent
Level 4: Multi-Agent Systems(多智能體系統)
arXiv 2604.18071 定義:分析 70 個專案後,識別出 “subagent architecture” 為五個核心設計維度之一。
關鍵特徵
| 特徵 | 說明 |
|---|---|
| 角色分工 | Planner / Coder / Reviewer / Tester |
| Agent 間通訊 | Agent A 輸出 → Agent B 輸入 |
| 任務分配 | Router / Orchestrator 決定誰做什麼 |
| 狀態共享 | Shared memory / Blackboard |
架構模式(arXiv 發現)
- Hierarchical(層級式):Manager → Workers
- Peer-to-Peer(平等式):Agents 互相協商
- Blackboard(黑板式):共享工作區
程式碼範例
# Level 4: Multi-Agent
def multi_agent_system(task):
plan = planner_agent(task)
for subtask in plan:
code = coder_agent(subtask)
review = reviewer_agent(code)
if review.approved:
test = tester_agent(code)
例子
- AutoGen:多 agent 對話協作
- LangGraph Multi-Agent:有狀態的多 agent workflow
- Claude Code + Subagents:主 agent spawn 子 agent
Level 5: Agent Harness(控制平面)
OpenAI 定義:“Harness engineering is the discipline of designing the scaffolding (context delivery, tool interfaces, planning artifacts, verification loops, memory systems, and sandboxes) that surrounds an AI agent”
五個核心設計維度(arXiv 2604.18071)
- Subagent architecture
- Context management
- Tool systems
- Safety mechanisms
- Orchestration
關鍵特徵
OpenAI、Anthropic、arXiv 對 harness 的共識大概是這幾件事:一個 control plane、會機械性強制執行的 policy gates(“mechanical enforcement”)、驗證迴圈、context 管理(OpenAI 強調的 “repository knowledge”)、可觀測性與審計,以及權限系統。
OpenAI 實作關鍵洞察
- “Humans steer. Agents execute.”
- “No manually-written code”:所有程式碼由 agent 生成
- “Repository knowledge is the system of record”:知識庫存在 repo,不是放 Google Docs / Slack
- “Agent legibility is the goal”:優化目標是讓 agent 看得懂
例子
- OpenAI Codex Harness:百萬行 agent 生成程式碼的生產系統
- SafeHarness(arXiv 2604.13630):生命週期整合安全架構
- Microsoft Azure SRE Agent:處理 35,000+ production incidents
架構決策樹
你的需求是什麼?
│
├─ 簡單問答 / 資訊檢索? ── 是 ──→ L1: Augmented LLM
│ (來源:Anthropic)
└─ 否
│
├─ 任務可預先分解? ── 是 ──→ L2: Workflows
│ (來源:Anthropic, LangChain)
└─ 否
│
└─ 需要靈活性 / 自主性? ── 是
│
└─ 任務太複雜需分工?
│
├─ 否 ──→ L3: Autonomous Agents
│ (來源:Anthropic, OpenAI, arXiv)
└─ 是 ── 需要生產級可控性?
│
├─ 否 ──→ L4: Multi-Agent Systems
│ (來源:arXiv 2604.18071)
└─ 是 ──→ L5: Agent Harness
(來源:OpenAI, arXiv, Anthropic)
具體例子對照表
| 使用場景 | Level | 來源依據 |
|---|---|---|
| ChatGPT 網頁版問問題 | L1 | Anthropic 定義 |
| RAG 問答系統 | L1 | Anthropic “Augmented LLM” |
| Claude Code | L3 | Anthropic “Autonomous Agent” |
| Claude Code + Subagent | L4 | arXiv “Subagent Architecture” |
| OpenAI Codex 生產系統 | L5 | OpenAI “Harness Engineering” |
| Microsoft Azure SRE Agent | L5 | arXiv + Microsoft Tech Community |
常見誤區
不算 Multi-Agent(L4)的情況
| 情況 | 為什麼不算 |
|---|---|
| Chain of Thought | 同一個 agent 在思考,無分工 |
| 單純 Tool Calling | 同一個 agent 在調用工具 |
| 單純 Handoff | 客服轉接,無協作 |
算 Multi-Agent 的條件
- 有角色分工(planner、coder、reviewer、tester)
- 有 Agent 間通訊(agent A 輸出 → agent B 輸入)
- 有任務分配機制(router / orchestrator 決定誰做什麼)
- 有狀態共享(shared memory / blackboard)
參考文獻
| # | 來源 | 機構 | 日期 | 研究方法 |
|---|---|---|---|---|
| 1 | Building Effective Agents | Anthropic | Dec 2024 | 與數十個團隊合作的實證觀察 |
| 2 | Harness Engineering | OpenAI | Feb 2026 | 從 0 開始用 Codex 建構百萬行程式碼的實驗 |
| 3 | Architectural Design Decisions in AI Agent Harnesses | arXiv | Apr 2026 | 分析 70 個公開 agent 系統的實證研究 |
| 4 | Building Effective AI Coding Agents for the Terminal | arXiv | Mar 2026 | OPENDEV 實作經驗 |
| 5 | The Anatomy of an Agent Harness | LangChain | 2026 | 框架設計者視角 |