Фреймворки AI-агентов¶
~8 минут чтения
9 фреймворков: LangGraph, CrewAI, AutoGen, OpenAI Agents SDK, Pydantic AI, LlamaIndex, Semantic Kernel, Smolagents. Архитектура, код, production comparison (2025-2026)
Предварительно: LLM-агенты, Воркфлоу AI-агентов
Зачем это нужно¶
Выбор фреймворка определяет скорость разработки, production-readiness и стоимость эксплуатации агентной системы. LangGraph занимает 60% enterprise adoption, CrewAI -- 25%, AutoGen -- 15%. Token overhead между фреймворками отличается в 2 раза: LangGraph 1.0x baseline, CrewAI 1.2-1.5x, AutoGen 1.5-2.0x из-за conversation patterns. Неправильный выбор фреймворка для RAG-heavy задачи (например, LangGraph вместо LlamaIndex) может увеличить time-to-MVP с дней до недель. Smolagents (~1000 LOC) доказывает, что для простых агентов фреймворк можно написать за день.
Ключевые концепции¶
Ландшафт 2026¶
| Tier | Framework | Best For | Maturity | License |
|---|---|---|---|---|
| 1 | LangGraph | Production enterprise, complex workflows | High | Apache 2.0 |
| 1 | CrewAI | Rapid prototyping, role-based tasks | Medium-High | MIT |
| 1 | AutoGen | Microsoft ecosystem, research | Medium | MIT |
| 2 | OpenAI Agents SDK | OpenAI-native, simple agents | Medium | Proprietary |
| 2 | Pydantic AI | Type-safe, validated agents | Medium | MIT |
| 2 | LlamaIndex | RAG-centric agents | High | MIT |
| 2 | Semantic Kernel | Azure integration | High | MIT |
| 3 | Smolagents | Lightweight, educational | Low-Medium | Apache 2.0 |
2026 тренд: explicit state management (LangGraph) побеждает emergent multi-agent behavior. Enterprise adoption: LangGraph 60%, CrewAI 25%, AutoGen 15%.
Tier 1: Production Enterprise¶
1. LangGraph¶
Архитектура:
| Компонент | Описание |
|---|---|
| State | TypedDict определяет состояние агента |
| Nodes | Функции, обрабатывающие состояние |
| Edges | Условные переходы между узлами |
| Graph | Скомпилированный state machine |
| Checkpointer | Persistence для состояния |
Ключевые фичи:
| Feature | Описание |
|---|---|
| State machines | Explicit control flow |
| Persistence | Save/resume execution |
| Streaming | Real-time output |
| Human-in-the-loop | Interrupt for approval |
| Time travel | Rewind execution |
Код:
from langgraph.graph import StateGraph, END
from typing import TypedDict
class State(TypedDict):
messages: list
next_action: str
def agent_node(state: State) -> State:
# Process state
return {"messages": [...], "next_action": "..."}
graph = StateGraph(State)
graph.add_node("agent", agent_node)
graph.add_edge("agent", END)
app = graph.compile()
Best practices:
| Practice | Описание |
|---|---|
| Type your state | TypedDict for clarity |
| Keep nodes small | Single responsibility |
| Use checkpointing | Enable persistence |
| Test edges | Verify conditional logic |
| Log transitions | Debug state changes |
Best for: compliance workflows (audit trails), multi-step processing, production reliability, HITL.
Ограничения: steep learning curve, verbose for simple tasks, requires engineering expertise.
2. CrewAI¶
Архитектура:
| Компонент | Описание |
|---|---|
| Agents | Role-based entities с целями |
| Tasks | Конкретные задания для агентов |
| Crews | Команды агентов |
| Process | Sequential или hierarchical execution |
Ключевые фичи:
| Feature | Описание |
|---|---|
| Role definition | Natural language agent roles |
| Auto delegation | Агенты передают задачу, если застряли |
| Tool integration | Easy tool assignment |
| Memory | Short и long-term memory |
| Collaboration | Built-in multi-agent patterns |
Код:
from crewai import Agent, Task, Crew
researcher = Agent(
role="Researcher",
goal="Find relevant information",
tools=[search_tool]
)
writer = Agent(
role="Writer",
goal="Create content",
tools=[write_tool]
)
task = Task(description="Write about AI", agent=writer)
crew = Crew(agents=[researcher, writer], tasks=[task])
crew.kickoff()
Ключевой дифференциатор: automatic delegation -- когда агент застревает, он автоматически делегирует другому агенту в crew.
Best practices:
| Practice | Описание |
|---|---|
| Clear roles | Distinct agent responsibilities |
| Limit crew size | 2-5 агентов оптимально |
| Task dependencies | Explicit ordering |
| Monitor delegation | Watch handoff patterns |
Best for: rapid prototyping (hours to MVP), role-based tasks, content creation (writer-researcher pattern).
Ограничения: less control (emergent behavior harder to debug), less explicit state management, fewer enterprise integrations.
3. AutoGen (Microsoft)¶
Архитектура:
| Компонент | Описание |
|---|---|
| ConversableAgent | Base agent class |
| UserProxyAgent | Human-in-the-loop proxy |
| AssistantAgent | AI assistant |
| GroupChat | Multi-agent conversations |
Ключевые фичи:
| Feature | Описание |
|---|---|
| Conversation patterns | Agents talk to each other |
| Code execution | Built-in sandbox |
| Human proxy | Easy human integration |
| Research focus | Academic origins |
Код:
from autogen import AssistantAgent, UserProxyAgent
assistant = AssistantAgent("assistant", llm_config={...})
user_proxy = UserProxyAgent("user", code_execution_config={...})
user_proxy.initiate_chat(
assistant,
message="Help me build a web scraper"
)
Best practices:
| Practice | Описание |
|---|---|
| Limit turns | Prevent infinite loops |
| Use human proxy | Control critical decisions |
| Sandbox execution | Isolate code runs |
| Log conversations | Debug agent interactions |
Best for: Microsoft/Azure ecosystem, research, conversational agents, code generation.
Ограничения: conversation overhead (more tokens), less production-ready, complex setup.
Tier 2: Specialized¶
4. OpenAI Agents SDK¶
| Аспект | Детали |
|---|---|
| Developer | OpenAI |
| Focus | OpenAI-native agents |
| Languages | Python, JavaScript |
Архитектура:
+----------------------------------------------------------+
| OpenAI Agent |
+----------------------------------------------------------+
| Agent: name, instructions, model |
| | |
| +----------+ +----------+ +------------+ |
| | Tools | | Handoffs | | Guardrails | |
| |(Functions)| | (Agents) | |(Validators)| |
| +----------+ +----------+ +------------+ |
+----------------------------------------------------------+
Features: handoffs (agent-to-agent transfer), function calling, built-in tracing (observability), input/output guardrails.
Best for: OpenAI-only stacks, minimal boilerplate.
5. Pydantic AI¶
| Аспект | Детали |
|---|---|
| Developer | Pydantic Team |
| Focus | Type-safe validated agents |
| Key | Runtime validation через Pydantic models |
Код:
from pydantic_ai import Agent
from pydantic import BaseModel
class Result(BaseModel):
answer: str
confidence: float
agent = Agent(
model='openai:gpt-4',
result_type=Result,
)
@agent.tool
def search(query: str) -> str:
"""Search documentation."""
return docs.search(query)
result = agent.run("What is RAG?")
# result: Result(answer="...", confidence=0.95)
Strengths: type safety (runtime validation), structured output (Pydantic models), simple API (minimal boilerplate), IDE support.
Best for: safety-critical applications, validated structured output.
6. LlamaIndex Agents¶
| Аспект | Детали |
|---|---|
| Developer | LlamaIndex Inc. |
| Focus | RAG-first agent framework |
| Languages | Python, TypeScript |
Agent Types:
| Тип | Use Case |
|---|---|
| ReActAgent | General purpose (reasoning + acting) |
| QueryEngineAgent | Document Q&A (RAG-focused) |
| FnAgent | Function calling / tool integration |
| OpenAIAgent | GPT integration |
Архитектура:
+----------------------------------------------------------+
| LlamaIndex Agent |
+----------------------------------------------------------+
| Query Engine: vector store, knowledge graph, hybrid |
| | |
| Tool Registry: FunctionTool, QueryEngineTool, custom |
| | |
| LLM Provider: OpenAI, Anthropic, local models |
+----------------------------------------------------------+
LlamaIndex vs LangGraph для RAG:
| Feature | LlamaIndex | LangGraph |
|---|---|---|
| RAG setup | Best (easiest) | Manual |
| Workflow control | Limited | Best |
| Document processing | Best | Basic |
| Multi-agent | Basic | Good |
Best for: RAG-heavy applications, document Q&A.
7. Semantic Kernel (Microsoft)¶
| Аспект | Детали |
|---|---|
| Developer | Microsoft |
| Focus | Azure AI integration |
| Languages | C#, Python, Java |
Core Concepts:
| Concept | Описание |
|---|---|
| Skills | Reusable capabilities |
| Functions | Native (C#/Python) или semantic (prompts) |
| Planners | Auto-compose functions (Action/Sequential/Stepwise) |
| Connectors | AI service integration (Azure) |
| Memory | Volatile (in-process) и persistent (Azure AI Search) |
Архитектура:
+----------------------------------------------------------+
| Semantic Kernel |
+----------------------------------------------------------+
| Planner: Action | Sequential | Stepwise |
| | |
| +-------------+ +---------------+ +-----------+ |
| | Native Funcs| |Semantic Funcs | |Connectors | |
| | (C#/Python) | | (Prompts) | |(Azure/LLM)| |
| +-------------+ +---------------+ +-----------+ |
| | |
| Memory: Volatile | Persistent (Azure AI Search) |
+----------------------------------------------------------+
Best for: Azure/Microsoft stack, enterprise (multi-language C#/Python/Java), auto-compose workflows.
Tier 3: Lightweight¶
8. Smolagents (Hugging Face)¶
| Аспект | Детали |
|---|---|
| Developer | Hugging Face |
| Focus | Lightweight, educational |
| Size | ~1000 lines of code |
| Philosophy | "Build agents with minimal abstraction" |
Код:
from smolagents import CodeAgent, tool
@tool
def search(query: str) -> str:
"""Search the web."""
return web_search(query)
agent = CodeAgent(tools=[search], model="gpt-4")
result = agent.run("What's the weather in NYC?")
Компоненты: CodeAgent (generates and executes Python), Tool (simple function wrapper), Model (any LLM provider).
Best for: learning/education, simple agents, understanding internals.
Детали и сравнения¶
Production Comparison¶
Decision Matrix:
| Потребность | Рекомендация |
|---|---|
| Enterprise compliance | LangGraph |
| Speed to MVP | CrewAI |
| Microsoft/Azure stack | Semantic Kernel или AutoGen |
| RAG-heavy | LlamaIndex |
| Type safety | Pydantic AI |
| OpenAI-only | OpenAI Agents SDK |
| Learning/education | Smolagents |
| Multi-cloud | LangGraph |
Production Readiness:
| Framework | Stability | Scaling | Observability |
|---|---|---|---|
| LangGraph | High | High | Built-in |
| OpenAI SDK | High | High | OpenAI tools |
| LlamaIndex | High | High | Plugin |
| Semantic Kernel | High | High | Azure Monitor |
| CrewAI | Medium | Medium | Plugin |
| AutoGen | Medium | Medium | Limited |
| Pydantic AI | Medium | Medium | Limited |
| Smolagents | Low | Low | Manual |
Cost Considerations:
| Framework | Token Overhead | Cost Factor |
|---|---|---|
| LangGraph | Low | 1.0x (baseline) |
| CrewAI | Medium | 1.2-1.5x |
| AutoGen | High | 1.5-2.0x |
AutoGen дороже из-за conversation patterns -- агенты обмениваются сообщениями, каждый round-trip стоит токенов.
Feature Matrix¶
| Feature | LangGraph | CrewAI | AutoGen | LlamaIndex | Semantic Kernel | Pydantic AI | Smolagents |
|---|---|---|---|---|---|---|---|
| State management | Best | Basic | Basic | Basic | Good | Basic | None |
| RAG native | Manual | Plugin | Plugin | Best | Plugin | Plugin | None |
| Type safety | Good | Basic | Basic | Basic | Basic | Best | None |
| Multi-language | Python | Python | Python | Py+TS | C#/Py/Java | Python | Python |
| Enterprise | High | Medium | Medium | High | Best | Low | None |
| Learning curve | High | Low | Medium | Medium | High | Low | Lowest |
| HITL | Built-in | Limited | Built-in | Limited | Limited | None | None |
Selection Guide¶
По экосистеме:
| Ваш стек | Рекомендация |
|---|---|
| Azure + Microsoft | Semantic Kernel |
| OpenAI-only | OpenAI Agents SDK |
| RAG-heavy | LlamaIndex |
| Python type-safety | Pydantic AI |
| Learning/education | Smolagents |
| Multi-cloud | LangGraph |
По сложности:
| Сложность | Framework |
|---|---|
| Simple (1 agent) | Smolagents, OpenAI SDK |
| Medium (multi-agent) | CrewAI, Pydantic AI |
| Complex (workflows) | LangGraph, Semantic Kernel |
| RAG-heavy | LlamaIndex |
По размеру команды:
| Команда | Рекомендация |
|---|---|
| Solo developer | Smolagents, CrewAI |
| Small team | LangGraph, Pydantic AI |
| Enterprise | Semantic Kernel, LangGraph |
Code Complexity (lines)¶
| Task | LangGraph | CrewAI | Pydantic AI | Smolagents | LlamaIndex |
|---|---|---|---|---|---|
| Simple agent | 25 | 15 | 15 | 10 | 20 |
| RAG agent | 40 | 25 | 30 | 20 | 25 |
| Multi-agent | 60+ | 30 | 50 | 40 | 60 |
Для интервью¶
Q: "Какой agent framework выбрать для production?"¶
LangGraph для enterprise (explicit state management, HITL, checkpointing, audit trails). 60% enterprise adoption. Token overhead 1.0x (baseline). Tradeoff: steep learning curve, more code. Если нужен quick MVP -- CrewAI (hours to production, auto-delegation). Microsoft stack -- Semantic Kernel (C#/Python/Java, Azure native). RAG-heavy -- LlamaIndex (best document processing).
Q: "LangGraph vs CrewAI vs AutoGen?"¶
LangGraph: state machine (State/Nodes/Edges), explicit control, production-ready, 50K+ GitHub stars, latency 2-5s. CrewAI: role-based (Agents/Tasks/Crews), auto-delegation, rapid prototyping, 35K+ stars, latency 3-8s. AutoGen: conversation-based (ConversableAgent/GroupChat), Microsoft ecosystem, research-focused, 40K+ stars, latency 5-15s. Cost: LangGraph 1.0x, CrewAI 1.2-1.5x, AutoGen 1.5-2.0x (conversation overhead).
Q: "Что нового в agent frameworks 2026?"¶
Тренд: explicit state management побеждает emergent behavior. Новые фреймворки: OpenAI Agents SDK (handoffs, guardrails, tracing), Pydantic AI (type-safe agents с Pydantic validation), Smolagents (HuggingFace, ~1000 LOC, educational). LlamaIndex добавил agent types (ReAct, QueryEngine, FnAgent). Semantic Kernel -- multi-language (C#/Python/Java) с auto-compose planners.
Q: "Как снизить token overhead в multi-agent системах?"¶
AutoGen: 1.5-2.0x overhead (chat patterns). CrewAI: 1.2-1.5x. LangGraph: 1.0x (minimal). Стратегии: (1) explicit state management вместо conversation (LangGraph), (2) limit turns (AutoGen
max_consecutive_auto_reply), (3) structured output вместо free-text, (4) tool results вместо agent-to-agent chat, (5) smaller models для draft agents.
Q: "LlamaIndex vs LangGraph для RAG-агентов?"¶
LlamaIndex: best RAG setup (easiest), best document processing, QueryEngineAgent для document Q&A. LangGraph: best workflow control, better multi-agent, explicit state. Если RAG -- core задача: LlamaIndex. Если RAG -- часть complex workflow с HITL: LangGraph. Можно комбинировать: LlamaIndex для retrieval + LangGraph для orchestration.
Ключевые числа¶
| Факт | Значение |
|---|---|
| Enterprise adoption: LangGraph | 60% |
| Enterprise adoption: CrewAI | 25% |
| Enterprise adoption: AutoGen | 15% |
| GitHub stars: LangGraph | 50K+ |
| GitHub stars: AutoGen | 40K+ |
| GitHub stars: CrewAI | 35K+ |
| GitHub stars: LlamaIndex | 40K+ |
| Latency: LangGraph | 2-5s |
| Latency: CrewAI | 3-8s |
| Latency: AutoGen | 5-15s |
| Token overhead: LangGraph | 1.0x |
| Token overhead: CrewAI | 1.2-1.5x |
| Token overhead: AutoGen | 1.5-2.0x |
| CrewAI optimal crew size | 2-5 agents |
| Smolagents codebase size | ~1000 LOC |
| Semantic Kernel languages | C#, Python, Java |
Источники¶
- DataCamp -- "CrewAI vs LangGraph vs AutoGen: Choosing the Right Multi-Agent AI Framework"
- Latenode -- "LangGraph vs AutoGen vs CrewAI: Complete AI Agent Framework Comparison"
- Medium (Data Science Collective) -- "The Best AI Agent Frameworks for 2026: Tier List"
- brlikhon.engineer -- "Building Production Agentic AI Systems in 2026"
- Hugging Face -- "Smolagents: Build agents with minimal abstraction"
- Microsoft -- "Semantic Kernel Documentation"
- Pydantic -- "Pydantic AI Documentation"
- LlamaIndex -- "Building Agents with LlamaIndex"
- OpenAI -- "Agents SDK Documentation"
- Turing -- "Detailed Comparison of Top 6 AI Agent Frameworks"