From Aryan Vatsa | Product & Market Analysis
LangChain vs LlamaIndex vs Writing It Yourself: What Abstraction Costs
On this page
The langchain package recorded 254.5 million downloads in the month to 27 August 2026. In the same window OpenAI's own agents SDK recorded 39.7 million and llama-index-core recorded 14.6 million. LangChain vs LlamaIndex is now the wrong question to open with. The real decision is how much abstraction between your code and the model you are willing to own for the next two years.
Key takeaways
- The choice has split into two layers, and only one of them is contested. Durable execution, checkpointing and tracing are worth importing. Prompt assembly and control flow are what production teams keep taking back.
- The model providers now ship the competing layer themselves. The openai-agents package pulled 39.7 million downloads last month, 2.7 times llama-index-core's 14.6 million, from a repository that did not exist before March 2025.
- Quality, not cost, is the top blocker to shipping agents. 33% of 1,340 practitioners surveyed by LangChain named it, against 20% for latency. That is an argument against anything that hides the prompt.
- LangChain agrees with a large part of the critique. Version 1.0 moved LLMChain, the legacy retrievers and the indexing API out of the main package and into langchain-classic.
What the three options actually are
Most comparisons treat this as a three-way pick between two libraries and a blank file. That framing is out of date, because all three options have moved since 2024 and two of them have moved toward each other.
LangChain is two products, and the distinction matters
LangChain today ships a high-level agent constructor and a lower-level orchestration runtime called LangGraph. Harrison Chase, the company's co-founder, drew that line himself in April 2025. He described LangGraph as an orchestration framework with a series of agent abstractions built on top, and argued that the hard part of reliability is controlling what reaches the model at each step.
That is a more careful position than the marketing suggests. It also concedes the central point of the critics, which is that agent abstractions are the risky layer and orchestration is the useful one.
LlamaIndex is a retrieval framework with an agent layer added later
LlamaIndex started as an indexing and retrieval library and still leads with document work. Its own agent story arrived as Workflows, released as version 1.0 on 30 June 2025 by Massimiliano Pippi and Logan Markewich. They shipped it as a separate package with a limited set of dependencies, usable outside the LlamaIndex ecosystem entirely.
Read that decision carefully. The company that owns the framework chose to unbundle its orchestration layer from its retrieval layer, because developers wanted the flow control without the rest.
The third option is not zero abstraction
Nobody serious writes raw HTTP calls to a model endpoint. Writing it yourself means importing the provider SDK, a validation library and a queue, then owning the loop that sits between them. Anthropic put this plainly in December 2024, saying developers should start by using LLM APIs directly because many patterns take only a few lines of code.
The download numbers say the default has already moved
Package downloads are the only continuously published adoption signal in this market, so they are worth reading even with their flaws. Here is what they said on the morning this was written.
Three readings hold up. LangChain remains the distribution leader by a wide margin and nothing in this post disputes that. LangGraph at 70.3 million is closing on a third of the main package, which is consistent with teams importing the runtime and skipping the agent wrapper. And openai-agents, from a repository created on 11 March 2025 and now carrying 28,985 stars, has passed both LlamaIndex packages combined.
Downloads are not users, and the gap is large. Every figure above counts machines, not people. A single continuous integration pipeline can install a package hundreds of times a week, and container image builds inflate popular packages more than niche ones. Absolute values are therefore close to meaningless.
Ratios between packages of similar popularity are more defensible, because the CI distortion applies to both sides. That is why the comparison to watch here is openai-agents against llama-index-core, and not any single number on its own.
| Project | Monthly PyPI downloads | GitHub stars | Open issues |
|---|---|---|---|
| langchain | 254,529,872 | 145,082 | 430 |
| langgraph | 70,260,618 | Tracked in a separate repository | Not comparable |
| openai-agents | 39,718,829 | 28,985 | 44 |
| llama-index-core | 14,614,344 | 51,884 | 682 |
Downloads from pypistats.org, stars and issue counts from the GitHub API, both retrieved 27 August 2026. Star counts are cumulative since repository creation and reward age, so LlamaIndex leading OpenAI on stars while trailing on downloads is expected rather than contradictory.
Where a framework genuinely earns its place
The strongest case for importing a framework has nothing to do with saving keystrokes on a prompt. It is about the machinery that surrounds a long-running process.
Durable execution is the honest one. If an agent runs for 40 minutes across a dozen tool calls, it will be interrupted by a deploy, a rate limit or a timeout. Recovering from step nine without replaying steps one to eight is real distributed-systems work. Chase makes this argument directly, noting that features like human-on-the-loop review and model-specific observability are awkward to build alone.
I would extend it to two more cases. Teams running many similar agents benefit from one shared runtime rather than five hand-rolled loops that drift apart. And teams with a compliance obligation to replay a decision need checkpointing that someone else maintains and tests.
What none of these cases require is the agent constructor. You can import the runtime and keep your own control flow, which is exactly the split the download figures suggest is happening. If you are choosing between a framework and a hosted product rather than between two libraries, the trade-offs are laid out in the piece on when to build coding agents rather than buy them.
The abstraction cost, itemised
Frameworks are usually evaluated on what they add. The costs are less visible because they arrive later, after the person who chose the framework has moved to another project.
Debugging happens through a wrapper
Anthropic's guidance names this failure precisely. Frameworks often create extra layers of abstraction that can obscure the underlying prompts and responses, making them harder to debug. The same document warns that incorrect assumptions about what sits under the hood are a common source of customer error.
This is the cost that compounds. When output quality drops, the first question is always what text the model actually received. If answering it means reading library source, every quality investigation gets slower, and quality is the blocker 33% of practitioners named.
Version churn is a real maintenance line
LangChain reached 1.0 on 22 October 2025 and the release was not cosmetic. LLMChain, ConversationChain, MultiQueryRetriever, the indexing API, the hub module and the community re-exports all moved into a separate langchain-classic package. Objects already marked deprecated were deleted outright.
That was the right call for the library and it was still a migration someone had to schedule. Any framework you adopt is a bet that its maintainers will keep making decisions you can live with, and you have no vote.
Provider abstraction has a shelf life
The most-cited reason to adopt a framework is portability across model providers. I think this is the weakest argument on the list. Provider APIs have converged on tool calling and structured output, so the switching work has shrunk on its own, and the parts that have not converged are the parts frameworks normalise least well.
Reasoning traces, prompt caching semantics, citation objects and server-side tools still differ in ways that leak. A normalisation layer that covers 90% of a provider's surface leaves you writing provider-specific code anyway, on top of the abstraction rather than instead of it.
The 80% wall is a scheduling problem, not a quality problem
The most useful description of what goes wrong comes from Dex Horthy's 12-factor agents, a document with 25,511 stars on GitHub. His account of the failure is a sequence, not a verdict. A team adopts a framework, moves quickly, reaches roughly 70% to 80% quality, then discovers that the last stretch requires control the framework does not expose.
His second observation matters more for architecture. Most products marketed as agents are, in his words, mostly deterministic code, with LLM steps sprinkled in at just the right points. If that is true, the majority of an agent codebase is ordinary software that a framework was never needed for.
The commercial version of this problem is worse than the technical one. The wall is hit near launch, when the team is least able to spend three weeks on an architectural rewrite. Frameworks do not cause bad agents. They move the cost of the decision to the worst possible week.
The counter-discipline is to find your ceiling before you commit, which is what a real readiness test does. The checks worth running are set out in the piece on the tests a proof of concept has to survive.
What writing it yourself means in 2026
The phrase sounds heroic and describes something fairly boring. A thin custom layer is a few hundred lines that most teams could review in an afternoon.
You keep the imports that do genuinely hard things. The provider SDK, because it handles streaming, retries and transport. A schema library for tool arguments. A retrieval library if you are doing document work, and LlamaIndex is a reasonable answer there. A queue or workflow engine if runs are long. An observability layer, because agents drift in production in ways offline tests never show.
You write the parts that encode your product. The loop that decides when to call a tool. The message list, in a shape you chose. The tool dispatch table. The error compaction that turns a stack trace into something a model can act on. The place where a human approves an action, which is a product decision before it is an engineering one, as the piece on designing the human review step argues.
| Option | Strongest use | What it costs you | Where it clearly wins |
|---|---|---|---|
| LangChain and LangGraph | Long-running stateful agents needing checkpointing, replay and review gates | Debugging through a wrapper, migration work at major versions, a large dependency surface | Multiple agents sharing one runtime, and teams that need durable execution before they need control |
| LlamaIndex | Document-heavy retrieval, parsing and indexing over messy enterprise files | An agent layer that arrived later, and a smaller ecosystem to hire against | Retrieval quality on real documents, which is still the thing it is best at |
| Thin custom layer | A single agent whose behaviour is the product | You maintain the loop, the retries and the state machine, forever | Anything where the last 20% of quality decides whether it ships |
A test you can run before the architecture is fixed
Arguments about frameworks go in circles because both sides are describing different projects. These four questions separate them. Answer them about your project, not about the category.
| Question | What a yes means |
|---|---|
| Can you print the exact string sent to the model at every step, without reading library source? | If no, your quality investigations will run slow for the life of the project. |
| Does a run last longer than one request cycle, or survive a deploy? | If yes, import a runtime. Do not write checkpointing yourself. |
| Is your orchestration logic under roughly 500 lines? | If yes, a framework is adding more surface than it removes. |
| Would switching model providers next quarter be a business decision or an engineering one? | If it is engineering only, portability is not worth an abstraction layer. |
My own rule sits in the third row. Below about 500 lines of orchestration, I would not start a new agent on a framework's agent abstraction in 2026. Above it, and with long-running state, I would import the orchestration runtime and still write my own control flow on top. That is not a compromise position, it is the split the two camps already agree on once you separate the layers. Where several agents have to coordinate, the tooling landscape is mapped in the review of agent orchestration and automation tools.
Where this argument is weakest
Every post arguing that frameworks are overrated skips this part, so here it is.
The case for the framework, put fairly
LangChain is not a hobby project losing an argument. It raised $125 million at a $1.25 billion valuation on 20 October 2025, led by IVP, and reported 90 million combined monthly downloads for LangChain and LangGraph alongside use at 35% of the Fortune 500. LangSmith trace volume was reported at 12 times the prior year. Those are the numbers of a tool doing real production work.
There is also a survivorship problem in the critique. The teams who write blog posts about removing a framework are the teams whose requirements outgrew it. The much larger group whose requirements did not outgrow it writes nothing, because a project that shipped on time is not a story.
What the framework sceptics get wrong
The rewrite is not free and it is usually costed at zero. A hand-rolled loop that a senior engineer wrote in a week becomes a load-bearing internal framework within six months, with no documentation, no external maintainers and one person who understands it. That is a real risk transferred, not a risk removed.
Sceptics also overstate how much of a framework you must adopt. Importing LangGraph for durable execution while writing your own prompts is a supported pattern, not a hack, and it collects most of the benefit at a fraction of the abstraction.
The part nobody can settle
There is no public dataset comparing defect rates, delivery time or cost between framework-based and custom agent codebases. The download figures here measure distribution, not outcomes. The 80% wall rests on practitioner accounts rather than measurement, and practitioner accounts are selected for drama.
So treat every claim in this post as a prior to test against your own project rather than a finding. The right response is a measurement, and the way to build one is covered in the piece on standing up an evaluation suite you can trust.
Frequently asked questions
Is LangChain or LlamaIndex better for RAG?
LlamaIndex was built for retrieval and indexing first, and that remains its strongest area, particularly parsing and querying messy document sets. LangChain covers retrieval as one capability among many inside a broader agent framework. Many production teams use LlamaIndex for the retrieval layer and something else for orchestration, which is a reasonable split because the two jobs have different failure modes and different debugging needs.
Should I use a framework or build my own AI agent?
Start by separating orchestration from agent abstraction. If your runs are long, survive deploys or need replay, import an orchestration runtime rather than writing checkpointing yourself. If your orchestration logic is small and behaviour quality decides whether the product ships, write the loop yourself over the provider SDK. Anthropic's published guidance is to begin with the API directly and add complexity only when it demonstrably helps.
Why do developers stop using LangChain in production?
The recurring complaint is visibility. Abstraction layers make it harder to see the exact prompt and response, which slows down quality work, and quality was named the top production blocker by 33% of practitioners in LangChain's own 2026 survey. Migration cost is the second complaint. Version 1.0 moved LLMChain, legacy retrievers and the indexing API into a separate langchain-classic package in October 2025.
What is the difference between LangChain and LangGraph?
LangChain is the higher-level library, including a standard agent constructor, model integrations and message types. LangGraph is the lower-level orchestration runtime underneath it, handling state, checkpointing and durable execution. Harrison Chase has described LangGraph as an orchestration framework with agent abstractions built on top. You can import LangGraph and write your own control flow without adopting the agent abstraction.
How much code does it take to build an agent without a framework?
No credible measured figure exists, because scope varies enormously between projects. Structurally you own four things: a loop, a tool dispatch table, a message list and error handling. Anthropic's guidance states that many agent patterns take only a few lines of code against the API directly. The maintenance cost lands later, in retries, state and observability, rather than in the initial loop.
Is LlamaIndex still worth using in 2026?
For document retrieval, yes. The caution is scale of ecosystem rather than quality. In the month to 27 August 2026, llama-index-core recorded 14.6 million PyPI downloads against 39.7 million for OpenAI's agents SDK and 254.5 million for langchain. Smaller ecosystems mean fewer worked examples and a shallower hiring pool, which is a real operational cost even when the library is the better technical fit.
Where to start this week
Two things, both doable before your next planning meeting.
First, add one line of logging to your existing agent that writes the exact payload sent to the model on every call, then read a day of it. If getting that line to work is hard, you have measured your abstraction cost directly and you did not need an opinion to do it.
Second, count the lines in your orchestration path, excluding tools and prompts. If the number is under a few hundred, the framework in your dependency list is carrying less weight than the migration you will owe it. If the number is large and the runs are long, keep the runtime and take back the control flow.
Related on the build decision
If the question is a tool rather than a library, read the build versus buy case for coding agents. If it is how your agent talks to everything else, read the state of MCP as an interoperability standard.
References
- Anthropic, Building Effective AI Agents, 19 December 2024. Used for the guidance to start with the API directly and for the abstraction and debugging quotes.
- Harrison Chase, LangChain, How to think about agent frameworks, 20 April 2025. Used for the orchestration versus agent abstraction distinction and the context argument.
- LangChain, LangChain raises $125M to build the platform for agent engineering, 20 October 2025. Used for the funding, valuation, 90 million combined downloads, Fortune 500 share and LangSmith trace growth.
- LangChain, LangChain v1 migration guide, accessed 27 August 2026. Used for what moved into langchain-classic and for the deletion of deprecated objects.
- LangChain, State of AI Agents, published 12 June 2026. 1,340 responses collected 18 November to 2 December 2025. Used for the 57% production figure and the quality and latency blockers.
- Massimiliano Pippi and Logan Markewich, LlamaIndex, Announcing Workflows 1.0, 30 June 2025. Used for the dependency and control of execution flow statements.
- Dex Horthy, HumanLayer, 12-factor agents, repository created 30 March 2025. Used for the 70% to 80% quality wall and the deterministic code observation.
- pypistats.org, PyPI download statistics, retrieved 27 August 2026. Used for every download figure. GitHub API used for star, fork and issue counts on the same date.
The weakest thing about this source base is that no independent survey measures how many production teams use frameworks against custom layers. The direction of travel here is inferred from package downloads, which count machines rather than people, and from practitioner writing, which is selected for teams whose requirements outgrew a framework. The quality-versus-effort chart is illustrative and shows a relationship, not measured data. The adoption survey cited is published by one of the vendors under discussion, and 63% of its respondents work in technology.
Related reading