Skip to content
LinkedInX

AI Agent Framework Comparison

Target audience: Beginner-to-intermediate developers who understand basic AI agent concepts and want to build an agent
Prerequisites: What Is an AI Agent?

An AI agent framework is a library or toolkit that streamlines the design and implementation of agents. Orchestration logic, tool management, and memory management that would require hundreds of lines to implement from scratch can be written concisely using the APIs that frameworks provide.

Why Use a Framework?

Building from Scratch vs. Using a Framework

Building an agent from scratch requires you to implement everything yourself:

  • The ReAct loop (managing the Reason → Act → Observe cycle)
  • Tool definitions, invocations, and error handling
  • Context management (length control, summarization)
  • Information passing between agents
  • Human-in-the-loop approval flows
  • Execution logs and debugging

Frameworks provide all of this out of the box, so developers can focus on task-specific logic.

AspectFrom ScratchUsing a Framework
FlexibilityMaximumWithin the framework’s scope
Development speedSlowFast
Learning costNo framework to learnMust learn the framework
MaintenanceSelf-managedFollow framework updates
Recommended whenStrong custom requirementsBuilding standard agents
This table scrolls horizontally. Keyboard users can focus the table and use the left and right arrow keys.

Representative Frameworks

1. LangGraph

LangGraph is a graph-based agent framework developed as part of the LangChain ecosystem. Its official documentation describes it as a foundation for long-running, stateful agents.[1]

# Python - Minimal LangGraph example (conceptual)
from langgraph.graph import StateGraph, END
from typing import TypedDict

class AgentState(TypedDict):
    messages: list
    next_step: str

# Define the graph
workflow = StateGraph(AgentState)

# Add nodes (processing steps)
workflow.add_node("reason", reason_node)     # Thinking step
workflow.add_node("tool_use", tool_node)     # Tool execution
workflow.add_node("observe", observe_node)   # Result observation

# Define edges (transitions)
workflow.add_edge("reason", "tool_use")
workflow.add_conditional_edges(
    "observe",
    should_continue,  # condition function
    {"continue": "reason", "finish": END}
)

# Compile and run the graph
app = workflow.compile()
result = app.invoke({"messages": [("user", "Please execute the research task")]})

StateGraph is a mechanism that manages workflow by type-defining the agent’s state and having each node update that state.[1] It’s well-suited for agents with complex conditional branching and state management.

Best suited for

  • Agents that require complex state management
  • Workflows with many conditional branches and loops
  • Cases where you’re already using the LangChain ecosystem

2. CrewAI

CrewAI is a framework that defines multiple agents as a “crew” and assigns each agent a role and goal. Its official documentation describes agents, crews, and flows as core concepts.[2]

# Python - Minimal CrewAI example (conceptual)
from crewai import Agent, Task, Crew

# Define agents (specify role, goal, and backstory)
researcher = Agent(
    role="Research Analyst",
    goal="Comprehensively research the latest EV market trends",
    backstory="An analyst with 10 years of market research experience who values data accuracy.",
    tools=[web_search_tool, data_analysis_tool],
    verbose=True
)

writer = Agent(
    role="Technical Writer",
    goal="Compile research findings into a clear report",
    backstory="A technical documentation expert skilled at communicating complex information clearly.",
    tools=[file_write_tool]
)

# Define tasks
research_task = Task(
    description="Collect and analyze the latest EV market data",
    agent=researcher,
    expected_output="Analysis report including market share, growth rate, and key players"
)

writing_task = Task(
    description="Create a readable report based on the research findings",
    agent=writer,
    expected_output="A market trends report of approximately 1,500 words",
    context=[research_task]  # Use results from research_task as input
)

# Assemble and run the crew
crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    verbose=True
)
result = crew.kickoff()

Best suited for

  • Multi-agent systems with clear role divisions (research → writing → review, etc.)
  • Automation of business processes
  • Content generation pipelines

3. AutoGen (Microsoft)

AutoGen is Microsoft’s framework for building AI agents and applications. Its current documentation describes AgentChat as a programming framework for conversational single-agent and multi-agent applications.[3]

# Python - Minimal AutoGen example (conceptual)
import autogen

# LLM configuration
llm_config = {"model": "MODEL_NAME", "api_key": "YOUR_API_KEY"}

# Define agents
assistant = autogen.AssistantAgent(
    name="CodingAssistant",
    llm_config=llm_config,
    system_message="An agent that writes Python code to solve problems."
)

# Human proxy agent (implements Human-in-the-loop)
user_proxy = autogen.UserProxyAgent(
    name="UserProxy",
    human_input_mode="TERMINATE",  # Ask the human when termination condition is met
    code_execution_config={"work_dir": "workspace"}
)

# Start the conversation (agents solve the task through dialogue)
user_proxy.initiate_chat(
    assistant,
    message="Write a Python script that calculates the Fibonacci sequence and test it"
)

This code uses an older AutoGen API as a conceptual example. Current AutoGen is organized into AgentChat, Core, and Extensions, so check the documentation for the version you are using before implementing it.[3]

Best suited for

  • Interactive task solving
  • Automation of code generation, execution, and debugging
  • Multi-agent experiments for research purposes

4. Mastra

Mastra is a TypeScript framework for building AI applications and agents. Its documentation covers agents, workflows, tools, memory, and evals for a modern TypeScript stack.[4]

// TypeScript - Minimal Mastra example (conceptual)
import { Mastra, Agent } from "@mastra/core";

// Define the agent
const researchAgent = new Agent({
  name: "ResearchAgent",
  instructions: "A specialized agent that uses web search to gather the latest information.",
  model: {
    provider: "ANTHROPIC",
    name: "claude-sonnet-4-5",
  },
  tools: {
    webSearch: webSearchTool,
    fileWrite: fileWriteTool,
  },
});

// Create the Mastra instance
const mastra = new Mastra({
  agents: { researchAgent },
});

// Run the agent
const agent = mastra.getAgent("researchAgent");
const result = await agent.generate(
  "Please research the latest AI agent market size"
);

console.log(result.text);

Best suited for

  • Integration into web frameworks like Next.js or Nuxt
  • Agent development in TypeScript projects
  • Cases where you want tight coupling between the frontend and agents

5. OpenAI Agents SDK (formerly Swarm)

The OpenAI Agents SDK is OpenAI’s agent SDK. Its documentation highlights Agents, Tools, Handoffs, Guardrails, and Tracing as core concepts.[5]

# Python - Minimal OpenAI Agents SDK example (conceptual)
from openai import OpenAI
from agents import Agent, Runner, handoff

client = OpenAI()

# Define each specialist agent
triage_agent = Agent(
    name="TriageAgent",
    instructions="Analyze the user's question and route it to the appropriate specialist agent.",
    model="MODEL_NAME"
)

coding_agent = Agent(
    name="CodingAgent",
    instructions="Handle questions about code.",
    model="MODEL_NAME",
    handoffs=[handoff(triage_agent)]  # Return to triage after completion
)

research_agent = Agent(
    name="ResearchAgent",
    instructions="Handle information gathering and research tasks.",
    model="MODEL_NAME",
    handoffs=[handoff(triage_agent)]
)

# Set handoff targets on the triage agent
triage_agent.handoffs = [
    handoff(coding_agent),
    handoff(research_agent)
]

# Run
result = Runner.run_sync(triage_agent, "Please implement a sorting algorithm in Python")

A handoff is a mechanism for delegating a conversation or control from one agent to another.[6] Think of it like transferring a customer call to the right department — the appropriate agent takes over based on its specialty.

Best suited for

  • Projects centered on the OpenAI API
  • Simple multi-agent handoff implementations
  • Customer support and triage systems

6. Claude Code (Anthropic)

Claude Code is Anthropic’s coding-oriented AI agent. The official documentation presents it as an agentic coding tool used from the terminal.[7]

Claude Code supports MCP integration and custom subagents for specialized work units.[8][9]

# Claude Code basic usage (command line)

# Execute a single task
claude -p "Investigate and fix the bug in src/auth.ts"

# Parallel tasks using sub-agents (conceptual example)
claude -p "Please execute the following in parallel:
  1. Write unit tests for the frontend
  2. Generate API documentation for the backend
  3. Optimize the CI configuration file"

# Operations integrated with an MCP server
# (when MCP servers are configured)
claude -p "Reference GitHub issue #123 and fix the corresponding code"

To use the same agent loop as Claude Code from an application, choose the Claude Agent SDK described next.[10]

Best suited for

  • Software development and codebase operations
  • Large-scale refactoring and automated test generation
  • Integration with external services via MCP

7. Claude Agent SDK (Anthropic)

The Claude Agent SDK provides the same built-in tools, agent loop, and context management as Claude Code through Python or TypeScript. Claude Code is an interactive development tool, while the Claude Agent SDK runs agents inside a custom application.[10]

# Python - Minimal Claude Agent SDK example
import asyncio
from claude_agent_sdk import ClaudeAgentOptions, query

async def main():
    options = ClaudeAgentOptions(
        allowed_tools=["WebSearch"],
        system_prompt="You are an agent that organizes research with sources.",
    )

    async for message in query(
        prompt="Research methods for evaluating AI agents",
        options=options,
    ):
        print(message)

asyncio.run(main())

In addition to built-in tools, the SDK lets an application configure MCP, subagents, permissions, and sessions in code.[10]

Best suited for

  • Embedding Claude Code’s agent capabilities in a custom application
  • Autonomous tasks that include file operations, command execution, and web search
  • Controlling tool permissions and execution progress from Python or TypeScript

8. Google ADK (Gemini)

The Google Agent Development Kit (Google ADK) is Google’s open-source agent development framework. It provides straightforward access to Gemini and can also connect to models from other providers. It supports Python, TypeScript, Go, Java, and Kotlin, covering tools, sessions, multi-agent systems, graph workflows, evaluation, and deployment.[11]

# Python - Minimal Google ADK example using Gemini
from google.adk import Agent
from google.adk.tools import google_search

root_agent = Agent(
    name="researcher",
    model="gemini-flash-latest",
    instruction="Research topics while checking supporting evidence.",
    tools=[google_search],
)

The Google GenAI SDK is a client SDK for calling the Gemini API directly. Google ADK is the relevant option in this framework comparison when an application also needs tool execution, state management, and multi-agent coordination.[11][12]

Best suited for

  • Building agents around Gemini and Google Cloud
  • Applying the same agent design across multiple programming languages
  • Handling multi-agent workflows, evaluation, and deployment in one framework

Framework Comparison Table

FrameworkLanguageKey FeatureLearning CostBest For
LangGraphPythonGraph-based, state managementMediumComplex workflows
CrewAIPythonRole/goal-based designLow–MediumRole-divided multi-agent
AutoGenPythonConversational agentsMediumResearch, code execution automation
MastraTypeScriptWeb integration, type safetyMediumWeb app integration
OpenAI Agents SDKPythonHandoffs, simplicityLowOpenAI-centered multi-agent
Claude CodeCLICoding-specialized, MCP integrationLowInteractive software development
Claude Agent SDKPython / TypeScriptBuilt-in tools, permission controlMediumCustom Claude-based agents
Google ADKPython / TypeScript / Go / Java / KotlinGemini integration, workflows, evaluationMediumGemini- and Google Cloud-centered agents
This table scrolls horizontally. Keyboard users can focus the table and use the left and right arrow keys.

Framework Selection Flowchart

graph TD
    Start["Framework Selection"] --> Use{"Primary requirement?"}

    Use -->|"Interactive coding"| ClaudeCode["Claude Code\n(coding-specialized)"]
    Use -->|"Embed Claude tool use in an app"| ClaudeSDK["Claude Agent SDK\n(built-in tools and permissions)"]
    Use -->|"Build around Gemini and Google Cloud"| GoogleADK["Google ADK\n(multi-language, evaluation, deployment)"]
    Use -->|"Build around the OpenAI API"| OpenAI["OpenAI Agents SDK\n(handoffs)"]
    Use -->|"Complex state management"| LangGraph["LangGraph\n(graph-based)"]
    Use -->|"Clear role-divided team structure"| CrewAI["CrewAI\n(role/goal-based)"]
    Use -->|"Conversational experiments"| AutoGen["AutoGen\n(conversational agents)"]
    Use -->|"TypeScript web app integration"| Mastra["Mastra\n(TypeScript-first)"]

Summary

  • Frameworks let you avoid implementing the ReAct loop, tool management, and inter-agent communication yourself
  • Each of the eight options has its own design philosophy and strengths
  • For embedded Claude agent capabilities, consider Claude Agent SDK; for Gemini-centered development, consider Google ADK; for interactive coding assistance, consider Claude Code
  • LangGraph fits complex state management, CrewAI fits role-divided agents, and Mastra fits TypeScript web integration
  • I recommend trying a small prototype before committing to production use

Frequently Asked Questions

Q: Which framework is easiest for beginners?

A: CrewAI or the OpenAI Agents SDK are most beginner-friendly. CrewAI is especially intuitive — you can build a multi-agent system just by defining roles and goals in natural language. LangGraph is feature-rich but takes time to get comfortable with the graph concept.

Q: What’s the difference between LangChain and LangGraph?

A: LangChain is a general-purpose framework for LLM applications. LangGraph is an agent-specialized framework built on top of LangChain, centered on flow control through graph structures. For building agents, LangGraph is recommended.

Q: Can multiple frameworks be used together?

A: Technically possible, but it gets complex and I don’t recommend it. First check whether a single framework can meet your requirements; only consider combining them if there’s truly no other way.

Q: Is there a way to call the Anthropic API directly without a framework?

A: Yes. Using the Anthropic Python SDK (anthropic package), you can build agents without a framework. This approach is appropriate for simple agents or cases with strong custom requirements. See AI Agents and MCP for details.

Q: What is the difference between the Google GenAI SDK and Google ADK?

A: The Google GenAI SDK is a client SDK for calling the Gemini API directly. Google ADK is an agent development framework that adds tools, sessions, multiple agents, and workflows around model calls. The Google GenAI SDK fits one-off generation tasks, while Google ADK fits designing a complete agent system.[11][12]

References

  1. LangChain, LangGraph overview
  2. CrewAI, Agents
  3. Microsoft, AutoGen
  4. Mastra, Get started with Mastra
  5. OpenAI, OpenAI Agents SDK
  6. OpenAI, Handoffs
  7. Anthropic, Claude Code overview
  8. Anthropic, Connect Claude Code to tools via MCP
  9. Anthropic, Create custom subagents
  10. Anthropic, Agent SDK overview
  11. Google, Agent Development Kit
  12. Google, Gemini API libraries

For the latest releases and updates, check the official website and official documentation.

Quiz