Guide

Open-Source AI Agent Frameworks You Can Self-Host

Thirteen open-source frameworks for building AI agents, compared on the things that matter when the agent runs on your own machines: the license, the languages, what each is best for, and what you still have to run yourself.

Licenses and project status checked against each project’s GitHub repository on . These projects change quickly: confirm the LICENSE file and README of the version you install.

At a glance

FrameworkLicenseLanguagesBest for
LangGraphLangChainMITPython, JavaScript/TypeScriptLong-running, stateful agents that must resume after a crash
CrewAICrewAI Inc.MITPythonTeams of role-based agents working one task together
Microsoft Agent FrameworkMicrosoftMITPython, .NET (Go in a separate repository).NET and Python teams, and anyone moving off AutoGen
AG2AG2 community (ag2ai)Apache-2.0PythonConversational multi-agent code written the AutoGen way
OpenHandsOpenHands (All Hands AI)MIT (core)Python, TypeScriptAn autonomous coding agent you run on your own machines
smolagentsHugging FaceApache-2.0PythonAgents that act by writing and running code
OpenAI Agents SDKOpenAIMITPython, JavaScript/TypeScriptLightweight multi-agent workflows with handoffs and guardrails
Agent Development Kit (ADK)GoogleApache-2.0Python (Java, Kotlin, Go and TypeScript in separate repositories)Code-first agents you also want to evaluate before shipping
Pydantic AIPydanticMITPythonPython teams who want typed, validated tool calls and outputs
LlamaIndexLlamaIndexMITPythonAgents that work over your own documents and data
HaystackdeepsetApache-2.0PythonExplicit, inspectable pipelines for retrieval-heavy agents
AgnoAgnoApache-2.0PythonRunning agents as durable services with an API and MCP server
MastraMastraApache-2.0 (except ee/ directories)TypeScriptTypeScript and Node.js teams

Pick by the job

The frameworks

LangGraph

By
LangChain
License
MIT
Languages
Python, JavaScript/TypeScript

Best for

Long-running, stateful agents that must resume after a crash

A low-level orchestration library: you model the agent as a graph of steps, and LangGraph handles durable execution, human-in-the-loop interrupts and memory. It does not prescribe a prompt or agent architecture.

Self-hosting it

It is a library that runs inside your own process. Durable execution depends on a checkpointer, so a self-hosted deployment needs a database you operate to hold checkpoints, plus a place to run any code the agent's tools execute. LangChain also sells a managed deployment platform; the MIT library does not require it.

CrewAI

By
CrewAI Inc.
License
MIT
Languages
Python

Best for

Teams of role-based agents working one task together

A standalone Python framework (it does not depend on LangChain) built around two ideas: Crews, groups of agents with roles and goals that collaborate, and Flows, event-driven workflows that give you step-by-step control.

Self-hosting it

Runs as an ordinary Python program and works with local models as well as hosted APIs. Anything a crew needs to remember between runs, such as memory, task output and flow state, has to live on storage you keep, which is the part most self-hosted setups get wrong.

Microsoft Agent Framework

By
Microsoft
License
MIT
Languages
Python, .NET (Go in a separate repository)

Best for

.NET and Python teams, and anyone moving off AutoGen

Microsoft's framework for single agents and multi-agent workflows, and the successor it names for AutoGen. Microsoft publishes a migration guide from AutoGen.

Self-hosting it

The SDK runs anywhere Python or .NET runs. Its samples cover both local development and cloud hosting, and it supports Microsoft Foundry and Azure OpenAI alongside other providers, so check that each connector you pick doesn't tie you to one cloud.

AG2

By
AG2 community (ag2ai)
License
Apache-2.0
Languages
Python

Best for

Conversational multi-agent code written the AutoGen way

The community-run continuation of AutoGen, describing itself as "formerly AutoGen". It keeps the conversational multi-agent model AutoGen users know, under its own governance and license.

Self-hosting it

A Python library. Multi-agent conversations that execute code need somewhere isolated to run it; give each agent its own sandbox rather than the host you deploy on.

OpenHands

By
OpenHands (All Hands AI)
License
MIT (core)
Languages
Python, TypeScript

Best for

An autonomous coding agent you run on your own machines

A coding agent rather than a general framework: it reads an issue, edits code, runs commands and tests, and opens a pull request. Its Software Agent SDK and Agent Server are what run the agent.

Self-hosting it

The MIT core gives you the agent, SDK, Agent Server and CLI. Single sign-on, role-based access, audit logs and LLM budgeting sit in a paid Enterprise tier. Every session executes arbitrary code, so isolation is the main decision: a Docker container per session is the common default, and a micro-VM per session gives each agent its own kernel.

smolagents

By
Hugging Face
License
Apache-2.0
Languages
Python

Best for

Agents that act by writing and running code

A deliberately small library whose CodeAgent writes its actions as Python code instead of JSON tool calls. It is model-agnostic, including local models through transformers or Ollama.

Self-hosting it

Because actions are code, where that code runs matters. smolagents supports sandboxed execution through Docker, E2B, Modal or Blaxel; for a fully self-hosted setup, Docker or your own micro-VMs are the options that stay on your hardware.

OpenAI Agents SDK

By
OpenAI
License
MIT
Languages
Python, JavaScript/TypeScript

Best for

Lightweight multi-agent workflows with handoffs and guardrails

A small set of primitives: agents with instructions and tools, handoffs between agents, guardrails, human-in-the-loop and tracing. Despite the name it is provider-agnostic and works with many non-OpenAI models.

Self-hosting it

Runs in your own process. Tracing is built in, so check where traces are sent and switch it off or redirect it if your data has to stay on your own infrastructure.

Agent Development Kit (ADK)

By
Google
License
Apache-2.0
Languages
Python (Java, Kotlin, Go and TypeScript in separate repositories)

Best for

Code-first agents you also want to evaluate before shipping

A code-first toolkit for building, evaluating and deploying agents and multi-agent workflows. It is optimized for Gemini but model-agnostic.

Self-hosting it

The library runs in any Python process. Its deployment guides lean towards Google Cloud, so if you are self-hosting, plan your own serving, session storage and scaling instead of following those defaults.

Pydantic AI

By
Pydantic
License
MIT
Languages
Python

Best for

Python teams who want typed, validated tool calls and outputs

An agent framework from the team behind Pydantic, typed end to end: tool arguments and agent outputs are validated against your own models, so type checkers and tests catch mistakes before production does.

Self-hosting it

A plain Python dependency with no server of its own. You bring the process manager, the state store and the sandbox for any tool that runs code.

LlamaIndex

By
LlamaIndex
License
MIT
Languages
Python

Best for

Agents that work over your own documents and data

Started as a data framework for connecting models to documents, and now includes agent workflows. Its strength is ingestion, indexing and retrieval over private data.

Self-hosting it

The open-source library runs locally; the company also sells hosted document-processing services. For a fully self-hosted build, pair it with a vector store and model you run yourself.

Haystack

By
deepset
License
Apache-2.0
Languages
Python

Best for

Explicit, inspectable pipelines for retrieval-heavy agents

An orchestration framework built from modular pipelines, giving you explicit control over retrieval, routing, memory and generation. Agents are one kind of pipeline among many.

Self-hosting it

Pipelines are Python objects you can run in your own services. Each component (document store, model, retriever) is chosen separately, so a fully on-premises stack is possible.

Agno

By
Agno
License
Apache-2.0
Languages
Python

Best for

Running agents as durable services with an API and MCP server

Builds agents, teams and workflows, and runs them as services through AgentOS, which provides authentication, role-based access, resume and replay, human approvals and scheduling.

Self-hosting it

Designed to run in your own cloud: its starter template brings up an API server, an MCP server and PostgreSQL for conversations and memory. Its control-plane UI is a hosted web app, so check what it can see before you connect it.

Mastra

By
Mastra
License
Apache-2.0 (except ee/ directories)
Languages
TypeScript

Best for

TypeScript and Node.js teams

A TypeScript framework for agents and workflows with model routing across many providers. It plugs into React, Next.js and Node, or runs as a standalone server.

Self-hosting it

Deploy it anywhere Node runs. Code under directories named ee/ is under a separate enterprise license, so check which packages you depend on.

Why AutoGen isn’t on the list

Microsoft has archived AutoGen and no longer ships bug or security fixes for it. New projects should start on Microsoft Agent Framework, which Microsoft names as its successor, or AG2, the community continuation. An AutoGen deployment you already run keeps working, but plan the migration.

What every framework leaves to you

A framework decides how the agent thinks and calls tools. Self-hosting it means you also own the machine it runs on.

Isolation

Frameworks orchestrate; they do not contain. Any tool that runs code, installs packages or browses needs a boundary: a container shares the host kernel, a micro-VM gives each agent its own.

State that outlives the process

Checkpoints, memory and the agent's working files have to sit on storage that survives a restart or redeploy, not in the process that crashed.

Long-running execution

Agent runs last minutes to hours, which breaks request timeouts on serverless platforms. Plan for a resident process or a machine per agent.

Idle cost

Most agents spend most of their time waiting. Without sleep-and-wake, you pay for every idle machine in the fleet.

Observability

The same prompt can take a different path on every run, so you need traces of model calls, tool calls and their results, not just HTTP logs.

Questions

Which open-source AI agent framework is best?
There isn't one winner; it depends on the job. LangGraph suits long-running, stateful agents, CrewAI suits role-based teams of agents, smolagents suits agents that act by writing code, OpenHands is a ready-made coding agent, and Mastra is the TypeScript-first option. Use the table above to narrow it to two, then build the same small task in both.
Are these frameworks free to self-host?
Each core library on this list is under the MIT or Apache-2.0 license, so you can run it on your own machines without paying the maintainer. You still pay for compute, storage and model usage. Some projects keep extra features under a separate license or in a paid tier (OpenHands Enterprise, Mastra's ee/ directories), so read the LICENSE file of the exact packages you install.
Is AutoGen still maintained?
No. Microsoft has archived AutoGen and says it no longer provides bug or security fixes. It points new users to Microsoft Agent Framework and publishes a migration guide. AG2, a community project that describes itself as formerly AutoGen, is maintained separately.