An agent framework handles the plumbing of AI agents: the tool-calling loop, memory and state, multi-agent coordination, retries, human approval and tracing. This guide compares the most-used options so you can pick one.
What You Will Learn
- What a framework adds over a plain loop
- LangGraph, CrewAI, OpenAI Agents SDK, Claude Agent SDK, Google ADK, Microsoft Agent Framework, LlamaIndex
- Code examples in two styles
- How to choose
Prerequisites
Do You Need a Framework?
A single agent with 3–5 tools is often fine as a simple loop (see function calling). Frameworks pay off when you need long-running state, several cooperating agents, human-in-the-loop checkpoints, streaming and observability.
The Main Options
| Framework | Style | Best for |
|---|---|---|
| LangGraph | Agents as graphs of nodes with saved state (checkpoints) | Production workflows needing control, durability and human approval |
| CrewAI | Role-based “crews” of agents with tasks | Fast multi-agent prototypes that map to team roles |
| OpenAI Agents SDK | Small set of primitives: agents, tools, handoffs, guardrails | Lightweight tool-using agents, especially on OpenAI models |
| Claude Agent SDK | The agent loop behind Claude Code: files, shell, tools | Coding and file-manipulation agents |
| Google ADK | Agent Development Kit with multi-agent support | Gemini and Google Cloud projects |
| Microsoft Agent Framework | Successor to AutoGen and Semantic Kernel; Python and .NET | Azure / Microsoft enterprise stacks |
| LlamaIndex Workflows | Event-driven workflows around data | RAG-heavy, document agents – see LlamaIndex |
| Pydantic AI, smolagents, Mastra (TypeScript) | Minimal, typed or code-first agents | Developers who want little abstraction |
Example: CrewAI (Role-Based)
from crewai import Agent, Task, Crew
researcher = Agent(role="Researcher", goal="Find facts about a topic",
backstory="Careful analyst who cites sources")
writer = Agent(role="Writer", goal="Write a clear 200-word summary",
backstory="Technical writer for beginners")
t1 = Task(description="Research: what is RAG?", expected_output="5 bullet facts", agent=researcher)
t2 = Task(description="Write a summary from the facts", expected_output="200-word text", agent=writer)
print(Crew(agents=[researcher, writer], tasks=[t1, t2]).kickoff())
Example: LangGraph (Graph-Based)
from langgraph.prebuilt import create_react_agent
def get_fee(course: str) -> str:
"""Fee for a course."""
return {"python": "₹8,000"}.get(course.lower(), "unknown")
agent = create_react_agent("openai:gpt-4.1-mini", tools=[get_fee])
result = agent.invoke({"messages": [{"role": "user", "content": "Python course fee?"}]})
print(result["messages"][-1].content)
Explanation: CrewAI describes who does what; LangGraph describes how state flows between steps. For custom flows in LangGraph you define a StateGraph with nodes, edges and conditional routing, and add a checkpointer for memory and pause/resume.
How to Choose
| If you… | Consider |
|---|---|
| Need reliable long-running workflows with approvals | LangGraph |
| Want a multi-agent demo today | CrewAI |
| Mostly use OpenAI models and want minimal code | OpenAI Agents SDK |
| Build coding or file-automation agents | Claude Agent SDK |
| Are on Google Cloud / Azure | Google ADK / Microsoft Agent Framework |
| Have document-heavy RAG agents | LlamaIndex |
Series
Generative AI series: Intro to GenAI · LLM Fundamentals · Tokenization · Embeddings · Prompt Engineering · RAG · Vector DBs · Function Calling · AI Agents · Agent Frameworks · MCP · Hallucinations · Run LLMs Locally · Diffusion Models
Interview Questions
Q: What does an agent framework provide?
The agent loop, tool integration, state/memory, multi-agent orchestration, error handling, human-in-the-loop and observability.
Q: LangGraph vs CrewAI?
LangGraph gives explicit graph-based control and durable state; CrewAI offers a quicker role-and-task abstraction.
Practice Exercises
- Build the same two-step research-and-write task in CrewAI and LangGraph and compare the code.
- Add a human-approval step before an agent sends an email.
Summary
Pick LangGraph for controlled production workflows, CrewAI for quick role-based crews, vendor SDKs for lightweight agents on their models, and use MCP plus tracing everywhere.
Next: AI Agents · LLM Hallucinations & Risks
Machine Learning Tutorials, Courses and Certifications