Claude Agent SDK vs LangGraph vs build-your-own in 2026
Three honest options for running production agents in late 2026. Model lock-in, control, and the hidden cost nobody puts in the comparison table.
By late 2026, most teams building a production agent have narrowed the choice to three real options: use the Claude Agent SDK, use LangGraph, or write the agent loop themselves against a raw model API. Each has become a sensible pick for a specific kind of team and workload. The frameworks article compared the broader agent framework landscape — this piece goes narrower, into the direct tradeoff between the three options teams actually weigh when they are ready to ship.
The three in one sentence each
- Claude Agent SDK — Anthropic’s programmable agent harness (renamed from Claude Code SDK in early 2026), ships the same agent loop that powers Claude Code. Claude-only.
- LangGraph — a stateful graph framework that models an agent as nodes and edges with checkpointing. Model-agnostic. Verbose but maximally explicit.
- Build-your-own — a manual loop written directly against the Anthropic, OpenAI, or open-model API. No framework. Full control, no abstraction tax.
Claude Agent SDK
The SDK packages the same tool-use loop that powers Claude Code into a Python and TypeScript library. Install is one command (pip install claude-agent-sdk or npm install @anthropic-ai/claude-agent-sdk) and a working agent is dozens of lines rather than hundreds.
Where it wins:
- Fastest path to a working Claude agent. For teams committed to Claude, this is the lowest-friction option. The loop, tool-use plumbing, and session handling are already built.
- Native MCP support. The SDK has first-class support for Model Context Protocol servers, so adding a new tool is a config entry rather than a wiring exercise. Covered more in MCP explained.
- Same patterns as Claude Code. Teams whose developers already use Claude Code get a familiar mental model for the production agent. Subagents, tracing, and evaluation patterns carry over.
- Anthropic-maintained. The SDK ships with the model provider, so API behaviour changes and new model capabilities tend to land on the SDK first.
Where it loses:
- Claude-only. The SDK is not an orchestration framework that happens to default to Claude — it is a Claude agent runtime. Switching to OpenAI, Gemini, or an open-weight model later means replacing the agent code, not swapping a config.
- API still at v0.x. As of late 2026, the SDK is actively evolving and has breaking changes between versions. Teams building on it should pin the version carefully and track the changelog.
- Billing nuance. Starting mid-2026, Agent SDK usage on Anthropic’s subscription plans draws from a separate programmatic credit pool (distinct from interactive usage). Teams planning to run agents at scale should budget via API keys, not subscription plans. Confirm the current terms on Anthropic’s own documentation before committing.
Pick the Claude Agent SDK when: the team has decided Claude is the model for the foreseeable future, speed-to-production matters, and the agent is a tool-use loop rather than a complex multi-stage workflow.
LangGraph
LangGraph models an agent as a directed graph with explicit nodes and edges. Each node is a function (LLM call, tool invocation, conditional router), and state is persisted at every super-step via a checkpointer so long-running agents survive restarts.
Where it wins:
- Model-agnostic. The same graph runs against Claude, GPT-4o, Gemini, or a locally hosted open-weight model. Switching providers is a config change, not a rewrite.
- Deterministic control flow. Every path through the agent is a defined edge. Debugging means tracing a graph, not reading transcripts hoping to catch where the model went off-script.
- State persistence. Long-running workflows (minutes, hours, multi-day with human approvals) resume from the last checkpoint instead of restarting. This is the production-grade pattern the SDK and raw loops have to build themselves.
Where it loses:
- Verbose. A simple research agent that is 50 lines in the Claude Agent SDK is often 150-400 in LangGraph depending on how much graph structure is defined. The boilerplate pays off at complexity but hurts at simplicity.
- LangChain lineage. LangGraph lives under the LangChain ecosystem. Teams that migrated away from LangChain for complexity reasons may inherit some of the same abstraction overhead.
Pick LangGraph when: the workflow is longer than one LLM round-trip, has conditional branching, needs retries or approvals, or must survive process restarts. Also when the team wants model portability as insurance against pricing or availability changes.
Covered in more depth in the agent frameworks comparison article.
Build-your-own
The build-your-own option is a plain Python (or TypeScript) loop that calls the model API directly, parses the tool-use response, executes the tool, appends the result, and loops. No framework. No DAG. A production version is 100-300 lines depending on the retry and logging story.
Where it wins:
- No abstraction tax. The code is the design. There is no framework version to upgrade, no framework quirk to debug, no framework-shaped hole for the agent to fall into.
- Minimum dependency surface. One SDK (the model provider’s own), one HTTP library, standard logging. Teams that run production systems with strict dependency review find this attractive.
- Full control over context. The prompt, the tool definitions, the retry strategy, the token budget, the logging format — all explicit. See context engineering for why this matters at scale.
Where it loses:
- You rebuild everything. Tool-use plumbing, streaming, retries on 429s, checkpoint persistence, parallel sub-agents, MCP support — all of it. What takes a config entry in the SDK or a node in LangGraph takes real code here.
- No community patterns. With a framework, a Stack Overflow answer or a GitHub example might apply. With a bespoke loop, the team is on its own.
- Harder to onboard new engineers. A LangGraph graph or a Claude Agent SDK config is a known shape. A custom loop is specific to this codebase and takes time to learn.
Pick build-your-own when: the agent is simple (one or two tools), the team has strong engineers who prefer explicit code over framework magic, dependency hygiene matters, OR the agent is so unusual that no framework fits cleanly.
Decision tree — four questions
Walk through these in order:
1. Will the agent ever need to switch models (Claude → GPT, or open-weight hosted locally)? → Yes: Claude Agent SDK is out. Pick LangGraph or build-your-own. → No: all three are candidates.
2. Is the workflow longer than one tool-use round-trip, with branching, approvals, or must-survive-restart semantics? → Yes: LangGraph is the strongest fit for the state model. → No: Claude Agent SDK or build-your-own.
3. Does the team value speed-to-production over abstraction minimalism? → Yes: Claude Agent SDK (if Claude is the model) or LangGraph (if portability matters). → No: build-your-own.
4. Is the agent so unusual that no framework example resembles it? → Yes: build-your-own. Frameworks will just fight the shape. → No: pick whichever framework matches question 1-3.
Line-count reality check
Rough order-of-magnitude for a “research agent that searches and summarises” — one of the most common agent shapes:
| Framework | Approx lines | Includes |
|---|---|---|
| Claude Agent SDK | 50-100 | Agent setup, tool definitions, run loop |
| LangGraph | 150-400 | Nodes, edges, state schema, checkpointer config |
| Build-your-own | 100-300 | Loop, tool dispatch, retry, logging |
Numbers vary with how much is pulled from the framework defaults vs. explicit configuration. The gap narrows as the agent gets more complex — at a 5-tool multi-stage workflow, all three land within 50% of each other.
The hidden tradeoff nobody puts in the comparison
Comparison tables usually focus on features (MCP support, checkpointing, model support, pricing). The hidden tradeoff that matters more over 12+ months is framework drift risk.
- Claude Agent SDK evolves with Claude. New model capabilities (new tool-use modes, new context limits) land here first. But the SDK is at v0.x and API breaks have been common.
- LangGraph is stable at v1.x and conservative about breaking changes. But new model-specific capabilities land later, sometimes months after the model itself ships.
- Build-your-own has zero framework drift (you own the code), but you also do not get the “new feature for free” that landing a framework update provides.
Teams that pick for “lowest 2026 risk” tend to end up with either LangGraph (stable framework, slower feature adoption) or build-your-own (own all the drift). Teams that pick for “fastest innovation” on Claude specifically tend to end up with the Claude Agent SDK and accept the v0.x API churn.
Three failure modes to design around
1. Picking the SDK then needing to switch models. Teams that ship on the Claude Agent SDK and later get pricing or availability pressure to switch to GPT, Gemini, or an open-weight model face a full rewrite. If model portability is remotely plausible in the 12-month horizon, the SDK is the wrong pick.
2. Picking LangGraph for a one-tool-call agent. Modelling “call the search API and summarise the result” as a graph is a disproportionate amount of structure for a disproportionately simple job. The graph becomes two nodes and one edge. The Claude Agent SDK or build-your-own is lighter.
3. Picking build-your-own then adding a framework in year two. Teams start with a minimal loop, agent complexity grows, and six months in someone proposes “we should use LangGraph.” The migration cost is real. If the team can predict complexity growth, pick the framework now; if not, start simple but write the loop so the agent’s business logic is separable from the loop mechanics.
Bottom line
For Claude-committed teams who want speed to production, the Claude Agent SDK is the correct 2026 default. For teams who need model portability or deterministic state semantics, LangGraph is the correct default. For teams whose agent is simple, unusual, or dependency-sensitive, writing the loop directly is still the correct default.
The wrong pick is the one made on vibes. The question is not “which framework is best” but “which framework matches this agent’s complexity, this team’s model commitments, and this project’s 12-month evolution path.” Walk the four-question decision tree before writing the first line of agent code — it is cheaper than rewriting the agent six months later.
Related reading: