AI Agent Frameworks: How to Choose One for Building in Python
・ Employee Store Operations

Summary
When you build an AI agent in Python, first decide whether to use a framework or call the AI model's API directly. This article compares LangChain, LangGraph, OpenAI Agents SDK and Claude Agent SDK, based on their official documentation as checked in October 2026. It also walks through getting your first agent running.
The content of this article was checked against each vendor's official documentation on October 2, 2026. Frameworks change quickly, and function names or requirements may change. Check the sources at the end for the latest details before you use them.
An AI agent framework is a library that packages the parts every agent needs, such as calling the AI model, defining tools and managing conversation state. You write less code yourself. In return, you need to know what happens inside the library.
Why use a framework, and when not to
In its article on building agents, Anthropic divides AI-based systems into two kinds. Workflows run AI and tools along predefined steps. Agents let the AI decide its own steps and how to use tools.
The same article recommends finding the simplest solution first and adding complexity only when needed. For many uses, it says a single call to an AI model, plus retrieval or examples, is enough.
Benefits and cautions of frameworks
- Benefit: common tasks such as calling the AI model, defining and parsing tools, and chaining calls are easy to write
- Caution: extra layers of abstraction make it harder to see the instructions sent to the AI and the responses that come back, which makes debugging harder
- Caution: they tempt you to add complexity even where a simple setup would do
The article recommends starting by using the AI model's API directly. If you do use a framework, it asks you to understand the code underneath. It says wrong assumptions about what happens inside are a common source of errors.
LangChain and LangGraph
LangChain and LangGraph are both libraries built by the LangChain team. They play different roles.
LangChain: assemble the basics of an agent
LangChain creates agents with a function called create_agent. Pass it an AI model, tools and a system prompt, and you get a setup where the AI answers while using tools. Adding middleware lets you layer on guardrails, retries and rules for tool use later.
You can call AI models from providers such as OpenAI, Anthropic and Google with the same code. The official documentation says you can switch models with few changes. LangChain agents are built on top of LangGraph.
LangGraph: control the flow and state in detail
LangGraph is a low-level orchestration framework for long-running, stateful agents. You can mix predefined steps and steps the AI decides within a single graph.
- If a run fails partway, it can resume from where it stopped (persistence)
- A person can check and edit the state partway through (human-in-the-loop)
- It can keep short-term memory within a conversation and long-term memory across conversations
The official documentation recommends that people building agents for the first time, or who want a higher level of abstraction, start with LangChain agents. LangGraph can also be used without LangChain.
The LangChain documentation also lists Deep Agents as another option. It comes with features such as automatic context compression, a virtual file system and spawning subagents built in.
Vendor SDKs: OpenAI Agents SDK and Claude Agent SDK
AI model providers also offer SDKs for building agents. They are designed for use with the vendor's own models, but they also provide ways to use models from other providers.
OpenAI Agents SDK
OpenAI Agents SDK is a library for building agents from a small set of parts. It has three core parts.
- Agents: AI models with instructions and tools
- Agents as tools and handoffs: ways to delegate work to other agents
- Guardrails: checks on inputs and outputs
You can turn a Python function into a tool as is, and the argument schema is generated automatically. It can also call tools on MCP servers. Tracing (a record of each run) is built in, so you can see how the agent behaved and fix it. With OpenAI models it uses the Responses API by default, and the documentation also covers how to use models from other providers.
Claude Agent SDK
Claude Agent SDK is a library that makes the same tools, agent loop and context management that power Claude Code available from Python and TypeScript. Tools for reading and writing files, running commands and searching the web are built in.
It also supports hooks, subagents, MCP, permission settings and sessions. Authentication uses an API key. The official documentation does not allow third-party developers to offer claude.ai login or usage limits in their own products unless they have prior approval.
LangChain
- Build with create_agent
- Easy to switch model providers
- Runs on top of LangGraph
LangGraph
- Control flow and state in detail
- Resume from where it stopped
- Usable without LangChain
OpenAI Agents SDK
- Few parts
- Delegate work with handoffs
- Tracing built in
Claude Agent SDK
- Same tools and loop as Claude Code
- File operations and command execution built in
- Authenticates with an API key
Checked against official documentation in October 2026
Python or TypeScript
All four can be used from Python. As of October 2026, each requires Python 3.10 or later. This is stated in the official documentation for LangChain and Claude Agent SDK, and in the configuration files on GitHub for LangGraph and OpenAI Agents SDK.
You can also write in TypeScript (JavaScript). LangChain and LangGraph have JavaScript documentation, and OpenAI Agents SDK has a TypeScript version. Using Claude Agent SDK from TypeScript requires Node.js 18 or later.
| Framework | Python | TypeScript | License or terms |
|---|---|---|---|
| LangChain | 3.10 or later | JavaScript version available | MIT |
| LangGraph | 3.10 or later | JavaScript version available | MIT |
| OpenAI Agents SDK | 3.10 or later | TypeScript version available | MIT |
| Claude Agent SDK | 3.10 or later | Supported (Node.js 18 or later) | Subject to Anthropic's Commercial Terms of Service |
Matching the language of the system the agent will plug into reduces integration work.
If you build it into something you sell, check the license too. The GitHub repositories for LangChain, LangGraph and OpenAI Agents SDK use the MIT license. The official documentation states that use of Claude Agent SDK, including in products you offer to your own customers, is subject to Anthropic's Commercial Terms of Service.
What to compare: state, tools and observability
When comparing frameworks, look at the parts your agent needs rather than the number of features. There are three points to check.
State management
For long tasks or tasks with human checks, see whether you can save the state partway and resume. LangGraph makes persistence and human checks core features. OpenAI Agents SDK and Claude Agent SDK have session features that keep context across exchanges.
Tools
Agents do work in the outside world through tools. Check whether you can turn your own functions into tools and whether you can connect MCP servers. Anthropic's article recommends writing tool descriptions and parameters with as much care as prompts. How MCP works is explained in AI agents and MCP.
Observability
An agent can behave differently each time, even with the same input. If you cannot record which tools it called and in what order, you cannot find the cause of failures. OpenAI Agents SDK has tracing by default, and LangChain and LangGraph let you view traces in LangSmith.
What kind of agent are you building
Steps to run a minimal agent
With any framework, getting your first agent running follows similar steps. In the OpenAI Agents SDK quickstart, you create a working folder and a Python virtual environment, then install openai-agents with pip. You set your API key as an environment variable, create an agent with a name and instructions, run it and check the final output.
- 1Create a virtual environmentPython 3.10 or later
- 2Install the library
- 3Set the API key as an environment variable
- 4Write instructions and create the agent
- 5Run it and check the output
- 6Add 1 toolWatch the calls in the trace
Do not write the API key directly in your code; pass it through an environment variable. Add tools one at a time and check how the agent behaves. Anthropic's article recommends reviewing, from the AI's point of view, whether a tool's description alone makes clear how to use it.
Once it works, decide when it should stop. The same article mentions adding stopping conditions such as a maximum number of iterations. Because agents can run up costs and compound errors, it also recommends extensive testing in a sandboxed environment. Connect tools that write to external services only after testing.
Selling the agent you built
If you sell an agent built in code, first decide where the buyer will run it. If it runs in the buyer's environment, list the required Python version, libraries and API key setup in the installation steps. Also state on the listing page who pays for AI model usage. The overall build process is covered in How to build an AI agent, and designs that combine several agents in Multi-agent design.
Employee Store is a marketplace where companies can adopt AI agents built by developers, with a one-time purchase or a monthly plan. Listings can take any format, including custom-built agents, agents that use the Claude or OpenAI API, and agents built with LangChain. There is no listing fee or upfront cost. The fee is 20% of the deal amount and applies only when a deal closes.
FAQ
- Do I need a framework to build an AI agent?
- No. Anthropic recommends starting by using the AI model's API directly and adding complexity when needed. A framework reduces common work, but you need to understand what happens inside it.
- Should I start with LangChain or LangGraph?
- The LangGraph documentation recommends that first-time agent builders start with LangChain agents. Use LangGraph for long-running work where you want fine control over saving progress and human checks.
- Which version of Python do I need?
- As of October 2026, LangChain, LangGraph, OpenAI Agents SDK and Claude Agent SDK all require Python 3.10 or later. This may change with updates, so check each project's documentation before you start.
Sources
- Anthropic, 'Building effective agents'
- LangChain Docs, 'LangChain overview' (checked October 2, 2026)
- LangChain Docs, 'Install LangChain'
- LangChain Docs, 'LangGraph overview'
- LangChain Docs, 'LangChain overview' (JavaScript)
- LangChain Docs, 'LangGraph overview' (JavaScript)
- LangGraph, 'pyproject.toml'
- LangChain, 'LICENSE'
- LangGraph, 'LICENSE'
- OpenAI Agents SDK (checked October 2, 2026)
- OpenAI Agents SDK, 'Quickstart'
- OpenAI Agents SDK, 'Models'
- OpenAI Agents SDK TypeScript
- openai-agents-python, 'pyproject.toml'
- openai-agents-python, 'LICENSE'
- Claude Code Docs, 'Agent SDK overview' (checked October 2, 2026)
- Claude Code Docs, 'Agent SDK Quickstart'
- Employee Store, Seller guide (Japanese)


