Agent Frameworks
Agent Framework は、prompt、tool、memory、control flow、observation、retry、safety を 抽象化して再利用しやすくする library / SDK です。Agent system を production に乗せる際には、何かしらの framework を使うのが一般的です。
主要 framework
| Framework | 焦点 |
|---|---|
| LangGraph | 明示的なグラフで agent flow を定義 |
| AutoGen | Conversable agents と multi-agent chat |
| CrewAI | Role-based crew、task delegation |
| OpenAI Agents SDK | Lightweight primitives: agents、handoffs、guardrails |
| LlamaIndex Agent | RAG / index と統合した agent |
| Haystack | Production NLP pipeline |
LangGraph
LangGraph は、agent の流れを node と edge のグラフ で記述します。
- 明示的な state machine として書ける
- Checkpoint / persistence
- Human-in-the-loop
- Multi-agent をグラフで表現
AutoGen
AutoGen は 会話する agent (conversable agent) を基本単位とし、agent 同士の対話で task を解きます。Code execution、tool、group chat、teachability を含む豊富な abstraction を持ちます。
CrewAI
CrewAI は role-based。Crew (agent の集合) と task の delegation を中心に、軽量に multi-agent を構築できます。
OpenAI Agents SDK
OpenAI Agents SDK は、
- Agents: instructions + tools + model
- Handoffs: agent 間の制御移譲
- Guardrails: 入出力 validation
- Tracing: 自動 trace
という小さな primitive で agent を構築します。Multi-provider 対応で、シンプルさを重視。
選び方の目安
| 状況 | 推奨 |
|---|---|
| 明示的 control flow、production stability | LangGraph |
| Multi-agent dialogue / collaboration | AutoGen |
| Role 分担を直感的に | CrewAI |
| シンプルで provider 横断 | OpenAI Agents SDK |
| RAG-heavy | LlamaIndex |
| 既存 NLP pipeline 統合 | Haystack |
Framework に依存しすぎない
Anthropic の "Building Effective Agents" では、
- 多くの場合 直接 LLM API を呼ぶだけで十分
- Framework は debugging を難しくすることがある
- まずシンプルに、必要に応じて framework を導入
と推奨されています。
数式で見る workflow graph
Agent framework は、LLM call、tool call、retrieval、human approval などの node を持つ workflow graph として整理できます。Node 集合を 、edge 集合を とすると、状態 は前段 node の出力に依存します。
この式の気持ちは、「agent application は一つの巨大な prompt ではなく、複数の処理 node が依存関係を持ってつながった計算グラフである」ということです。
Router を持つ framework では、次に実行する node を policy で選びます。
この設計では、正しい node を選ぶ routing 精度と、各 node の出力品質の両方が全体性能を決めます。
関連ページ
主なソース
- LangGraph: https://langchain-ai.github.io/langgraph/
- AutoGen: https://microsoft.github.io/autogen/
- CrewAI: https://docs.crewai.com/
- OpenAI Agents SDK: https://openai.github.io/openai-agents-python/
- Anthropic Building Effective Agents: https://www.anthropic.com/research/building-effective-agents