There is no single best AI agent framework for Python. Pick LangGraph when you need explicit control, durable state and human approval. Pick CrewAI when work breaks into roles and you want a working multi-agent prototype fast. Pick Agno when you want agents, teams, memory and a FastAPI runtime in one stack. Pick smolagents when the agent should write Python to call tools. For typed, schema-validated outputs, start with Pydantic AI.

All of the libraries below are open source and free at the library level. You pay for model API calls and any optional hosted platform you choose. Versions checked on PyPI on October 9, 2026: langgraph 1.2.14, langchain 1.4.4, crewai 1.15.26, agno 3.1.2, smolagents 1.26.0, pydantic-ai 2.54.0 and openai-agents 0.23.1. For a deeper three-way comparison of LangGraph, CrewAI and the OpenAI Agents SDK, see LangGraph vs CrewAI vs OpenAI Agents SDK. TypeScript teams should start with best TypeScript AI agent frameworks.

Best AI agent frameworks for Python compared

FrameworkPyPI packageLicenseBest forMain abstraction
LangGraphlanggraphMITProduction workflows with branches and approvalsState graph with checkpoints
CrewAIcrewaiMITRole-based multi-agent prototypesCrews of agents plus Flows
AgnoagnoApache-2.0Full agent platforms with a runtime UI/APIAgents, teams and workflows
smolagentssmolagentsApache-2.0Code-first agents that write tool calls as PythonCodeAgent / ToolCallingAgent
Pydantic AIpydantic-aiMITTyped tools and structured outputsAgent with deps and output types
OpenAI Agents SDKopenai-agentsMITSmall multi-agent systems with handoffsAgents, tools, handoffs, sessions

GitHub star counts (public API, October 9, 2026) are a rough popularity signal only: LangChain ~147k, CrewAI ~59k, LangGraph ~43k, Agno ~43k, OpenAI Agents SDK ~30k, smolagents ~30k, Pydantic AI ~21k. Stars are not quality scores.

LangGraph: best for production control

LangGraph is LangChain's low-level orchestration runtime for long-running, stateful agents. Official docs describe it as focused on durable execution, streaming, human-in-the-loop and persistence, not on hiding prompts or architecture. You define a typed state, write nodes as functions and connect them with edges, including conditional edges that route on the current state. A checkpointer saves state after each step so a run can pause for a person, survive a crash and resume on the same thread.

from typing import TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.checkpoint.memory import InMemorySaver

class State(TypedDict):
    draft: str
    approved: bool

def write(state: State) -> dict:
    return {"draft": "Refund approved for order 1042."}

def route(state: State) -> str:
    return "send" if state.get("approved") else "review"

def review(state: State) -> dict:
    return {"approved": True}

def send(state: State) -> dict:
    print("sending:", state["draft"])
    return {}

g = StateGraph(State)
g.add_node("write", write)
g.add_node("review", review)
g.add_node("send", send)
g.add_edge(START, "write")
g.add_conditional_edges("write", route, ["send", "review"])
g.add_edge("review", "send")
g.add_edge("send", END)

app = g.compile(checkpointer=InMemorySaver())
app.invoke({"draft": "", "approved": False}, {"configurable": {"thread_id": "ticket-1042"}})

In a real agent, write would call a model and review would be an interrupt that waits for a human. Swap InMemorySaver for a database-backed checkpointer in production. LangChain sits beside LangGraph as the higher-level agent framework (models, tools and agent loops). LangChain's own stack guide also points beginners who want a prebuilt harness at Deep Agents on top of LangGraph.

Pros: explicit branches and loops, durable checkpoints, first-class interrupts, Python and TypeScript ports, optional tracing and deploy through LangSmith.

Cons: more concepts before a first demo; overkill if you only need a model-plus-tools loop.

Who it's for: teams shipping regulated or long-running workflows where you must explain and resume every step.

Sources: LangGraph overview, PyPI langgraph.

CrewAI: best for role-based teams, fast

CrewAI popularized crews: agents with a role, goal and backstory that work through tasks. Flows add event-driven, stateful orchestration when a prototype needs stricter control. The docs recommend Python 3.10 through 3.13 and the uv toolchain; uv tool install crewai installs the CLI, then crewai create crew scaffolds a project.

from crewai import Agent, Task, Crew, Process

researcher = Agent(
    role="Researcher",
    goal="Find accurate, current facts about the topic",
    backstory="A careful analyst who cites sources.",
)
summary = Task(
    description="Summarize the state of {topic} in 2026.",
    expected_output="Three bullet points with sources.",
    agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[summary], process=Process.sequential)
result = crew.kickoff(inputs={"topic": "agent sandboxes"})

Newer CLI scaffolds are JSON-first (agents/*.jsonc and crew.jsonc). Use --classic if you want the older Python/YAML layout. CrewAI also ships enterprise hosting (AMP SaaS and Factory self-hosted); the open-source library stays MIT.

Pros: readable role/task vocabulary, fast time to a demo, Flows for persistence and human feedback, active docs and CLI.

Cons: free-running collaboration is harder to debug than an explicit graph; tight control pushes you into Flows, which narrows the gap with LangGraph.

Who it's for: product and research teams that think in specialist roles (researcher, writer, reviewer) and need a working crew this week.

Sources: CrewAI docs, installation, GitHub crewAI.

Agno: best batteries-included Python platform

Agno is a Python SDK plus AgentOS runtime for building and serving agent platforms. The three primitives are agents, teams and workflows. You attach capabilities as needed: memory, knowledge, sessions, guardrails, human-in-the-loop, evals and OpenTelemetry tracing. Official setup uses Python 3.9+ and uv pip install -U agno openai (or other providers). Serving with AgentOS adds a FastAPI app, usually on http://localhost:7777, with health and OpenAPI endpoints.

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.os import AgentOS

agent = Agent(
    name="Support",
    model="openai:gpt-5-mini",
    db=SqliteDb(db_file="support.db"),
    enable_agentic_memory=True,
    add_history_to_context=True,
    num_history_runs=3,
)

agent_os = AgentOS(agents=[agent], tracing=True)
app = agent_os.get_app()

Agno's docs emphasize ownership of data and security posture (including JWT-based RBAC on the runtime) and ship docs as an MCP server so coding agents can read the live surface. The library is Apache-2.0.

Pros: agents, teams and workflows in one API; built-in storage/memory path; AgentOS turns the same code into a service; many model and tool integrations.

Cons: larger surface than a thin SDK; you should learn the primitive you need (agent vs team vs workflow) before stacking every capability.

Who it's for: teams that want a Python-owned agent platform, not only a library for a single chat loop.

Sources: Agno SDK introduction, Install and setup, GitHub agno.

smolagents: best for code-first agents

Hugging Face smolagents keeps the agent loop small. CodeAgent writes tool calls as Python (loops, conditionals, nested calls). ToolCallingAgent uses ordinary JSON tool calls when you prefer that style. Install with pip install 'smolagents[toolkit]'. Models can come from the Hub Inference API, LiteLLM (OpenAI, Anthropic and others), Transformers, vLLM or Ollama. Generated code can run in sandboxes such as E2B, Modal, Docker or similar providers — important because code execution is powerful and risky if left open.

from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool

model = InferenceClientModel()
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
result = agent.run("What is the capital of France?")
print(result)

Pros: tiny API, first-class code agents, Hub sharing, MCP and LangChain tools, model-agnostic.

Cons: the docs mark the API as experimental and subject to change; you must sandbox code execution carefully for untrusted tasks.

Who it's for: researchers and builders who want agents to compose tools in real Python, especially on Hugging Face models.

Sources: smolagents docs, PyPI smolagents.

Pydantic AI and OpenAI Agents SDK: strong runners-up

Pydantic AI (by the Pydantic team) is the typed option: dependency injection into tools, structured output_type models, OpenTelemetry instrumentation and optional durable execution on engines such as Temporal. It is the natural pick when the agent's return value must validate like any other API response. See the Pydantic AI overview.

The OpenAI Agents SDK keeps primitives small — agents, tools, handoffs, guardrails and sessions — and works with non-OpenAI providers even though OpenAI models are the default. It is the shortest path when a triage agent should hand work to specialists. Details and sample code are in our LangGraph vs CrewAI vs OpenAI Agents SDK guide.

How to choose an AI agent framework in Python

Ask these questions in order:

  1. Do you need durable state, branches and human approval? Choose LangGraph (or Agno workflows / CrewAI Flows if you already picked those stacks).
  2. Does the work map to specialist roles? Choose CrewAI.
  3. Do you want a full platform with an HTTP runtime and memory out of the box? Choose Agno.
  4. Should the agent write Python to call tools? Choose smolagents, and pair it with a sandbox.
  5. Must every output pass a schema? Choose Pydantic AI.
  6. Is the design a thin handoff graph? Choose the OpenAI Agents SDK.

If you are still exploring, prototype in CrewAI or smolagents, then move the control-heavy path to LangGraph once you know which steps must be deterministic. Keep tools as plain Python functions with clear schemas so migration between frameworks stays cheap. For agent memory libraries rather than orchestration, see AI agent memory: Mem0 vs Letta vs Zep. For sandboxes that execute agent code safely, see E2B vs Daytona vs Modal.

FAQ

What is the best AI agent framework for Python in 2026?

There is no universal winner. LangGraph is the safest default for production control and durable state. CrewAI is the fastest path to a role-based multi-agent demo. Agno fits teams building a full agent platform. smolagents fits code-first agents. Pydantic AI fits typed, schema-validated outputs.

Is there a good open source AI agent framework?

Yes. LangGraph, CrewAI, Agno, smolagents, Pydantic AI and the OpenAI Agents SDK are all open source (MIT or Apache-2.0). Optional hosted products (LangSmith, CrewAI AMP, Agno control plane and similar) are separate from the libraries.

LangGraph or CrewAI for a first project?

CrewAI if you want a readable crew this week. LangGraph if you already know you need branching, checkpoints and approval gates. Many teams prototype in CrewAI and rewrite the critical path in LangGraph later.

Does Microsoft have an AI agent framework for Python?

Microsoft's current direction is the Microsoft Agent Framework, positioned as the successor path for AutoGen and Semantic Kernel. AutoGen remains available but is no longer the place to start a new Python project. Prefer LangGraph, CrewAI, Agno or the OpenAI Agents SDK unless you are standardized on Microsoft's stack.

What about Java AI agent frameworks?

This guide is Python-only. Java has separate options (for example Embabel appears in autocomplete for "java ai agent framework"). If your runtime is the JVM, evaluate Java-native tools rather than wrapping Python frameworks.

Can I mix these frameworks?

Usually you pick one orchestrator. You can still share tools, MCP servers and model providers across projects. Building an MCP server once and connecting it from several clients is often cleaner than embedding two orchestrators in one process — see how to build an MCP server in Python.