LangChain
Type: full-code · Vendor: LangChain Inc. · Language: Python, TypeScript · License: MIT · Status: active · Status in practice: mature · First released: 2022
Provide a standard, model-agnostic Python/TypeScript interface plus a prebuilt agent (create_agent) for building LLM applications that loop over tool calls in the ReAct shape, with first-class integrations for retrieval, structured output, MCP tools, and middleware-based human approval.
Description. LangChain is the MIT-licensed agent and LLM-application framework built by LangChain Inc., the same company that ships LangGraph and LangSmith. In its 1.x form the headline surface is create_agent, a prebuilt agent that runs a chat model in a ReAct loop over a developer-supplied list of tools, stopping when the model emits a final answer or an iteration limit is reached. The framework ships standard integrations for models, embeddings, vector stores, retrievers, MCP servers, and content-block citations; orchestration concerns beyond the loop (durable state, interrupts, multi-agent graphs) are delegated to LangGraph, which create_agent compiles down to internally.
Agent loop shape. ReAct tool-calling loop. The model is bound to a tool list; runtime alternates model-emit-tool-calls and tool-execute steps, and stops on final-answer-or-iteration-limit. Middleware hooks run before/after model and tool calls inside the compiled LangGraph that create_agent returns.
Primary use cases
- ReAct-shape agents calling provider-agnostic models and tools
- RAG via retrievers + cross-encoder reranking + EnsembleRetriever
- structured-output agents with ProviderStrategy / ToolStrategy
- MCP-tool integration via langchain-mcp-adapters
Key concepts
- create_agent → react (docs) — Prebuilt ReAct-style agent constructor that binds a model to a tool list and loops.
- Tool / @tool → tool-use (docs) — Callable functions with well-defined inputs and outputs passed to a chat model.
- response_format (structured output) → structured-output (docs) — Schema-driven structured output via ProviderStrategy (native) or ToolStrategy (tool-call emulation).
- Middleware (docs) — Hooks running inside the compiled LangGraph that create_agent returns; used for HITL, summarization, custom guards.
- Retriever (docs) — Interface returning documents given an unstructured query; integrations for many vector stores, BM25, Pinecone Hybrid Search, etc.
- RunnableWithFallbacks (.with_fallbacks) → fallback-chain (docs) — Runnable that falls back to other Runnables on failure; fallbacks tried in order.
Patterns this full-code implements —
- ★★Agentic RAG
RAG is documented as 'a simple agent with a tool that retrieves information' — the model decides when to call the retrieval tool, mirroring the agentic-RAG shape.
- ★★Cross-Encoder Reranking
CrossEncoderReranker wraps a HuggingFace cross-encoder and plugs into ContextualCompressionRetriever.
- ★★Fallback Chain
RunnableWithFallbacks (or .with_fallbacks()) is a documented core abstraction; fallbacks are tried in order until one succeeds.
- ★★Model Context Protocol
First-class MCP integration via langchain-mcp-adapters and MultiServerMCPClient.
- ★★Query Rewriting
LangChain ships MultiQueryRetriever as the canonical Query Rewriting implementation: an LLM generates N variants of the user query, retrieval runs per variant, results are unioned and deduplicated. D…
- ★★ReAct
create_agent IS the prebuilt ReAct constructor.
- ★★Session Isolation
Threads scope short-term memory; storing state in graph state maintains separation between threads.
- ★★Structured Output
response_format with ProviderStrategy (native) or ToolStrategy (tool-call emulation). As of LangChain 1.0, passing a schema defaults to ProviderStrategy and falls back to ToolStrategy.
- ★★Tool Use
Tools are the primary extension point; @tool decorator + model.bind_tools(...).
- ★★Hybrid Search
EnsembleRetriever (langchain_classic) combines multiple retrievers via weighted Reciprocal Rank Fusion; BM25Retriever (langchain-community) provides keyword search alongside vector retrieval.
- ★★Plan-and-Execute
Documented in LangChain Inc.'s blog rather than the docs proper; concrete implementations live in langgraph examples. Downgraded from first-class.
- ★★Step Budget
Agents stop on final-answer-or-iteration-limit but no current docs page names the iteration-limit parameter; recursion_limit is a LangGraph concept. Downgraded from first-class.
- ★★Approval Queue
Human-in-the-Loop middleware uses LangGraph's interrupt + checkpointer underneath; halts execution and saves state. Limited because the durability comes from LangGraph, not LangChain proper.
- ★★Chain of Thought
Not a dedicated CoT API; reasoning is exposed as 'reasoning' content blocks during streaming. The ReAct loop interleaves reasoning steps with tool calls.
- ★★Citation Streaming
Citation is a typed content-block annotation; streaming surfaces content blocks but there is no dedicated 'citation streaming' mode named in docs.
- ★★Context Window Packing
Short-term-memory docs name the problem and offer SummarizationMiddleware + token trimming as the answer.
- ★Handoff
Agents transfer control via tool calls (Command(goto=...) is a LangGraph primitive re-exported by LangChain).
- ★★Self-Refine
Reflection agents are blog-only; no dedicated docs page in current LangChain.
- ★Skill Library
Skills live primarily in Deep Agents (a higher-level harness built on LangChain), not core LangChain.
- ★Contextual Retrieval
No canonical LangChain docs page for Anthropic's Contextual Retrieval technique; usable only as a recipe via custom embedding-time chunking. Downgraded from limited to via-integration. No verbatim up…
- ★★Supervisor
Closest core-LangChain concept is the Router (LLM picks among agents and invokes in parallel). The supervisor pattern is documented as a multi-agent architecture with a central supervisor coordinatin…
Neighbourhood
Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.