LangChain

agent framework · by LangChain · official site

What it does

LangChain is a framework for composing applications that rely on large language models (LLMs). It provides abstractions for prompts, chains, agents, tools, memory, retrievers, and callbacks. The core library is Python and TypeScript, with integrations for most major LLM providers, vector stores, and data sources. The “agent” functionality—where an LLM decides which tool to call and in what order—is built on top of this stack, historically via AgentExecutor and more recently through LangGraph for stateful, cyclic workflows.

LangChain does not run models itself; it orchestrates calls. The framework handles prompt templating, input/output parsing, tool selection loops, and error recovery. LangGraph extends this into directed graphs with cycles, enabling multi-step agents that can maintain state across turns.

Who it's for

LangChain targets developers who need to stitch together multiple LLM calls, external APIs, and databases into a single application. It suits teams that want rapid prototyping of complex pipelines—RAG with query rewriting, multi-step reasoning, tool-using agents. It is also used in exploratory research where the exact architecture is unknown and frequent iteration is expected.

LangChain is not for:

What works

Prototyping speed. The library has built-in integrations for dozens of services. Switching from OpenAI to Anthropic, or from Pinecone to Chroma, often means changing a single import line. For quick proof-of-concepts, this friction reduction is real. LangGraph for agents. The graph-based approach to agent logic is an improvement over the original AgentExecutor. It gives explicit control over state, conditional edges, and human-in-the-loop pauses. For non-trivial agent loops—web scraping, multi-turn reasoning—LangGraph works reliably once the graph is correctly defined. Observability with LangSmith. LangSmith provides trace logging, latency breakdowns, token usage tracking, and dataset evaluation. It solves the black-box problem inherent in chained LLM calls. In production, LangSmith is often the only way to understand why an agent failed. Memory abstractions. The buffer, summary, and vector-based memory implementations are useful for conversational agents that need to remember context across sessions. They work as advertised, though the cost of re-summarizing long conversations can catch teams off guard.

What breaks

Versioning churn. Between versions 0.1.x and 0.3.x (and the later shift to LangGraph as the primary agent layer), breaking changes were frequent. Integrations, prompt templates, even the base ChatOpenAI class altered signatures. Teams that pinned versions still faced deprecation warnings and had to rewrite significant sections when upgrading. By 2026, stability has improved—the API is more settled—but legacy codebases often require migration. Debugging implicit chains. When an agent fails, the root cause can be buried: was the prompt malformed? Did the tool return an error that the LLM misread? Did a chain produce a badly formatted intermediate output? LangSmith helps, but many failures are nondeterministic and hard to reproduce. Latency and cost surprise. Each step in a chain or agent loop makes a full round trip to the LLM. A five-step agent can cost five times the input/output tokens of a single call. Latency adds up accordingly. LangChain does not expose cost estimation upfront; teams often discover the budget impact during load testing. Tool call reliability. LLMs frequently hallucinate tool arguments or fail to follow formatting instructions, even with strict schema enforcement. LangChain’s parser and fallback logic helps, but in production, tool call failure rates of 5–15% are common unless the LLM is fine-tuned or heavily prompted.

Pricing reality

LangChain itself is open source (MIT license). The cost comes from:

No exact figures are available because LangChain’s pricing page redirects to a sales form for custom quotes. The free tiers are adequate for small projects; scaling up requires a budget commitment that may rival the LLM API bill itself.

Honest comparison

Compared to building agents with raw SDK calls and manual tool orchestration, LangChain provides a higher-level API but adds a dependency with its own learning curve. For simple agents (one tool, single step), the overhead is rarely justified.

CrewAI focuses on role-based multi-agent teams with predefined collaboration patterns. It sits at a higher abstraction level than LangChain. If your use case is exactly a crew of specialized agents, CrewAI may be simpler; if you need custom graph logic, LangGraph is more flexible. AutoGPT offered a different paradigm (autonomous task decomposition) but by 2026 has largely been surpassed by graph-based frameworks like LangGraph and Microsoft’s AutoGen. LangChain is more mature in terms of production tooling (LangSmith, caching, cost tracking). LlamaIndex is the primary competitor for RAG workflows. It provides more out-of-the-box indexing, chunking, and query engines. For pure RAG, LlamaIndex often requires less code. For agentic RAG (agents that decide to query or not), LangChain plus LangGraph is the stronger choice.

When to use

Use LangChain when:

Avoid LangChain when: LangChain delivers on its promise for prototyping. For production, the real cost is not the library itself but the engineering time spent debugging, optimizing, and upgrading. It remains a solid choice for teams that need a flexible agent framework and can invest in the surrounding tooling. For simpler needs, the overhead is not worth it.

Last verified: 2026-06-08 by kernel.