Skills Guide

    LangChain and AI Agents
    The 2026 Skills Guide

    AI agents are the fastest-growing area of applied LLM engineering. This guide covers LangChain LCEL, LangGraph for stateful multi-step agents, the ReAct pattern, tool use, memory systems, and what it takes to build agents that actually work in production.

    LangChain Expression Language (LCEL)

    LCEL is the compositional core of modern LangChain. Every component — prompts, LLMs, retrievers, output parsers, tools — is a Runnable implementing a consistent interface: invoke(), stream(), batch(), and their async equivalents. Chains are composed with the | operator, which maps the output of one Runnable to the input of the next.

    A typical RAG chain: retriever | format_docs | prompt | llm | StrOutputParser(). This single expression supports synchronous invocation, async execution, token streaming, and batch processing without modification.

    Key LCEL primitives:

    • RunnableParallel — Execute multiple branches simultaneously and merge results. Used to run retrieval and other context-gathering in parallel.
    • RunnableLambda — Wrap any Python function as a Runnable. Bridges from arbitrary Python logic into LCEL chains.
    • RunnablePassthrough — Pass the input through unchanged; used to preserve original query text alongside retrieved context.
    • .with_fallbacks() — Specify alternative Runnables to try if the primary raises an exception. Critical for production reliability.
    • .with_retry() — Automatic retry with exponential backoff for transient API errors.

    Tool Use and the ReAct Agent Pattern

    Tools are functions that agents can call to interact with the outside world: web search, code execution, database queries, API calls. In LangChain, tools are defined with a name, description (used by the LLM to decide when to call them), and input schema (Pydantic model for type-safe argument parsing).

    The ReAct pattern (Reason + Act) is the most widely used agent loop:

    1. Thought: The LLM reasons about what it knows and what it needs to find out.
    2. Action: The LLM outputs a tool call in a structured format (function name + JSON arguments).
    3. Observation: The framework calls the tool and returns the result to the LLM.
    4. Repeat until the LLM produces a Final Answer.

    Modern implementations use the OpenAI function calling / tool calling API format, where the LLM returns structured JSON tool calls rather than free-text action descriptions. This is more reliable than text-parsed ReAct for production use.

    Tool design principles:

    • Tool descriptions are part of the prompt — write them from the LLM's perspective, describing exactly what the tool does, when to use it, and what inputs to provide.
    • Tools should be idempotent where possible. Non-idempotent tools (send email, create database record) should have confirmation steps.
    • Return structured data, not long text. The LLM must parse tool outputs; shorter and more structured is better.

    LangGraph: Stateful Agentic Workflows

    LangGraph models agentic workflows as directed graphs where nodes are functions (typically LLM calls or tool calls) and edges define transitions. State is a typed dictionary (TypedDict) that flows through the graph and is updated by each node.

    Core LangGraph concepts:

    • StateGraph — The graph container. Define nodes (functions taking and returning state), edges (unconditional: always go to node X), and conditional edges (the LLM's output or a function determines which node to visit next).
    • Persistence / Checkpointing — LangGraph can persist the full state at each step to a database (PostgreSQL, SQLite, Redis). This enables: resuming interrupted workflows, human-in-the-loop review and approval steps, and debugging by replaying from any checkpoint.
    • Interruptinterrupt() within a node pauses execution and returns control to the caller, waiting for human input before resuming. Essential for workflows requiring human approval (e.g., before sending an email or making an API call).
    • Multi-agent patterns — Supervisor pattern: an orchestrator agent routes tasks to specialist sub-agents. Each sub-agent is a compiled subgraph. The supervisor selects which agent handles the current task and processes the result. LangGraph's structured state makes it straightforward to pass context between agents and track which agent produced what output.

    Production Agent Considerations

    Building agents that actually work reliably in production is significantly harder than building demos. Key production concerns:

    • Latency — Agents with multiple LLM calls and tool invocations can take 30–60 seconds per turn. Parallelise tool calls where the LLM requests multiple independent tools simultaneously. Use streaming to show progress to the user.
    • Reliability and error handling — Tools fail; APIs rate-limit; LLMs sometimes output malformed JSON. Every tool call path needs retry logic, timeout handling, and graceful degradation.
    • Observability — Use LangSmith for tracing and debugging multi-step agent runs. Every LLM call, tool invocation, and intermediate state should be logged with enough context to reproduce failures.
    • Cost control — Multi-turn agents accumulate context; long conversations become expensive. Implement context windowing (summarise old turns) and token budgets. Monitor cost per session.
    • Security — Prompt injection via tool outputs (malicious content in a retrieved document instructs the LLM to take a different action) is a real threat. Sanitise tool outputs and use constrained output schemas.

    Frequently Asked Questions

    What is the difference between a chain and an agent?

    A chain is a fixed, predetermined sequence of steps (LLM call → retrieval → parsing). Flow is determined at code time. An agent is dynamic: the LLM decides what action to take next, chooses tools, observes results, and reasons about next steps. Chains are more controllable; agents are more flexible. Most production LLM applications use chains or fixed workflows, not fully autonomous agents.

    What is LangChain Expression Language (LCEL)?

    LCEL composes Runnable components with the pipe operator (|). Each component implements invoke(), stream(), and batch() with async support. LCEL chains automatically support streaming, parallel execution (RunnableParallel), fallbacks (.with_fallbacks()), and retry logic. It replaced earlier LangChain chain classes and is now the standard composition primitive.

    What is the ReAct pattern?

    ReAct (Reason + Act) interleaves Thought (reasoning), Action (tool call with inputs), and Observation (tool output) in a loop until a Final Answer is reached. The LLM must produce structured Thought/Action/Observation format; the framework parses the Action and calls the tool. Robust but requires a capable model.

    When should you use LangGraph vs LangChain agents?

    LangGraph for: multi-step workflows with conditional branching, human-in-the-loop checkpoints, multi-agent systems, or production agentic systems needing full control. Standard LangChain agents for simpler single-agent applications. LangGraph's state management and persistence make it production-grade.

    How do you handle memory in LangChain agents?

    Short-term (in-context): include conversation history in the prompt. Buffer memory keeps the last N exchanges; summary memory uses an LLM to summarise old history. Long-term: store memories in a vector store and retrieve relevant ones at each turn (MemoryVectorStore). Production systems typically combine both: buffer for recent turns, vector retrieval for relevant past context.

    Browse AI Agent Engineering Jobs

    Find AI engineering roles building agentic systems at UK companies.

    Quick Facts

    Demand level
    Very High
    Difficulty
    Intermediate
    Time to proficiency2–4 months
    Salary premium+£10,000–£20,000

    Key Tools

    LangChain
    LangGraph
    LangSmith
    LlamaIndex
    AutoGen
    CrewAI
    Haystack