The Agentic AI Codex
Ch 10 · Agent Frameworks
Chapter 10 · Tooling

Agent Frameworks — choose wisely

Frameworks compress months of plumbing into days. But each one carries opinions about how agents should think, how state should flow, and how teams should compose. This chapter compares the seven that actually matter and gives you a clear rule for when to pick each.

10.1 · The choice matrix

FrameworkBest atOne real-world example
LangChainChains, integrations, RAG"Chat with my PDFs" in 50 lines using built-in loaders + retrievers.
LangGraphStateful, controllable graph agentsCustomer-support agent that plans, calls tools, escalates to a human node when confidence drops.
CrewAIRole-based multi-agent teamsA blog crew: Researcher + Writer + Editor produce a finished post.
AutoGenConversational multi-agent + code execTwo agents collaborate to debug a Python script, one writing code, one executing & reading errors.
LlamaIndexData ingestion + RAG over docsIndexing 100k internal SharePoint files with metadata and serving them to an agent.
Claude Agent SDKClaude-native agents, MCP, filesystemBuilding a coding agent like Claude Code itself, with sub-agents and hooks.
OpenAI Agents SDKOpenAI-native handoffs + tool callsA travel agent that hands off between triage / flights / hotels specialists.
PydanticAI / DSPyType-safe, declarative pipelinesA 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

  1. Just calling an LLM with structure → no framework. Direct API + Pydantic.
  2. One agent, a handful of tools → OpenAI Agents SDK or Claude Agent SDK.
  3. Stateful, branching, long-running → LangGraph.
  4. Many specialists with different roles → CrewAI.
  5. Hardest problem is data ingestion → LlamaIndex.
  6. Research / debate-style agents → AutoGen.
Frameworks are not moats
Your business logic is. Code your nodes, tools, evaluators as plain functions so you can switch frameworks in a week if the field moves on.

10.10 · Self-check

Q1 · You need a long-running agent that plans, executes, and can be paused/resumed. Best choice?
LangChain Chains
LangGraph
DSPy
FAISS
Q2 · Your team wants role-based agents like "researcher", "editor", "fact-checker". Best fit?
LangChain
CrewAI
LlamaIndex
FAISS