Skip to content
OpenAgentSkill
Browsing is open · Catalog captured 2026-11-21 · Automatic updates and account services are paused.
AI & knowledge

langchain-and-langgraph-agent-orchestration

Guides building LLM applications with LangChain's chain/agent abstractions and, for stateful multi-step agents, LangGraph's graph-based orchestration (nodes, edges, cycles, checkpointed persistence, human-in-the-loop interrupts). Use when a user asks to "build this with LangChain," "use LangGraph for a stateful agent," "add persistence/checkpointing to a LangChain agent," "add a human approval step in a LangGraph graph," "my LangChain agent loses state between turns," or is deciding between LangChain's `AgentExecutor`, a LangGraph graph, and a hand-rolled control loop.

selvarajmurugesan90 · Static checks on file

Installation

Read the source and dependencies before running a command. Copying does not install or execute anything.

npx skills add selvarajmurugesan90/ops-engineering-skills --skill langchain-and-langgraph-agent-orchestration

About this skill


name: langchain-and-langgraph-agent-orchestration description: > Guides building LLM applications with LangChain's chain/agent abstractions and, for stateful multi-step agents, LangGraph's graph-based orchestration (nodes, edges, cycles, checkpointed persistence, human-in-the-loop interrupts). Use when a user asks to "build this with LangChain," "use LangGraph for a stateful agent," "add persistence/checkpointing to a LangChain agent," "add a human approval step in a LangGraph graph," "my LangChain agent loses state between turns," or is deciding between LangChain's AgentExecutor, a LangGraph graph, and a hand-rolled control loop. license: Apache-2.0 compatibility: "Claude Code, GitHub Copilot, OpenAI Codex, Cursor, Gemini CLI" metadata: domain: ai-agent maturity: stable

LangChain and LangGraph Agent Orchestration

Purpose

LangChain provides two things that are easy to conflate: a set of composable building blocks (prompt templates, model wrappers, retrievers, output parsers, chained via LangChain Expression Language / Runnable), and a higher-level AgentExecutor that wraps those blocks into a single-loop, tool-calling agent. LangGraph is a separate, lower-level runtime built by the same project specifically for agents whose control flow is not a single linear loop — it models the agent as an explicit graph of nodes and edges, supports cycles (a node can route back to an earlier node), and adds two capabilities AgentExecutor does not have out of the box: durable checkpointed state (so a run can pause, crash, and resume from its last checkpoint) and first-class human-in-the-loop interrupts (a graph can pause at a named node until a human approves, edits, or rejects the pending state). This skill covers choosing between plain LangChain composition, AgentExecutor, and LangGraph, and operating LangGraph's persistence and interrupt features correctly. It is a framework-specific complement to agent-architecture-design, which covers the underlying control-flow patterns (ReAct loop, plan-and-execute, finite-state/graph) in a vendor-neutral way — LangGraph is one concrete runtime that implements the finite-state/graph pattern described there. For tool access, LangChain/LangGraph agents can call tools defined directly in Python or exposed via an MCP server; see mcp-server-development for building the tool-serving side, which this skill treats as an external dependency rather than repeating.

When to use

  • Deciding whether a task needs plain LangChain chain composition (a fixed pipeline, no branching), AgentExecutor (a single ReAct-style tool-calling loop), or a LangGraph graph (multi-step, branching, cyclical, or needing persistence/human approval).
  • Building an agent whose steps depend on prior results in ways a single linear chain can't express — retries, conditional branches, or loops back to an earlier step.
  • Adding durable state to a LangChain/LangGraph agent so a long-running or multi-session workflow survives a process restart or crash mid-run.
  • Adding a human-in-the-loop approval checkpoint before an irreversible tool call in an existing LangGraph graph.
  • An agent built with AgentExecutor loses context, re-does completed work, or can't be paused/resumed, and the team is evaluating migrating it to LangGraph.
  • Debugging a LangGraph graph that loops indefinitely, gets stuck at an interrupt, or fails to restore state correctly from a checkpoint.

Prerequisites & environment

  • Python (LangChain/LangGraph's primary, most mature ecosystem) or JavaScript/TypeScript (langchain/langgraph npm packages, closely mirroring the Python API but with some feature lag) — pick one and check current package versions before starting, since both projects have had breaking changes across major versions (notably the LangChain 0.1 → 0.2/0.3 restructuring that split core, community, and partner packages).
  • An LLM provider integration package (e.g. langchain-anthropic, langchain-openai) installed separately from langchain-core — recent LangChain versions moved provider-specific code out of the core package.
  • For LangGraph persistence: a checkpointer backend — the in-memory MemorySaver for local development/testing only (state is lost on process exit), or a durable checkpointer (SQLite, Postgres, or a managed backend) for anything that must survive a restart.
  • Tool definitions the agent will call, either as plain Python functions decorated with LangChain's @tool, or proxied from an MCP server via an MCP-to-LangChain adapter — confirm which integration path your LangChain version currently supports before assuming API shape.
  • Clarity on which parts of the workflow are genuinely cyclical/branching (justifying LangGraph) versus a fixed sequence (better served by a plain LCEL chain) — reach for LangGraph only once a chain's limitations are concrete, mirroring the "justify the split" discipline in agent-architecture-design.

Step-by-step guidance

  1. Start with the simplest abstraction that fits the task's shape. A fixed sequence (retrieve → prompt → parse) is a plain LCEL chain:

    from langchain_core.prompts import ChatPromptTemplate
    from langchain_core.output_parsers import StrOutputParser
    from langchain_anthropic import ChatAnthropic
    
    prompt = ChatPromptTemplate.from_messages([
        ("system", "Summarize the following ticket in one sentence."),
        ("human", "{ticket_text}"),
    ])
    model = ChatAnthropic(model="claude-sonnet-4-5", temperature=0)
    chain = prompt | model | StrOutputParser()
    result = chain.invoke({"ticket_text": ticket_body})
    

    No loop, no tool calls, no branching — a chain is the right tool and adding AgentExecutor or LangGraph here is unjustified complexity.

  2. **Use AgentExecutor only for a si

Read the complete source ↗