← 返回首頁

如何建立一個協作的 AI Agent 團隊(完整課程)

Khairallah AL-Awady
Khairallah AL-Awady
@eng_khairallah1
𝕏 (Twitter)🔥
AI 中文摘要Claude 生成

如何建立一個協作的 AI Agent 團隊(完整課程)

一個 Agent 很有用。但一個 Agent 團隊則是競爭優勢。

先存起來 :)

單一的 AI Agent 可以進行研究、寫作、分析或撰寫程式碼。但它無法同時把這些事情都做好。就像一個試圖同時處理研究、寫作、銷售和客戶支援的員工,每一項工作都會做得差強人意。

解決方案與人類幾個世紀前發現的方法相同:專業化。

與其使用一個負載過重的 Agent,不如建立一個團隊。一個只負責研究的研究 Agent。一個只負責寫作的寫作 Agent。一個只負責分析的分析 Agent。還有一個負責管理團隊、分配任務並整合最終產出的協調 Agent。

每個 Agent 都非常專注。每個 Agent 在其特定工作上都表現卓越。它們共同產出的成果,是任何單一 Agent 都無法比擬的。

這就是所謂的「多 Agent 協調 (multi-agent orchestration)」,這也是目前最強大的 AI 系統背後的架構。客戶支援平台、研究系統、內容引擎和業務自動化流程,其核心都使用了多 Agent 團隊。

本課程將教你如何設計、建構並部署你自己的團隊。

架構:中心輻射式 (Hub and Spoke)

每個有效的多 Agent 系統都遵循相同的基本模式:中心輻射式 (hub and spoke)。

中心(協調 Agent)位於核心位置。它從使用者那裡接收總體目標。它將目標分解為子任務。它決定由哪個專業 Agent 處理每個子任務。它在專業 Agent 之間傳遞 context。它將所有片段組裝成最終產出。

輻射(專業 Agent)是專注的專家。每個 Agent 都有明確的角色、一組針對該角色優化的工具,以及一個將其限制在專業領域內的系統 Prompt。

所有溝通都透過協調 Agent 進行。專業 Agent 之間從不直接對話。協調 Agent 是路由、品質控制和組裝的單一節點。

這種架構具有巨大的優勢。每個專業 Agent 都能保持專注,減少因 context 過載而導致的錯誤。專業 Agent 可以獨立開發和測試。你可以在不重建系統的情況下替換或升級個別的專業 Agent。協調 Agent 為除錯和監控提供了單一的可觀測性節點。

每個人都會犯的致命錯誤

我必須強調這一點,因為這是多 Agent 系統中最常見的錯誤。

專業 Agent 不會自動繼承協調 Agent 的對話歷史。

讓我說得更直接一點。當協調 Agent 產生一個專業 Agent 時,該專業 Agent 是從空白的 context 開始的。它什麼都不知道。它沒有讀過對話歷史。它沒有看過其他專業 Agent 產出了什麼。除了你在其 Prompt 中明確包含的內容外,它對任何事情都一無所知。

大多數人認為,因為協調 Agent 知道一切,所以專業 Agent 也一定知道一切。事實並非如此。如果協調 Agent 收集了研究資料,並希望寫作專業 Agent 將其轉化為報告,協調 Agent 必須在寫作專業 Agent 的 Prompt 中包含所有研究資料。如果它只是說「根據我們的研究寫報告」,寫作專業 Agent 根本不知道做了什麼研究。

# 錯誤 — 專業 Agent 沒有 context
writer_prompt = "Write a market analysis report based on the research."

# 正確 — 所有 context 都明確傳遞
writer_prompt = f"""You are a professional report writer.

Write a market analysis report using the research findings below.

RESEARCH FINDINGS:
{research_data}

KEY STATISTICS:
{statistics}

COMPETITOR ANALYSIS:
{competitor_data}

FORMAT: Executive summary (3 sentences), then 5 sections with headers, 
each 2-3 paragraphs. Professional tone. Cite specific numbers from 
the research.

AUDIENCE: C-level executives who will read this in under 10 minutes.
"""

第二個版本比較長。但它也是唯一能運作的版本。專業 Agent 需要的每一項 context 都必須明確包含在內。沒有例外。

建構你的第一個多 Agent 團隊:研究與報告系統

讓我帶你建構一個完整的多 Agent 團隊。這個系統接收一個研究問題,並產出一份全面、撰寫精良且經過事實查核的報告。

團隊成員:

Agent 1:研究專家 (Research Specialist) - 搜尋資訊、提取關鍵事實並編譯原始研究資料。

Agent 2:分析專家 (Analyst Specialist) - 接收原始研究資料、識別模式、得出結論並找出來源之間的矛盾之處。

Agent 3:寫作專家 (Writer Specialist) - 接收分析後的資料,並以定義好的格式和語氣產出精煉、結構化的報告。

Agent 4:審閱專家 (Reviewer Specialist) - 閱讀完成的報告,對照原始研究檢查準確性,識別薄弱的論點並提出改進建議。

Agent 0:協調 Agent (Coordinator) - 管理整個工作流程。

協調 Agent 的工作流程:

Step 1: Receive the research question from the user.
Step 2: Decompose the question into 3-5 sub-questions that together 
        fully cover the topic.
Step 3: Send each sub-question to the Research Specialist.
Step 4: Compile all research findings.
Step 5: Send compiled findings to the Analyst Specialist.
Step 6: Send analysis + research to the Writer Specialist.
Step 7: Send the draft report + original research to the 
        Reviewer Specialist.
Step 8: If the Reviewer flags issues: send the flagged sections 
        back to the Writer for revision.
Step 9: Deliver the final report to the user.

每個專業 Agent 都有一個專注的系統 Prompt:

研究專家:

You are a research specialist. Your only job is to find accurate, 
current information on the topic you are given.

For each piece of information:
- Note the source
- Rate your confidence (high/medium/low)
- Flag if the information might be outdated

Return your findings as a structured list of facts with sources 
and confidence ratings. Do not analyze. Do not write prose. 
Just find and organize facts.

分析專家:

You are a data analyst. Your only job is to analyze research 
findings and extract insights.

Given raw research data:
- Identify the 3-5 most important patterns
- Note contradictions between sources
- Flag claims that lack sufficient evidence
- Draw conclusions supported by the data

Do not write a final report. Return structured analysis that a 
writer can turn into polished prose.

寫作專家:

You are a professional report writer. Your only job is to turn 
analyzed data into a polished, readable report.

Given analysis and supporting data:
- Write in clear, professional prose
- Structure with an executive summary followed by detailed sections
- Cite specific numbers and sources throughout
- Make the report scannable — a reader should grasp key points 
  in under 3 minutes

Do not perform new research. Do not change the conclusions from 
the analysis. Only write.

審閱專家:

You are a quality reviewer. Your only job is to check the 
finished report against the original research.

Check for:
- Claims in the report not supported by the research data
- Important findings from the research that the report omits
- Logical inconsistencies or weak reasoning
- Accuracy of all numbers and statistics
- Clarity and readability issues

For each issue found: quote the problem, explain what is wrong, 
and suggest a specific fix. If the report is solid, say so.

為什麼這個團隊產出的成果比單一 Agent 更好:

研究 Agent 深入挖掘資訊——它不會因為同時要寫報告而分心。分析 Agent 純粹專注於模式——而不是尋找資訊或撰寫文稿。寫作 Agent 純粹專注於優質的文稿——而不是進行研究或分析。審閱 Agent 抓出了寫作 Agent 遺漏的錯誤,因為審閱就是它的全部工作。

每個 Agent 都把一件事做好。協調 Agent 確保各個部分完美契合。其結果在品質上始終高於要求單一 Agent 完成所有工作。

設計你自己的多 Agent 團隊

研究與報告團隊只是一種配置。你可以為任何複雜的工作流程建構多 Agent 團隊。

內容團隊:

研究員 → 大綱架構師 → 草稿撰寫人 → 編輯 → 格式化人員

接收一個主題並產出精煉、多格式的內容。

客戶支援團隊:

分類員 → 知識庫搜尋員 → 回覆草擬員 → 品質檢查員

透過多層驗證處理支援工單。

商業分析團隊:

資料收集員 → 趨勢分析師 → 風險評估師 → 建議撰寫人

接收原始商業資料並產出可執行的策略建議。

設計原則始終相同:

每個 Agent 都有一個明確的責任。每個 Agent 擁有一組專注的工具(最多 3 到 5 個)。所有溝通都透過協調 Agent 進行。Context 在 Agent 之間明確傳遞——絕不預設。協調 Agent 在傳遞給下一個 Agent 之前,會在每個階段驗證產出。

三種失敗模式(以及如何預防)

失敗 1:分解過於狹隘。

協調 Agent 將「AI 對各行業的影響」僅分解為軟體和醫療保健子主題,完全忽略了金融、教育、製造、媒體和法律。

預防:指示協調 Agent 在分解之前列舉完整範圍。增加一個自我檢查步驟:「審查你的分解。你是否涵蓋了該主題的所有主要方面?如果遺漏了任何重要領域,請補充。」

失敗 2:Context 遺失。

研究 Agent 發現的資訊從未傳遞給寫作 Agent,因為協調 Agent 沒有將其傳遞下去。

預防:協調 Agent 必須在每個後續 Agent 的 Prompt 中包含所有先前的 Agent 產出。將明確的 context 傳遞機制建構到協調 Agent 的工作流程中。

失敗 3:透過「傳話遊戲」導致品質下降。

每個 Agent 都會微妙地改變或遺失前一個 Agent 產出的細微差別。當資訊經過四個 Agent 傳遞時,重要的細節已經被稀釋了。

預防:在每個階段都包含原始來源資料——而不僅僅是前一個 Agent 的產出。寫作 Agent 應該收到原始研究資料 AND 分析結果,而不僅僅是分析結果。

總結

單一 Agent 很有用。多 Agent 團隊則很強大。

架構很簡單:協調 Agent 管理專業 Agent,每個專業 Agent 把一件事做好,所有 context 明確傳遞,最後由協調 Agent 組裝最終產出。

本週就建構你的第一個團隊吧。從研究與報告配置開始。用一個真實的研究問題來測試它。觀察它的品質與要求單一 Agent 完成所有工作相比如何。

一旦你體驗到品質上的差異,你就再也不會回到處理複雜任務時使用單一 Agent 的工作流程了。

AI 的未來不是一個 Agent 完成所有事情。而是由 Agent 團隊將所有事情都做好。

追蹤我的帳號 @eng_khairallah1 以獲取更多 Agent 架構指南、協調模式和建構系統的資訊。

希望這對你有幫助,Khairallah ❤️