LangChain Interview Questions and Answers
Here are 27 LangChain and LangGraph interview questions, with short answers in simple English. They follow LangChain 1.x. Many online answers still describe older classes that are no longer in the main package, so we checked every name against the current release.

How to answer a LangChain question
Explain the idea first, then name the LangChain part that does it. Frameworks change, but the ideas behind them, like tools, state and retrieval, do not. Interviewers want both.
1. LangChain basics
Start with what LangChain is for, and be ready to say when you would not use it.
What is LangChain?
LangChain is an open-source framework for building apps with large language models (LLMs). It gives one common way to call many models, and ready-made parts for prompts, tools, retrieval and agents.
Its main value is that you can switch model providers, or reuse a part, without rewriting your whole app.
What is the difference between LangChain, LangGraph and LangSmith?
LangChain gives you building blocks: chat models, prompts, tools and agents. LangGraph runs workflows as a graph with saved state, which suits long or branching agent tasks.
LangSmith is a service for tracing, testing and evaluating your app. LangSmith works on its own, and LangGraph needs only langchain-core. LangChain 1.x installs LangGraph, because its agents run on it.
What changed in LangChain 1.x?
The package became smaller and focused on agents. Its create_agent function is the main way to build an agent, and it runs on LangGraph underneath. Older classes such as LLMChain, RetrievalQA and ConversationBufferMemory are not in the 1.x langchain package.
Those old classes now live in a separate langchain-classic package, for older code. Many online answers still describe them, so say which version you mean.
When would you not use LangChain?
For a simple app that calls one model and returns text, the provider's own SDK is often enough. A framework adds another layer to learn, debug and upgrade.
Use it when you need many providers, many tools, or ready-made parts you would otherwise write yourself.
2. Building blocks
These are the parts most interview questions are about. Know what each one does, in one sentence.

What is a chat model in LangChain?
A chat model is LangChain's common wrapper around an LLM provider, such as OpenAI or Anthropic. It takes a list of messages and returns a message.
init_chat_model lets you pick the provider and model by name, so switching is a one-line change.
What is a prompt template?
A prompt template is a prompt with blanks, such as {question}, that are filled in at run time. ChatPromptTemplate builds a list of messages, like a system message and a user message.
Templates keep prompts in one place, so they are easy to test and change.
What is a Runnable, and what is LCEL?
A Runnable is any step with the same simple interface. It has invoke for one input, batch for many, and stream for output piece by piece. Prompts, models, parsers and retrievers are all Runnables.
LCEL (LangChain Expression Language) joins Runnables with the | symbol, like prompt | model | parser. The result is itself a Runnable.
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_core.language_models.fake_chat_models import FakeListChatModel
prompt = ChatPromptTemplate.from_messages([
("system", "Answer in one short sentence."),
("user", "{question}"),
])
model = FakeListChatModel(responses=["A token is a small piece of text."])
chain = prompt | model | StrOutputParser()
print(chain.invoke({"question": "What is a token?"}))
# A token is a small piece of text.How do you get structured output?
Call with_structured_output on a chat model, and give it a schema: a description of the fields you want. A Pydantic class, a common Python way to define data, works well. It returns objects in that shape instead of free text.
Still check the result. A model can fill the fields with wrong values, even when the shape is right. For tasks that need thinking, put a reasoning field before the answer field.
What we measured: In our lab, a JSON schema forced through Ollama cost right answers. Writing freely, two small models got 46 and 70 of 70 maths problems right. With only an answer field, they got 1 and 5. A steps field first brought most back.
How do you run two steps at the same time?
RunnableParallel runs several Runnables on the same input at once, and returns their results together. For example, search two sources in parallel, then combine them.
3. Tools and agents
Agents are where LangChain changed most. Answer with the current way, and say you know the older one.
How do you make a tool in LangChain?
Put the @tool decorator on a Python function. The function name becomes the tool name, and the type hints become the argument schema. The docstring becomes the description, which the model reads to choose a tool.
So write the docstring for the model: say clearly what the tool does and what each argument means.
from langchain_core.tools import tool
@tool
def get_order_status(order_id: str) -> str:
"""Return the delivery status of one order, given its order ID."""
return "shipped"
print(get_order_status.name) # get_order_status
print(get_order_status.description) # Return the delivery status of one order, ...
print(get_order_status.args) # {'order_id': {'title': 'Order Id', 'type': 'string'}}What does bind_tools do?
bind_tools gives a chat model a list of tools it may ask for. The model can then reply with a tool call: a tool name and arguments.
The model never runs the tool itself. Your code, or an agent, runs it and sends the result back.
How do you build an agent in LangChain 1.x?
Use create_agent with a model, a list of tools and a system prompt. It runs a loop. The model picks a tool, the tool runs, and the result goes back to the model, until it can answer.
The older create_react_agent in LangGraph still works, but it is marked as old and replaced by create_agent.
What is agent middleware?
Middleware is code that runs around the agent's steps, for example before or after each model call. You can use it to trim long history, add guardrails, or ask a person to approve a tool call.
You pass a list of middleware to create_agent. It keeps these rules outside the prompt, in normal code you can test.
What makes LangChain agents fail, and how do you reduce it?
The same things that make any agent fail. These include long tasks, too many tools, unclear tool descriptions, and unchecked tool calls. A framework does not remove these problems.
Keep tasks short, validate every tool call, cap the number of steps, and trace every run.
What we measured: Say each step is right 95% of the time. For 20 steps, that is 0.95 multiplied by itself 20 times: about 36%.
4. RAG with LangChain
Retrieval is one of the most common things built with LangChain.
What are the parts of a RAG pipeline in LangChain?
Document loaders read files into Document objects. Text splitters cut them into chunks. An embedding model turns chunks into vectors, and a vector store saves them.
A retriever then finds the best chunks for a question. It is a Runnable, so it plugs straight into a chain.
Which text splitter would you start with?
A recursive character splitter is a common start. It splits on paragraphs first, then lines, then words, so chunks stay as whole as possible. In recent versions it lives in the separate langchain-text-splitters package.
Test chunk sizes on your own questions. The best size depends on your documents.
Your LangChain RAG app gives wrong answers. Where do you look first?
At the search, not the model. Check whether the right chunk is in the retrieved results. If it is not, no prompt will fix the answer.
Print what the retriever returns, or open the run in LangSmith. Then try hybrid search (keyword plus vector), a reranker (a second, careful sort), or better chunking. Measure each change.
5. LangGraph
LangGraph questions are now common in agent interviews. Focus on state, graphs and control.

What is a StateGraph?
A StateGraph is a workflow made of nodes and edges. Each node is a function that reads the shared state and returns updates to it. Edges decide which node runs next.
The graph starts at START and stops at END. Conditional edges choose the next node based on the state.
Why use LangGraph instead of a simple chain?
A chain runs straight through. Real agents need loops, branches, retries, and pauses for a person. A graph makes that control flow clear and testable.
It also saves state, so a long task can survive a crash and continue.
What is a checkpointer?
A checkpointer saves the graph's state after each step. InMemorySaver keeps it in memory for testing. Production apps use a saver that writes to a database.
With it, a conversation can continue across requests, and a failed run can resume from its last good step.
How does memory work in LangChain 1.x?
Short-term memory, the current conversation, is kept by the checkpointer. Each conversation gets its own thread_id, and the saved state is loaded for it on every call.
Long-term memory, facts kept across conversations, goes in a separate store. The old memory classes are not used for this anymore.
How do you add human approval in LangGraph?
Call interrupt inside a node. This needs a checkpointer, or nothing is saved. Later, resume with Command(resume=answer), where Command is a LangGraph class.
On resume, that node runs again from its first line. So put side effects, like sending money, after the interrupt.
from typing import TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.types import interrupt, Command
class State(TypedDict):
action: str
approved: bool
def ask_person(state: State) -> dict:
answer = interrupt(f"Approve '{state['action']}'?") # pauses here
return {"approved": answer == "yes"}
graph = StateGraph(State)
graph.add_node("ask_person", ask_person)
graph.add_edge(START, "ask_person")
graph.add_edge("ask_person", END)
app = graph.compile(checkpointer=InMemorySaver())
config = {"configurable": {"thread_id": "order-42"}}
first = app.invoke({"action": "refund 500 rupees", "approved": False}, config)
print("paused:", "__interrupt__" in first) # paused: True
final = app.invoke(Command(resume="yes"), config) # resumes here
print("approved:", final["approved"]) # approved: TrueShould you build a multi-agent system with LangGraph?
Only when you need it. One agent with good tools is the right default. Each extra agent adds hand-offs, points where one agent passes work to another, and more places to fail.
Split into several agents when the parts are truly separate, and measure that it helps.
6. LangChain in production
Last, running a LangChain app for real users.
What is LangSmith used for?
LangSmith records a trace of each run: every prompt, model call, tool call, answer, time and token count. You can find the step that went wrong.
It also runs evaluations on test datasets, so you can compare versions of your app.
How do you show the answer while it is being written?
Use stream, or astream in async code, instead of invoke. Pieces of the answer arrive as the model writes them, so the user sees text right away.
LangGraph can also stream updates from each node, so the user sees progress on long tasks.
How do you handle LangChain's fast changes?
Pin exact package versions, and read the release notes before upgrading. Keep good tests, so an upgrade that changes behaviour is caught before users see it.
Keep your own logic in plain functions, so less code depends directly on the framework.
How do you control cost in a LangChain app?
Trace token use per request, so you know where cost comes from. Send easy requests to a cheaper model, trim long chat history, and cache repeated results.
Learn it properly, not just the answers
Every answer on this page comes from our AI Engineering course: 112 lessons on RAG, evals, agents, serving, security and MLOps. Many of them are built around a real experiment. You learn why the answer is right, which is what an interviewer checks with the second question. 10 lessons are free to read, with no card needed.