Single logo
  • Courses
  • Blog
  • About
Join free on SkoolJoin free on Skool

Learning path · 6 steps

Agents with LangChain and LangGraph
  1. 1
    What LangChain Is For, and When to Skip It: Five Standard Parts, One Pipe, and a Decision Table
  2. 2
    Why Chains Break: No Branch, No Retry, No Pause, and the Same Refund Assistant as a LangGraph Graph
  3. 3
    LangGraph Nodes, Edges and State: Build Your First Graph, Route With a Conditional Edge, and Read the Run Three Ways
  4. 4
    Human-in-the-Loop and Checkpointing in LangGraph: interrupt, a SQLite Save Slot and Command(resume=...)
  5. 5
    Multi-Agent Patterns: Hub and Spoke in LangGraph, With Short Briefs, Owned Tools and a Retry the Hub Decides
  6. 6
    A Research Agent in LangGraph: Plan, Search, Read, Write, and a Check Node That Rejects Citations Nobody Read
  1. Blog
  2. /
  3. AI Engineering
  4. /
  5. Agents and MCP

Learning path: Agents with LangChain and LangGraph · Step 1 of 6

What LangChain Is For, and When to Skip It: Five Standard Parts, One Pipe, and a Decision Table

LangChain is a box of standard parts (models, prompts, retrievers, tools, parsers) that snap together with a pipe. The same refund question through the plain Anthropic SDK (1 import, 13 lines) and a chain (3 imports, 14 lines) gives the same answer word for word. It pays off when the bot grows; for one call, the SDK is simpler, with 16 packages instead of 38.

Chaand Sheikh

·27 November 2026Agents and MCP

What you will learn

  • Name LangChain's five standard parts: chat model, prompt template, retriever, tools and output parser
  • Read a chain built with the pipe: prompt | model | parser
  • Compare the same call written with the plain provider SDK and with LangChain
  • Decide when LangChain pays off and when the plain SDK is the better choice

Before you start

  • The Claude Messages API: Your First Call
  • Basic Python functions and imports

What is LangChain actually for, and when is it smarter to leave it out? Here is one line of LangChain:

chain = prompt | model | StrOutputParser()

A prompt, a pipe, a model, another pipe and a parser. Hold on to this line, because it is the heart of the whole library. By the end of this article you'll be able to decide whether your own project needs it.

One bot, three stages

A developer is building a support bot for a shop, using plain API calls.

  • Day one: one call. A question goes to the model, and the answer comes back. Easy, and it works.
  • Week four: the bot needs the shop's help pages, so it first looks up the right pages and then asks the model. That's RAG, retrieval augmented generation.
  • Month three: the bot also needs tools. It checks an order and sends an email. Now there are four parts instead of one.

And now the developer wonders: should I bring in LangChain, or keep writing raw calls?

Flat-pack parts or a hammer

Think of furniture from a flat-pack store. The parts are standard, so they fit together fast, and you can build a whole cupboard. But if a carpenter needs just one shelf, a hammer and two nails is simpler. No box, no manual.

LangChain is the flat-pack box. The plain provider SDK is the hammer and nails.

Five standard parts

PartWhat it doesIn our project
Chat modelOne class that talks to a provider; the same shape works for many providersChatAnthropic
Prompt templateA prompt with a blank in it, filled in later"Answer briefly: {question}"
RetrieverFinds the right documents for a questionThe help pages from the story
ToolsPlain functions the model is allowed to ask for"check an order"
Output parserTurns the reply into clean text or data your code can useStrOutputParser

Parts snap together with a pipe

The parts connect with the pipe symbol, |. It passes the output of one part into the next. Our question, What is your refund policy?, goes into the prompt, and the blank gets filled: "Answer briefly: What is your refund policy?". It rides the pipe into the model, and a reply message comes out. Another pipe, into the parser, and out comes plain text.

prompt | model | parser questionrefund policy? promptfills the blank modelChatAnthropic parserplain text out || swap me: Claude, OpenAI, Gemini ... The other two boxes stay exactly as they are.
A chain is parts joined by pipes. Swapping the model box leaves the prompt and the parser untouched.

And here's the nice part: you can swap the model box for another provider, and the other two boxes stay exactly as they are.

The plain SDK call

Let's write the same tiny job two ways: ask one question, get the text back. First, the plain Anthropic SDK, 01_raw_sdk.py:

import anthropic

MODEL = "your-model-name"
client = anthropic.Anthropic()


def answer(question):
    reply = client.messages.create(
        model=MODEL,
        max_tokens=300,
        messages=[{"role": "user", "content": question}],
    )
    return reply.content[0].text

One import. Create a client, the object that talks to the provider. Inside answer, call messages.create with a model name, a token limit of 300 and the user message, and return the text from the first part of the reply. Thirteen lines, and every step is right there in front of you. (Each field is explained in The Claude Messages API: Your First Call.)

The same call as a chain

Now 02_langchain.py:

from langchain_anthropic import ChatAnthropic
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate

MODEL = "your-model-name"

prompt = ChatPromptTemplate.from_template(
    "Answer briefly: {question}")
model = ChatAnthropic(model=MODEL)
chain = prompt | model | StrOutputParser()


def answer(question):
    return chain.invoke({"question": question})

Three imports. We build the prompt template, with {question} as the blank, then the chat model, then the chain: prompt, pipe, model, pipe, parser. The three parts snap into one object. chain.invoke fills the blank with the question. Fourteen lines.

Same question, same answer

The project's runner sends What is your refund policy? to both. Without a key, a stand-in test model writes the reply, so you can run it straight away.

  • The plain SDK answers: Refunds are allowed within 30 days of purchase.
  • The chain gives the same answer, word for word.

The chain adds a prompt template and a parser, not new ability. And the size: one import and thirteen lines against three imports and fourteen lines. For one call, LangChain doesn't make this job easier. So where does it help?

Swapping the model, in our project

The runner (demo.py) already shows it, in how it swaps in the stand-in model:

def raw_module():
    module = load("01_raw_sdk.py")
    if not REAL:
        module.client = anthropic.Anthropic(api_key="stand-in-key", http_client=stand_in.anthropic_http_client())
    return module


def chain_module():
    module = load("02_langchain.py")
    if not REAL:
        module.chain = module.prompt | stand_in.StandInChatModel(messages=iter([])) | module.chain.last
    return module

For the plain SDK, it has to build a whole new client with a different HTTP client inside. For the chain, it keeps the same prompt and the same parser; only the middle box changes, to StandInChatModel. That's the model swap from the picture. The project's three tests pass, including the one that checks the chain gives the same answer as the plain SDK.

When LangChain pays off

  • Swapping providers. Change the model class and the rest of the chain stays. If your company might move providers, that saves a lot of time.
  • Many integrations. Vector stores, document loaders, tools: lots are already written, so you plug them in instead of writing glue code.
  • LangGraph and LangSmith. LangGraph builds agents that keep their state, and LangSmith traces what happened inside each step. Both plug in naturally. (LangGraph is next: Why Chains Break.)

When to skip it

  • One simple call. A single request doesn't need a pipeline around it.
  • Tight control. With the plain SDK, every argument of the request is right there in your code. Nothing is hidden.
  • Fewer dependencies. Installing just the Anthropic SDK pulls in 16 packages. Adding LangChain core and LangChain Anthropic brings it to 38. Each one is one more thing to update, and one more thing to debug when something breaks.

A quick decision table

Your situationReach for
One question, one answerProvider SDK
RAG plus several toolsLangChain
Might change provider laterLangChain
A small script with few dependenciesProvider SDK

The habit to remember: start simple, and add the toolbox when the pain shows up, not before.

Common mistakes

  • Adding LangChain on day one for a single call. You get more imports and more packages, and the same answer.
  • Expecting new ability. A chain organises parts; the model underneath decides the answer.
  • Hard-coding the provider everywhere. If you do expect to switch, keep the model in one place, whichever approach you choose.
  • Ignoring the dependency cost. 16 versus 38 packages is real maintenance work.

Quick recap

  • LangChain is a box of standard parts: models, prompts, retrievers, tools and parsers.
  • The parts snap together with a pipe, and you can swap the model without touching the rest.
  • It pays off with many parts or a changing provider. For one simple call, the plain SDK is simpler.

Try it yourself

Run the project's demo without a key and compare the two replies. Then change the prompt template to "Answer in one sentence: {question}" and see which file you had to touch, and which you didn't.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in the learning path Agents with LangChain and LangGraph · step 1 of 6

Next post
Why Chains Break: No Branch, No Retry, No Pause, and the Same Refund Assistant as a LangGraph Graph

Related course on Udemy

Become an AI Engineer: LLMs, RAG, Agents and MCP

Build real AI systems in Python: LLM APIs, RAG, evals, agents and MCP.View on Udemy ↗: Become an AI Engineer: LLMs, RAG, Agents and MCP (paid course, opens in a new tab)

Related posts

Context Engineering for a Long-Running Agent: Clear, Compact, Take Notes, Prove It

A support agent forgets the customer's name, order and contact choice after twenty turns and fails 0 of 4 checks. Measure the window, clear old tool output, compact old turns and keep a notes file, and the same chat passes 4 of 4 with 470 tokens instead of 2,945.

Why Chains Break: No Branch, No Retry, No Pause, and the Same Refund Assistant as a LangGraph Graph

A refund assistant built three ways. The chain runs classify, retrieve, reply once: it answers an opening-hours question with the billing line, misses the 30-day window, and sends a $150 refund with approved False. Plain if/while fixes it but hides the flow; a LangGraph StateGraph puts the branch, the retry loop and the approval stop in the arrows.

LangGraph Nodes, Edges and State: Build Your First Graph, Route With a Conditional Edge, and Read the Run Three Ways

Two small graphs. A refund skeleton: SupportState, a classify node, a route function on a conditional edge, and an Annotated log that appends instead of overwriting. A help desk: classify and answer call a scripted test model, spam goes straight to END after one model call instead of two, and the same run read with invoke, stream values and stream updates.

Human-in-the-Loop and Checkpointing in LangGraph: interrupt, a SQLite Save Slot and Command(resume=...)

A refund under 50 is approved by itself; 120 must wait for a person, maybe until tomorrow. interrupt pauses the graph and returns a question, SqliteSaver keeps the state in refunds.db after the program ends, and a brand new process resumes thread t-big with Command(resume="approve") at ask_human, not at the start.

On this page

  • One bot, three stages
  • Flat-pack parts or a hammer
  • Five standard parts
  • Parts snap together with a pipe
  • The plain SDK call
  • The same call as a chain
  • Same question, same answer
  • Swapping the model, in our project
  • When LangChain pays off
  • When to skip it
  • A quick decision table
  • Common mistakes
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Become an AI Engineer: LLMs, RAG, Agents and MCP

Build real AI systems in Python: LLM APIs, RAG, evals, agents and MCP.View on Udemy ↗: Become an AI Engineer: LLMs, RAG, Agents and MCP (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.