Introduction to LangChain

What is LangChain?

LangChain is an open-source framework for building LLM applications, maintained by LangChain Inc.. It packages model calls + tools + state + orchestration into a composable agent harness, so you can ship chatbots, RAG systems, and automation agents in Python (and JavaScript).

LangChain 1.0 (2025) is a major consolidation: the core focuses on the agent loop, runs on the LangGraph runtime, and adds Middleware for context engineering and control.


The ecosystem

┌─────────────────────────────────────────────────────────────┐
│                    LangChain ecosystem                       │
└─────────────────────────────────────────────────────────────┘
   ┌──────────────┐   ┌──────────────┐   ┌──────────────┐
   │  LangChain   │   │  LangGraph   │   │  LangSmith   │
   │  high-level  │   │  graph runtime│  │  trace/eval  │
   │  create_agent│   │  persistence │   │  observability│
   └──────────────┘   └──────────────┘   └──────────────┘
         │                    ▲
         └──── 1.0 built on ──┘
ComponentRoleTypical use
LangChainFastest path to agents: create_agent, tools, middlewareStandard ReAct-style agents, RAG agents
LangGraphLow-level graph engine: nodes, edges, checkpoints, interruptsComplex workflows, multi-agent orchestration
LangSmithCloud: traces, evals, monitoringDebug, regression tests, production ops

Key point: LangChain 1.0 agents run on LangGraph. Drop down to LangGraph when you need fine control; compose both (e.g. embed create_agent subgraphs in custom graphs).


LangChain 1.0 at a glance

AreaPre-1.01.0
Agent entryMany chain/agent classesUnified create_agent
RuntimeMultiple pathsLangGraph
CustomizationSubclasses, callbacksMiddleware hooks
PackagesMonolithic langchainlangchain-core + integration packages
ModelsVaried interfacesprovider:model strings + content blocks

Official framing:

Agent = Model + Harness
Harness = model + prompt + tools + middleware (right context at the right time)


Agent loop (mental model)

flowchart LR
  U[User input] --> M[Model]
  M --> T{Tools?}
  T -->|Yes| E[Run tools]
  E --> M
  T -->|No| R[Reply]
  MW[Middleware] -.-> M
  MW -.-> E

The model loops until the task is done. Middleware hooks (before_model, after_model, wrap_model_call, etc.) power summarization, memory, human-in-the-loop, and subagent delegation.


Comparison

LangChainLlamaIndexRoll your own
StrengthAgents + orchestration + integrationsIndexing / RAG data layerFull control
ProvidersHundreds of integrationsRich as wellDIY
ProductionLangGraph persistence + LangSmithOwn observabilityBuild it
Learning curveClearer entry in 1.0Fast for RAGHigh

When to choose LangChain: agents, workflows, observability in one stack. For doc-heavy RAG-only apps, LlamaIndex or plain API may suffice.


Good fit / caveats

Good fit: tool-using agents, RAG, persistent sessions, HITL, LangSmith tracing.

Watch out: one-shot prompts (use API directly), ultra-low latency (framework overhead), regional provider/compliance constraints.


Packages

PackagePurpose
langchain1.0 high-level APIs
langchain-coreMessages, Runnable, tools
langgraphGraph runtime, checkpoints
langchain-openai, langchain-anthropic, …Provider integrations

GitHub: langchain-ai/langchain, langchain-ai/langgraph


Next steps