Building Effective Agents
後設資料
- URL:https://www.anthropic.com/engineering/building-effective-agents
- 作者:Erik S.、Barry Zhang(Anthropic Applied AI 團隊)
- 發表日:2024-12-19
- 語言:英文
- 媒體:Anthropic Engineering blog
一句話濃縮
把「agentic system」分為 workflows(LLM + tools 走預定義 code path)與 Agent(LLM 動態決定流程與工具使用);列出 5 個常見 workflow pattern 與設計 agent 的核心原則:簡潔、透明、好的 ACI。
提取要點
- 核心區別:workflow 走預定義 code path;Agent 動態自主決定流程。
- 「最簡解優先」原則:agentic 系統用延遲與成本換取能力,只在必要時才增加複雜度。Workflow 適合定義良好的任務;agent 適合需要彈性、需要 model 自主決策的情境。
- 建議的 framework:Claude Agent SDK、Strands Agents SDK(AWS)、Rivet(drag-and-drop GUI)、Vellum(workflow GUI)。但作者建議先直接用 LLM API——框架會增加抽象層、隱藏實際邏輯、增加除錯難度。
三大成功原則
- 維持簡潔(simplicity)
- 透過明確規劃步驟提升透明度(transparency)
- 透過完善的工具文件與測試打造好的 Agent-Computer-Interface(ACI)
基礎元件:Augmented-LLM
agentic 系統的基礎——附加了檢索 / 工具 / 記憶的 LLM。第三方工具整合可用 Model Context Protocol(MCP)。
5 個 Workflow Pattern
- Prompt-Chaining — 把任務拆成依序執行的步驟,每個 LLM 呼叫處理上一步輸出;中間可加程式化「閘門」做驗證
- Routing — 把輸入分類後導向專門化的後續任務(不同模型、不同 prompt)
- Parallelization — 兩種變形:sectioning(拆成獨立子任務並行)/ voting(同任務多次跑取多樣輸出)
- Orchestrator-Workers — 中央 LLM 拆解任務、委派給 worker LLMs、合成結果。子任務動態決定(與 parallelization 的差異)
- Evaluator-Optimizer — 一個 LLM 生成回應、另一個提供評估與回饋;迭代精煉
Agents
當問題開放、步驟不可預測、無法 hardcode 路徑時用 agent。需要對 model 決策的信任、需要環境的 ground-truth feedback、需要在 checkpoint 暫停。範例:解 SWE-bench coding 任務、computer use 自動化。
Agents in Practice(兩個成功領域)
- 客戶支援:對話 + 工具整合(客戶資料、訂單、退款、ticket 更新);成果可由使用者定義的「resolutions」量化。
- Coding agents:解可被自動測試驗證的問題;有迭代回饋;問題空間定義清楚;有客觀品質量度。當前能力涵蓋從 PR 描述解決真實 GitHub issue。
工具的 Prompt Engineering(為 ACI 做準備)
格式建議:
- 為「執行前的 reasoning」分配 token 空間
- 格式接近自然出現在網路文本的形式
- 消除格式 overhead(行號、字串轉義)
設計指引:
- 包含使用範例、邊界案例、格式要求、與其他工具的界線
- 參數名與描述清楚
- 用多樣輸入廣泛測試
- poka-yoke(防呆)原則——例如要求絕對路徑而非相對路徑
關鍵句
“Success in the LLM space isn’t about building the most sophisticated system. It’s about building the right system for your needs.”
提取概念
- Anthropic — 文章發行方
- Agent — 動態決定流程的 agentic 系統
- Augmented-LLM — agentic 系統的基礎元件
- Agent-Computer-Interface(ACI)
- Prompt-Chaining / Routing / Parallelization / Orchestrator-Workers / Evaluator-Optimizer — 5 個 workflow pattern
- 更新:Context-Engineering——agent 與 workflow 的每一步都需要 context engineering
原文(可選)
Ingest 時透過 WebFetch 工具讀取,工具回傳的是被小型模型摘要過的內容、非 verbatim 原文。長期保存如有需要,可再次以瀏覽器抓取原始文章並貼回此區段。原始 URL 見上方。