10.1 · The choice matrix
| Framework | Best at | One real-world example |
|---|---|---|
| LangChain | Chains, integrations, RAG | "Chat with my PDFs" in 50 lines using built-in loaders + retrievers. |
| LangGraph | Stateful, controllable graph agents | Customer-support agent that plans, calls tools, escalates to a human node when confidence drops. |
| CrewAI | Role-based multi-agent teams | A blog crew: Researcher + Writer + Editor produce a finished post. |
| AutoGen | Conversational multi-agent + code exec | Two agents collaborate to debug a Python script, one writing code, one executing & reading errors. |
| LlamaIndex | Data ingestion + RAG over docs | Indexing 100k internal SharePoint files with metadata and serving them to an agent. |
| Claude Agent SDK | Claude-native agents, MCP, filesystem | Building a coding agent like Claude Code itself, with sub-agents and hooks. |
| OpenAI Agents SDK | OpenAI-native handoffs + tool calls | A travel agent that hands off between triage / flights / hotels specialists. |
| PydanticAI / DSPy | Type-safe, declarative pipelines | A schema-strict extraction pipeline where every model output is validated by Pydantic. |
10.2 · LangChain — the ubiquitous one
The original "everything in one box" library. Chains, document loaders, retrievers, LLM wrappers, evaluators. Excellent for linear pipelines and prototypes.
chain = (
{"context": retriever | format_docs, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
chain.invoke("how do I reset my password?")
Strengths: huge ecosystem, integrations to almost every vector DB, model, and tool. Weakness: when agents need real state machines, the abstraction gets thin — which is why the same team built LangGraph.
10.3 · LangGraph — agents as graphs
An agent is a graph of nodes (functions or sub-agents) and edges (transitions, possibly conditional). State flows through the graph. This is how Claude Code, many enterprise agents, and most serious LangChain users build production agents today.
graph = StateGraph(AgentState)
graph.add_node("plan", plan_node)
graph.add_node("execute", execute_node)
graph.add_node("review", review_node)
graph.add_edge("plan", "execute")
graph.add_conditional_edges("execute", needs_review,
{"yes": "review", "no": END})
graph.add_edge("review", "execute")
agent = graph.compile()
Why it wins for production:
- Explicit state — easy to inspect and persist.
- Cycles allowed — supports plan/execute/reflect loops.
- Streaming + checkpoints — pause and resume long runs.
- Human-in-the-loop is a first-class node type.
10.4 · CrewAI — agents with job titles
Define agents as roles with goals, backstories, and tools. A "crew" runs tasks in sequence or hierarchy. Great for the "team of specialists" pattern: a researcher, a writer, a critic, a publisher.
researcher = Agent(role="Senior Researcher", goal="Find recent AI papers", tools=[search])
writer = Agent(role="Tech Writer", goal="Summarise to a blog post")
crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task])
crew.kickoff()
Crews shine when the problem decomposes naturally into specialists. They struggle when one specialist's output is hard to predict — coordination overhead can dominate.
10.5 · AutoGen — a conversation between agents
Microsoft Research's framework treats every agent as a conversational participant. Users define roles and let agents chat until they reach consensus. Built-in patterns for code execution sandboxes.
Strength: novel debate / collaboration patterns. Weakness: less polished for production observability.
10.6 · LlamaIndex — data first
LlamaIndex began as the best library for ingesting and indexing data for RAG. It now has agentic features ("query engines as tools"). Pick LlamaIndex when your hardest problem is data — diverse sources, complex schemas, multi-tenant.
10.7 · Claude Agent SDK & OpenAI Agents SDK
Claude Agent SDK
Build agents that work like Claude Code. First-class file system, code execution, MCP, sub-agents, hooks, and human-in-the-loop. Best when you want Claude's full agentic posture in your own product.
OpenAI Agents SDK
A small, opinionated SDK for tool-using agents with "handoffs" between specialists, guardrails, and tracing. Clean defaults, minimal cognitive load.
10.8 · PydanticAI & DSPy — the "compiler" school
- PydanticAI: define agent inputs/outputs as Pydantic models; the runtime validates, retries, and types everything. Beloved by FastAPI users.
- DSPy: treat prompts as code modules; optimise them automatically with metric-driven compilation. Promising for teams that want reproducible prompt engineering.
10.9 · A decision rule that works
- Just calling an LLM with structure → no framework. Direct API + Pydantic.
- One agent, a handful of tools → OpenAI Agents SDK or Claude Agent SDK.
- Stateful, branching, long-running → LangGraph.
- Many specialists with different roles → CrewAI.
- Hardest problem is data ingestion → LlamaIndex.
- Research / debate-style agents → AutoGen.