LangChain

From PRIMO.ai
Jump to navigation Jump to search

YouTube ... Quora ...Google search ...Google News ...Bing News


LangChain is an open-source framework for building applications and agents around language models, tools, and external information. It provides a configurable agent loop and integrations in Python and JavaScript. Typical uses include document-grounded answers, research, customer support, coding assistance, and workflows that read from or act through connected services. It isn't a model, and installing the library doesn't by itself give an agent access to a company's systems.

The ecosystem now separates several jobs that were once discussed under the single LangChain name. LangChain provides framework primitives and the agent loop; LangGraph supplies explicit workflow control and persistence; Deep Agents adds a more complete harness for extended work. LangSmith provides development and operational services, including tracing, evaluation, and deployment. Managed Deep Agents and LangSmith Fleet offer additional ways to deploy or build agents, with different levels of coding and infrastructure responsibility.

Recent advances focus on running agents beyond a single chat: managing growing context, using skills and files, retaining state, pausing for review, responding to events, and measuring behavior after deployment. The practical benefit is a more repeatable process for work that crosses several tools. The limits remain concrete: a checkpoint doesn't validate a fact, a trace doesn't prove a result is correct, and a shared agent still needs an owner, scoped credentials, and a clear definition of completion.

Reviewed November 23, 2026. Product status, naming, and examples below follow current primary documentation. Managed Deep Agents is described as a public beta; internal application examples aren't independent guarantees of productivity or ready-made replacements for your own systems.


🔗 Explore the LangChain ecosystem
Distinguish LangChain, LangGraph, Deep Agents, and LangSmith.
Understand managed runtimes, middleware, and agent operations.
Compare managed services, team builders, and concrete applications.
Read about nodes, edges, checkpoints, and recovery limits.
Connect sources, artifacts, review, and verified publishing.
Check quality, authority, data handling, and total cost.
Select a large label to jump to its section.

Choose the Right Layer

LangChain's current open-source stack distinguishes a runtime, a framework, and a harness. These are composable choices, rather than a mandatory ladder every project must climb. A direct model call or a simple retrieval pipeline may be sufficient for a small task; use additional machinery when it solves a specific control, context, or operational need. LangChain open-source stack · LangChain · LangGraph · Deep Agents

Component Role Choose it when
LangChain Model and tool abstractions, integrations, create_agent, and middleware around the model/tool loop. You want a configurable agent with explicit tools and controls, or shared interfaces for model-based application components.
LangGraph Low-level orchestration with explicit state and control flow, persistence, interrupts, and fault-tolerance mechanisms. You need custom branching, deterministic steps, long-running state, or recovery behavior beyond a standard loop. It doesn't require using LangChain for every model call.
Deep Agents A higher-level harness using LangChain and LangGraph, with context management, filesystem abstractions, skills, and delegation capabilities. You want extended, multi-step work without assembling every harness component yourself. Configure the environment and tools for the job.
LangSmith Services for tracing, evaluation, development, deployment, and operational oversight; it can also observe agents built with other frameworks. You need to inspect runs, compare changes, and manage production behavior. Select the services your project needs rather than treating a commercial platform as a requirement of the open-source libraries.


🧩 Three building layers, with operations alongside
Deep Agents: harness
Uses the framework and runtime underneath, adding defaults for context, files, skills, and extended work.
LangChain: framework
Provides the configurable agent loop, integrations, and middleware that shapes model and tool behavior.
LangGraph: runtime
Supports explicit state and routing, checkpoints, interrupts, and controlled recovery.
Composition: Deep Agents → LangChain → LangGraph. LangSmith traces, evaluates, and supports operations across these choices.

Recent Advances and Practical Impacts

Advance Current primary evidence Practical impact and limit
A configurable core agent loop Current LangChain documentation centers on create_agent, composing models, tools, prompts, and middleware. Overview Less custom loop code. Provider adapters reduce integration work, but changing models still requires checking tool behavior, structured output, and quality.
Review attached to the actual proposed tool call Human-in-the-loop middleware checks configured tool policies and pauses for decisions before execution. Documentation A person can inspect, approve, edit, or reject a concrete action. Approval policy and persistence must be configured; it isn't a blanket protection supplied by a prompt.
Managed extended work A November 2 update describes Managed Deep Agents as a public beta on LangSmith Cloud, with project-based instructions, tools, and skills, and managed runtime services. Announcement and update Reduces infrastructure work for hosted agents. Teams still own the task design, connected permissions, review process, and evaluation.
Agent records connect development and operations LangChain's November 16 LangSmith update describes agent records with owners, immutable IDs, types, environments, traces, and evaluations. Product update Makes it easier to locate an owner and compare behavior across environments. Trace collection must be configured, and operational visibility doesn't establish that an action was authorized or correct.
Event-driven applications replace some ad hoc prompting LangChain's November 17 account describes internal agents responding to events and schedules, including GTM Agent and Robin, formerly Open SWE. Application report Can handle recurring monitoring and preparation. A useful implementation needs relevant context, restrained notifications, a stop control, and review of consequential output.


Current Products and Application Examples

The first three entries are platform offerings. The last three are applications described by LangChain's own engineering team. The internal examples show implementation patterns; they shouldn't be read as universally available turnkey apps or independent evidence of a particular return on investment.

Product or application What it does Why it matters and what to evaluate
LangSmith Fleet Formerly LangSmith Agent Builder; provides a team workspace for creating, sharing, and managing agents, with permissions, credentials, and review of activity. Useful for teams seeking a more guided building experience. Distinguish permission to run an agent from permission to edit it, and user-specific credentials from shared service credentials.
Managed Deep Agents Runs the Deep Agents harness and production runtime on LangSmith Cloud; the updated announcement calls it public beta. Useful for developers who want a managed deployment path. Compare the managed service with running the open-source SDK yourself, including persistence, sandbox needs, pricing, and operational responsibility.
LangSmith Agent Platform and Engine Connects agent records with traces, evaluations, deployments, and issue analysis; Engine can propose fixes based on observed runs. Helps investigate regressions and compare a candidate change. Review proposed fixes and test them on held-out cases; generated recommendations aren't proof of improvement.
Robin, formerly Open SWE LangChain describes its internal engineering agent drafting pull requests and reviewing new ones, built on Managed Deep Agents. Illustrates event-driven engineering assistance. Evaluate repository scope, execution isolation, tests, review quality, and change approval before applying the pattern elsewhere.
Content Studio An internally developed, open-sourced design agent that creates assets from a Slack conversation, using a sandbox, design guidance, and a collaborative review experience. Shows how brand context, tools, and review shape output. Its October 27 implementation report describes adaptation work, not an assurance that a fork immediately matches your organization's design standards.
GTM Agent Researches leads and account context, prepares outreach, and presents a Slack draft for a salesperson's approval. Shows a workflow that joins multiple sources and checks contact history before outreach. Keep claims, recipients, and the final message under review; the provider's reported business results aren't a controlled comparison for another company.


From Linear Chains to Stateful Agent Graphs (2024–2026)

LangChain began with composition of prompts, model calls, and other application components. The current stack also supports repeated model/tool loops and explicit graphs with branching and review. A linear retrieval or summarization pipeline can still be appropriate; additional orchestration is useful when the task needs state, recovery, or custom control flow.

LangGraph

LangGraph is an open-source orchestration framework and runtime for stateful agents and workflows. It supports single-agent and multi-agent designs, deterministic steps, branching, and cycles. Applications define how tools, state, persistence, and review fit together; the framework doesn't make an agent's conclusions correct or its tools automatically authorized. LangGraph overview

Core Concept: Moving Beyond Linear Chains

Early LLM architectures treated workflows like a factory assembly line: prompt goes into Step A, output moves to Step B, and Step C delivers the final answer. That linear approach works well for simple tasks like document summarization or basic retrieval-augmented generation (RAG).

However, real-world reasoning rarely moves in a straight line. Think of an experienced chess player: they consider a move, evaluate the board, realize a flaw three steps ahead, rethink their strategy, and try another angle before committing. LangGraph models workflows as cyclical graphs rather than one-way pipes, giving agents the room to review their work, execute tools, catch errors, and try again until they reach a solid answer.

Architectural Foundations

LangGraph workflows center on three core primitives:

1. State

State serves as the central blackboard or shared memory for the application. It is represented as a structured schema (typically a Python TypedDict or Pydantic model).

Every node reads from this state and writes back updates. Instead of overwriting everything, LangGraph uses reducers to determine how updates are merged (for example, appending new messages to an existing conversation history rather than replacing it).

2. Nodes

Nodes are the workers in the system. A node is simply a Python function or callable that accepts the current state, performs an action, and returns an updated state dictionary.

A node can be:

  • An LLM call (generating reasoning or deciding which tool to call)
  • A Python function (querying a database or calculating numbers)
  • A tool execution (searching an API or reading a file)
  • A nested subgraph (delegating a complex subtask to another specialized team of agents)

3. Edges

Edges define how control flows from one node to the next:

  • Normal Edges: Direct paths where Node A always leads straight to Node B.
  • Conditional Edges: Dynamic decision points where an edge calls a routing function to decide the next destination. For instance, if an LLM decides it needs more data, the edge routes to a tool node. If the answer is complete, it routes to the final output node.
  • Cycles: Edges that point backward to previous nodes, allowing loops for retries, validation checks, and iterative refinement.


Persistence and Recovery: What Is Actually Saved?

LangGraph distinguishes thread checkpoints from a store for cross-thread information. A checkpointer saves graph state for continuation and review; a store holds application-defined data such as preferences or shared knowledge. RAM-backed examples such as InMemorySaver lose their state when the process restarts. Use a suitable durable backend when restart recovery is a requirement. Persistence documentation


💾 Keep three kinds of state distinct
Thread checkpoint
Messages, pending work, and graph state for a particular conversation or run.
Cross-thread store
Preferences and knowledge retained across conversations, with explicit scope and access controls.
External result
The actual ticket, sent message, database record, or artifact created by a tool. Confirm it in the destination system.
A saved checkpoint doesn't make the external action exactly-once. An absent local result can mean the outcome is unknown.

Fault tolerance also requires handling side effects. If a tool creates a ticket and the acknowledgement is lost, retrying the node can create another ticket. Use stable operation identifiers and provider-supported idempotency where available, and query the destination before repeating an uncertain write. LangGraph's current fault-tolerance documentation explicitly separates retry mechanisms from the external service's guarantees. Fault-tolerance documentation

Key Capabilities

Capability How It Works Practical Example
State Persistence & Checkpointing Uses a configured checkpointer to save thread state; restart durability depends on its backend and durability settings. A run resumes from persisted state after an interruption. Work within a retry boundary can repeat, so external side effects need deduplication and reconciliation.
Human-in-the-Loop (HITL) Interrupts execution before or after specified nodes, awaiting external input or approval. An agent drafts an email or prepares a financial transfer, pauses for user sign-off, and resumes once approved.
Time Travel & State Editing Inspects, rewinds, and edits state at any historical checkpoint. A developer rewinds an agent run to step 3, modifies a variable to fix a prompt drift, and forks execution to test an alternative path.
Multi-Agent Topologies Coordinates distinct agents with independent prompts, tools, and subgraphs. A "supervisor" agent routes user tickets between specialized "coder", "tester", and "researcher" agents.

Architectural Comparison

Framework Primary Mental Model Best Suited For Trade-offs
LangGraph State machines and cyclic graphs Precise, production-grade agentic workflows with strict routing and persistence Higher learning curve; requires explicit state and routing definitions
CrewAI Role-playing teams with conversational handoffs Rapid prototyping of collaborative agent teams with high-level abstractions Less granular control over exact execution loops and deterministic branching
AutoGen Conversational event loops between agents Conversational multi-agent simulations and emergent collaboration Can be harder to enforce strict deterministic business logic

When to Use LangGraph

LangGraph is best suited for systems that require:

  • Self-correction: Such as a code-generation agent that writes code, runs unit tests in a sandbox, catches syntax errors, and loops back to fix its own mistakes.
  • Strict compliance and governance: Where business logic dictates that an agent cannot take an irreversible action without human approval.
  • Multi-step persistence: Workflows that run over minutes, hours, or days, surviving server reboots without losing context.


Worked Example: A Shared Project Research Agent

Suppose a project team wants a weekly brief from approved documents, issue records, and current public sources. Define the audience and completion standard first: a dated brief with checked claims, source links, unresolved questions, and a saved version in the team's agreed location. The agent should distinguish proposals from decisions and avoid interpreting an old note as a current instruction.


📑 From project sources to a reviewed brief
1. Scope and retrieve
Use approved sources and the invoking user’s access. Record source versions, dates, and missing coverage.
2. Prepare an artifact
Create the brief with claim-level support, explicit uncertainty, and a list of changes since the last version.
3. Review and decide
Check facts and audience. Pause before external publication or another action requiring approval; a rejected proposal returns for revision.
4. Save and verify
Store the approved version, confirm the destination record, and update the run status and next scheduled task if authorized.
Scope → prepare → review → verified output. Retrieval gaps return to research; rejected changes return to revision.

LangChain can provide the model-and-tool loop for the research, LangGraph can encode a mandatory review branch, and Deep Agents can supply a harness for extended work with files and context. LangSmith can trace the run and compare later changes. This is an illustrative design; using every component isn't required. An existing assistant or a simple workflow may meet the team's needs with less maintenance.

Design decision Practical rule
Shared context Keep authoritative documents and decisions in the team's source system. Memory should point to evidence and respect access, rather than silently becoming the source of truth.
Tool authority Separate retrieval from publishing or messaging. The ability to call an MCP tool doesn't establish permission for every possible use.
Human review Present the actual proposed output and destination. Use approval policy on the tool call or graph path, not only a request in the prompt.
Delegation Add a specialist only when its separate context or tool scope helps. More agents add coordination work and don't automatically improve quality.
Run state Record the accepted artifact, unresolved issues, operation identifiers, and next step. Reconcile unknown results before replaying writes.


Evaluation, Privacy, and Operating Costs

Evaluate on representative tasks, including cases the agent should decline, escalate, or leave incomplete. Use a held-out set when revising prompts, skills, retrieval settings, or model choices. Inspect both the final artifact and the actions taken to produce it. A persuasive answer with the wrong sources, a duplicated ticket, or an unauthorized disclosure is a failure even if a language-model judge gives the prose a high score.


🔎 Improve the agent through a checked feedback loop
Observe a real failure
Capture the task, relevant inputs, tool actions, result, and the expected behavior. Remove unnecessary sensitive data.
Propose and compare
Change one meaningful part of the model, instructions, tools, or workflow. Test the candidate on known failures and held-out cases.
Review and release
Accept the change only when quality and control checks pass. Monitor the next deployment and retain a rollback route.
A trace supports diagnosis. An evaluation supports comparison. The destination result establishes whether the requested action actually happened.
Measure What to record
Outcome quality Correctness, source support, completeness, and whether the final artifact meets its acceptance criteria.
Action control Wrong-tool calls, approval bypasses, attempted out-of-scope access, duplicate writes, and useful escalations.
Operational behavior Completion rate, latency, timeout recovery, interrupted-run recovery, and notification burden.
Total cost Model calls, retrieval, sandboxes, hosting, storage, trace retention, review, rework, and maintenance per accepted result.

Traces and memory may contain prompts, retrieved documents, personal information, or tool payloads. Configure access, redaction, retention, and tenant separation deliberately. Keep credentials outside prompts and artifacts, restrict tools to the intended account and task, and treat retrieved documents, web pages, and emails as untrusted content. Context compression can help manage size, but important facts and approval records should remain recoverable from authoritative sources.

Getting Started

Using the Earlier Tutorials

The videos and topic resources below preserve the page's learning material, including documents, memory, email, tables, JavaScript, and vector retrieval. Many demonstrate earlier LangChain releases and model names. Use them for concepts, then consult current package documentation for imports, agent APIs, integrations, and security settings. A historical demo isn't evidence that its linked service, dependency version, or exact code still works today.

For a new project, choose one bounded task, define permitted tools and a completion check, pin dependencies, and start from the current LangChain, LangGraph, or Deep Agents documentation. Add a persistent backend, a review interface, and monitoring when the use case requires them.


LangChain Basics Tutorial #1 - LLMs & PromptTemplates with Colab
Sam Witteveen's LangChain basics #1: LLMs and prompt templates.

Easiest Way to Use GPT In Your Products | LangChain Basics Tutorial 🤖
Rachel Woods on the easiest way to use GPT in products with LangChain.

Getting Started with GPT-3 vs. Open Source LLMs - LangChain #1
James Briggs on getting started with GPT-3 versus open-source LLMs in LangChain.

LangChain Demo + Q&A with Harrison Chase
LangChain demo and Q&A with Harrison Chase.

Data Independent - tutorial videos

reference videos throughout page


What Is LangChain? - LangChain + ChatGPT Overview
Greg Kamradt gives an overview of LangChain with ChatGPT.

LangChain 101: Quickstart Guide
Greg Kamradt's LangChain 101 quickstart guide.

LangChain 101: Agents Overview + Google Searches
Greg Kamradt's LangChain 101 overview of agents, with Google searches.

LangChain 101: OpenAI + Wolfram Alpha
Greg Kamradt connects OpenAI and Wolfram Alpha with LangChain.

LangChain 101: YouTube Transcripts + OpenAI
Greg Kamradt uses YouTube transcripts with OpenAI in LangChain.

LangChain 101: Working With The New ChatGPT API
Greg Kamradt works with the new ChatGPT API in LangChain.

Structured Output From OpenAI (Clean Dirty Data)
Greg Kamradt gets structured output from OpenAI to clean messy data.


Documents with LangChain

For broader coverage of document creation, editing, analysis, and workflows, see Documents. This section covers documents in the context of LangChain.

LangChain 101: Ask Questions On Your Custom (or Private) Files + Chat GPT
Greg Kamradt asks ChatGPT questions about custom or private files with LangChain.

ChatGPT With Your Docs | Full Tutorial WITH Code Examples
Rachel Woods' full tutorial on chatting with your documents using ChatGPT.

LangChain101: Connect Google Drive Files To OpenAI
Greg Kamradt connects Google Drive files to OpenAI with LangChain.

Use Your Locally Stored Files To Get Response From GPT - OpenAI | Langchain | Python
Uses locally stored files to get answers from GPT with LangChain.

Long documents

GPT-4 Tutorial: How to Chat With Multiple PDF Files (~1000 pages of Tesla's 10-K Annual Reports)
GPT-4 tutorial on chatting with ~1,000 pages of Tesla annual reports.

LangChain101: Question A 300 Page Book (w/ OpenAI + Pinecone)
Greg Kamradt questions a 300-page book with OpenAI and Pinecone.

Workaround OpenAI's Token Limit With Chain Types
Greg Kamradt works around OpenAI token limits with LangChain chain types.

GPT-4 & LangChain Tutorial: How to Chat With A 56-Page PDF Document (w/Pinecone)
Chats with a 56-page PDF using GPT-4, LangChain and Pinecone.

Memory

LangChain - Conversations with Memory (explanation & code walkthrough)
Sam Witteveen explains LangChain conversations with memory.

Chatbot Memory for Chat-GPT, Davinci + other LLMs - LangChain #4
James Briggs adds conversational memory to LLMs with LangChain.

Emails

Build Your Own OpenAI + LangChain Web App in 23 Minutes
Greg Kamradt builds an OpenAI and LangChain web app in 23 minutes.

OpenAI + LangChain Wrote Me 100 Custom Sales Emails
Greg Kamradt has OpenAI and LangChain write 100 custom sales emails.

Tabular Data

Javascript

Langchain JS | How to Use GPT-3, GPT-4 to Reference your own Data | OpenAI Embeddings Intro
LangChain JS tutorial on referencing your own data with OpenAI embeddings.

Code - 17-sql-agent-demo.js — langchain-js-demo
Code demo of a SQL agent in LangChain JS.

LangChain Beginner's Tutorial for Typescript/Javascript
LangChain beginner's tutorial for TypeScript and JavaScript.

Full-Stack AI Apps with Javascript using LLMs - OpenAI, Hugging Face
Full-stack AI apps in JavaScript using OpenAI and Hugging Face.

Vector

Supabase

LangChain & Supabase Tutorial: How to Build a ChatGPT Chatbot For Your Website
Builds a ChatGPT chatbot for a website with LangChain and Supabase.

ClippyGPT - How I Built Supabase’s OpenAI Doc Search (Embeddings)
How Supabase's OpenAI-powered doc search, ClippyGPT, was built with embeddings.

Water

Import your knowledge-base into ChatGPT
Imports a knowledge base into ChatGPT.

Water - Build Custom ChatGPTs
Introduces Water, a tool for building custom ChatGPTs.

Visual ChatGPT

Microsoft's Visual ChatGPT using LangChain
Sam Witteveen on Microsoft's Visual ChatGPT built with LangChain.

Summarization

Building a Summarization System with LangChain and GPT-3 - Part 1
Sam Witteveen builds a summarization system with LangChain and GPT-3, part 1.

Building a Summarization System with LangChain and GPT-3 - Part 2
Sam Witteveen builds a summarization system with LangChain and GPT-3, part 2.

Building a Summarization System with LangChain - Part 3 Using ChatGPT Turbo
Sam Witteveen's summarization system, part 3, using ChatGPT Turbo.

Langchain Summary and QA with Chromadb using OpenAI Embeddings and GPT 3 with token count
LangChain summary and QA with ChromaDB and OpenAI embeddings, with token counts.

Hugging Face

LangChain - Using Hugging Face Models locally (code walkthrough)
Sam Witteveen uses Hugging Face models locally in LangChain.

LLama

Question Answer ChatBot using LLama-Index & LangChain with Hugging Face Models - Part 1
Builds a Q&A chatbot with LlamaIndex, LangChain and Hugging Face models, part 1.

GPT-Index

Build your own Q&A KnowledgeBot using GPT-Index & LangChain - Document to Chatbot
Builds a Q&A knowledge bot from documents with GPT-Index and LangChain.

Build your own LLM Apps with LangChain & GPT-Index
Builds LLM apps with LangChain and GPT-Index.

Comparing Large Language Models (LLM)

Comparing LLMs with LangChain
Sam Witteveen compares LLMs with LangChain.

Gradio

LLM ChatBot with Gradio UI Tutorial - Part 2
Builds an LLM chatbot with a Gradio UI, part 2.

Filtering LLM

Using Constitutional AI in LangChain
Sam Witteveen uses constitutional AI in LangChain.

Weights & Biases (W&B)

Weights & Biases offers tracing and evaluation for agents and language-model applications through Weave. This is a separate observability option from LangSmith; choose an integration supported by the actual framework and version you use. The older WandbTracer material on this page should be treated as historical rather than a current setup recipe. Current Weave project

Distinguish evaluating application settings from fine-tuning model weights. Comparing prompts, retrieval configuration, or sampling parameters doesn't itself train a model. Select the appropriate experiment or evaluation tool for the change being tested.

Reducing Hallucinations in LLMs | Retrieval QA w/ LangChain + Ray + Weights & Biases
Anyscale on reducing LLM hallucinations with retrieval QA using LangChain, Ray and W&B.

More

How to Build a Notion ChatBot For Your Knowledge Base Using LangChain (Code Template Included)
Builds a Notion knowledge-base chatbot with LangChain.

Chat with OpenAI in LangChain - #5
James Briggs chats with OpenAI models in LangChain.

Connecting the Internet with ChatGPT (LLMs) using Langchain And Answers Your Questions
Connects ChatGPT to the internet with LangChain to answer questions.

ChatGPT API Announcement & Code Walkthrough with LangChain
Sam Witteveen walks through the ChatGPT API announcement with LangChain code.

LangChain for LLMs is... basically just an Ansible playbook
David Shapiro compares LangChain to an Ansible playbook.

LangChain Agents - Joining Tools and Chains with Decisions
Sam Witteveen explains LangChain agents, which combine tools and chains with decisions.

Is AI going too far? 🤖 + 🌎 (LangChain + OpenAI)
A LangChain and OpenAI project asking whether AI is going too far.

PAL : Program-aided Language Models with LangChain code
Sam Witteveen covers PAL, program-aided language models, with LangChain code.

LangChain Basics Tutorial #2 Tools and Chains
Sam Witteveen's LangChain basics #2: tools and chains.

Langchain Async explained. Make multiple OpenAI chatgpt API calls at the same time.
Explains async LangChain calls to make multiple OpenAI requests at once.