LangChain and LangGraph
Interactive Quiz - Only Have MCQs
Q1. (MCQ) LangChain's core philosophy revolves around two principles. A developer switches their application from OpenAI to Anthropic's Claude without rewriting the pipeline logic. Which principle does this demonstrate?
A) Composition — linking components into chains for multi-step workflows B) Integration — providing a unified interface across different LLM providers without rewriting the codebase C) Retrieval — connecting the LLM to external private data D) Abstraction — hiding the LLM's API behind a generic wrapper for performance optimization
Answer: B
- A) — Incorrect. Composition is about linking components (prompt → model → parser) into sequential workflows. Swapping a provider without changing pipeline logic is about provider-agnostic interfaces, not component linking.
- B) — Correct. Integration means providing a unified interface to connect to dozens of different LLM providers, vector databases, and external tools without rewriting the entire codebase. Switching from OpenAI to Anthropic seamlessly is the textbook demonstration of this principle.
- C) — Incorrect. Retrieval is a specific module (Pillar 2) for connecting to external data sources via RAG. Provider swapping is an integration concern, not a data retrieval concern.
- D) — Incorrect. While LangChain does abstract API details, "performance optimization" isn't the stated goal. The principle is about unified interfaces across providers, not byte-level performance tuning.
Q2. (MSQ — Select ALL that apply) Which of the following are among the six foundational pillars of LangChain?
A) Model I/O — standardizing input/output across different model providers B) Retrieval — connecting the LLM to external data for RAG C) StateGraph — defining workflows as directed graphs with cyclic routing D) Callbacks — hooking into stages of the application for streaming and monitoring
Answer: A, B, D
- A) — Correct. Model I/O is Pillar 1, standardizing prompt templates, model wrappers (LLMs and Chat Models), and output parsers across different providers.
- B) — Correct. Retrieval is Pillar 2, providing the backbone for RAG with document loaders, text splitters, embedding models, vector stores, and retrievers.
- C) — Incorrect. StateGraph is a LangGraph primitive (the builder class for registering state schemas, nodes, and edges), not a LangChain pillar. LangChain's six pillars are: Model I/O, Retrieval, Chains, Memory, Agents, and Callbacks.
- D) — Correct. Callbacks is Pillar 6, allowing developers to hook into various stages for text streaming (reducing perceived latency) and logging/monitoring.
Q3. (MCQ) A LangChain application uses LCEL to build the following: chain = prompt | model | parser. The user's input flows through each component sequentially. This LCEL syntax is inspired by which computing concept?
A) Object-oriented method chaining (fluent interfaces) B) UNIX pipe syntax, where output of one component feeds as input to the next C) SQL JOIN operations that merge data from multiple tables D) MapReduce parallel processing across distributed nodes
Answer: B
- A) — Incorrect. Method chaining uses dot notation (e.g.,
obj.step1().step2()), not the pipe (|) operator. LCEL explicitly uses pipe syntax for a reason — it's modeled on a different paradigm. - B) — Correct. LCEL uses a UNIX-pipe-like syntax (
|) to seamlessly pass data from one component to the next, just as UNIX pipes pass the output of one command as input to another (e.g.,cat file | grep pattern | sort). - C) — Incorrect. SQL JOINs combine rows from multiple tables based on key relationships. LCEL is a sequential data flow, not a relational merge operation.
- D) — Incorrect. MapReduce involves parallel distribution across nodes. LCEL chains are sequential linear pipelines where data flows through one component at a time.
Q4. (MCQ) A developer's LLM consistently returns free-form text, but the downstream application needs structured JSON objects. Which LangChain Model I/O component solves this?
A) Prompt Templates B) Document Loaders C) Output Parsers D) Retrievers
Answer: C
- A) — Incorrect. Prompt Templates structure the input to the LLM (injecting variables into templates). They don't control or parse the output format.
- B) — Incorrect. Document Loaders fetch data from external sources (PDFs, databases) and convert them into Document objects. They operate on input data, not LLM output formatting.
- C) — Correct. Output Parsers force the LLM to output text in a specific format (like JSON, CSV, or a specific data schema) and parse that raw text into structured code objects for the application to use downstream.
- D) — Incorrect. Retrievers fetch relevant document chunks from a Vector Store based on a query. They handle data retrieval, not output formatting.
Q5. (MCQ) Traditional LLM chains are Directed Acyclic Graphs (DAGs). An agent researching quantum computing searches the web, reads a page, finds it unhelpful, searches again, reads a better page, and writes a summary. Why can't a standard LangChain chain handle this workflow?
A) LangChain chains cannot call external tools like web search B) LangChain chains are linear DAGs that cannot natively loop back to previous steps C) LangChain chains have no access to the internet D) LangChain chains cannot process text longer than 4,096 tokens
Answer: B
- A) — Incorrect. LangChain Agents (Pillar 5) can call external tools. The limitation isn't tool access — it's the inability to loop.
- B) — Correct. Standard LLM chains are Directed Acyclic Graphs (DAGs) — data flows in one direction without cycles. The research scenario requires a
whileloop: search → evaluate → if unhelpful, search again. DAGs cannot natively loop back to previous steps. This is precisely why LangGraph was built — to enable cyclical graphs where execution can flow back and forth between nodes. - C) — Incorrect. LangChain chains can connect to web APIs and search tools. Internet access is an integration feature, not a structural limitation.
- D) — Incorrect. Token limits are model constraints, not LangChain architectural limitations. Text splitters handle large documents, and the chain structure itself has no token ceiling.
Q6. (MSQ — Select ALL that apply) In LangGraph, which of the following are the five core primitives?
A) State — a shared data structure passed throughout the graph as the single source of truth B) Nodes — Python functions that receive current State, perform actions, and return state updates C) Chains — linear sequences of LLM operations connected by the pipe operator D) Edges — connections defining execution flow, including conditional routing
Answer: A, B, D
- A) — Correct. State is Primitive 1 — a shared data structure (TypedDict or Pydantic model) that is the single source of truth, continuously passed and updated throughout the graph.
- B) — Correct. Nodes are Primitive 2 — Python functions that receive the current State, perform actions (LLM calls, tool execution), and return partial state updates.
- C) — Incorrect. Chains are a LangChain concept (Pillar 3), not a LangGraph primitive. LangGraph's five primitives are: State, Nodes, Edges, StateGraph, and Checkpointers.
- D) — Correct. Edges are Primitive 3 — they define execution flow with Normal Edges (unconditional transitions) and Conditional Edges (routing based on current state).
Q7. (MCQ) In LangGraph, a node adds a new message to the chat_history field of the State. Instead of overwriting the existing messages, the new message is appended to the list. What mechanism controls this merge behavior?
A) Conditional Edges decide whether to append or overwrite B) Checkpointers save both versions and let the developer choose C) Reducers define how state field updates are handled — whether to overwrite or append D) The StateGraph compiler automatically detects list types and always appends
Answer: C
- A) — Incorrect. Conditional Edges determine where execution flows next (routing), not how state fields are updated. Edge logic and state merge logic are separate concerns.
- B) — Incorrect. Checkpointers save state snapshots for persistence and fault tolerance. They don't determine merge behavior for individual fields.
- C) — Correct. State fields use "reducers" to define how updates are handled. If a node outputs a new value, the reducer determines whether it overwrites the old value (like updating a
final_answerstring) or appends to it (like adding a new message to achat_historylist). LangGraph manages this merging process automatically based on the reducer configuration. - D) — Incorrect. LangGraph doesn't auto-detect types and assume behavior. Reducers must be explicitly defined — a list field might need overwrite behavior in some cases and append in others. The developer specifies this intentionally.
Q8. (MCQ) A LangGraph application crashes mid-execution at Node 4 of a 7-node workflow. After the server restarts, the graph resumes exactly at Node 4 without re-executing Nodes 1–3. Which LangGraph primitive enables this?
A) Conditional Edges that skip completed nodes B) Checkpointers that save state to a database after every node execution C) Reducers that track which nodes have already executed D) The StateGraph compiler that caches intermediate results in memory
Answer: B
- A) — Incorrect. Conditional Edges route execution based on state values, not completion tracking. They don't inherently know which nodes have been executed across server restarts.
- B) — Correct. Checkpointers save the graph's state to a database (PostgreSQL, SQLite) after every single node execution. This enables fault tolerance — if a server crashes mid-execution, the graph can resume exactly where it left off because the state at every step is persisted.
- C) — Incorrect. Reducers define how state field updates are merged (append vs. overwrite). They don't track node execution history or enable crash recovery.
- D) — Incorrect. In-memory caching is lost when the server crashes. Checkpointers persist state externally (to a database), which survives process termination.
Q9. (MCQ) An autonomous agent is about to execute a DROP TABLE SQL command. The organization requires a human to review and approve this action before execution. In LangGraph, how is this implemented?
A) A Conditional Edge routes to a "Human Review" node that blocks until manual input is received B) A breakpoint is set before the node; the graph pauses, saves state via Checkpointers, and resumes only after human approval via an API call C) The Callback system streams the SQL command to a UI, and the agent waits for a webhook response D) A separate LangChain Agent evaluates the command's risk level and auto-approves or rejects it
Answer: B
- A) — Incorrect. While conceptually similar, LangGraph's HITL mechanism isn't a blocking "Human Review" node. It's a breakpoint that pauses the entire graph, persists state, and lets the graph go dormant until externally resumed. A blocking node would keep the process running and consuming resources.
- B) — Correct. LangGraph's Human-in-the-Loop pattern uses Checkpointers to set a breakpoint before a specific node. The graph executes until it hits that node, interrupts itself, saves its current State to the database, and goes to sleep. A human reviews the action in a UI, and when they approve, an API call resumes the graph, picking up the exact state and completing the task.
- C) — Incorrect. Callbacks in LangChain are for streaming and monitoring, not for implementing approval gates. They don't pause execution or persist state for later resumption.
- D) — Incorrect. Using another LLM to auto-approve defeats the purpose of human oversight. The requirement is human review, not automated risk assessment.
Q10. (MCQ) In the Retrieval pillar, a large 200-page PDF is loaded but exceeds the LLM's context window. Which LangChain component breaks it into manageable pieces while preserving semantic meaning?
A) Document Loaders B) Text Splitters C) Text Embedding Models D) Vector Stores
Answer: B
- A) — Incorrect. Document Loaders fetch data from sources (PDFs, databases, web pages) and convert them into standard Document objects. They handle loading, not splitting.
- B) — Correct. Text Splitters break large documents into smaller, manageable chunks while preserving semantic meaning. This is necessary because LLMs have context limits — they can only process a bounded amount of text at once.
- C) — Incorrect. Text Embedding Models convert text chunks into numerical vectors after splitting has occurred. They handle vectorization, not chunking.
- D) — Incorrect. Vector Stores store the embeddings and enable similarity searches. They're the storage layer, not the splitting layer.
Q11. (MCQ) A developer builds a standard RAG pipeline: fetch docs → augment prompt → generate answer. The workflow is strictly linear with no loops or conditional branching. Which framework is the correct choice?
A) LangGraph — because all modern AI applications should use graphs B) LangChain — because the workflow is a predictable, linear sequence ideal for chains C) Both frameworks together — LangGraph for retrieval and LangChain for generation D) Neither — a raw OpenAI SDK call is always superior
Answer: B
- A) — Incorrect. LangGraph is designed for complex cyclical workflows with loops, branching, and state persistence. Using it for a simple linear pipeline introduces unnecessary complexity and overhead.
- B) — Correct. LangChain should be used when building a standard RAG pipeline, when the workflow follows a strict predictable sequence of data transformation steps, or when quickly wrapping an LLM API with simple prompt formatting and output parsing. A linear fetch → augment → generate pipeline is exactly this use case.
- C) — Incorrect. Splitting a linear pipeline across both frameworks adds architectural complexity with no benefit. LangChain handles the entire linear flow natively.
- D) — Incorrect. While the raw SDK works for a single API call, a RAG pipeline involves document loading, splitting, embedding, vector storage, retrieval, prompt formatting, and generation — exactly the multi-component orchestration LangChain was built for.
Q12. (MSQ — Select ALL that apply) LangGraph Checkpointers unlock which of the following enterprise-grade features?
A) Fault tolerance — resuming execution after a crash from exactly where it left off B) Time travel — rewinding to a previous step, changing a variable, and forking execution C) Automatic model selection — choosing the best LLM for each node based on task complexity D) Cross-session memory — remembering conversations from days or weeks ago
Answer: A, B, D
- A) — Correct. Because state is saved after every node execution, a crashed graph can resume exactly where it left off.
- B) — Correct. Because every state change is saved, you can rewind the graph to a previous step, change a variable, and fork the execution from that point.
- C) — Incorrect. Model selection is a developer design decision (covered in the Models article of the AI Agents course). Checkpointers persist state — they don't make model selection decisions.
- D) — Correct. Checkpointer persistence means the graph remembers conversations from days or weeks ago across sessions.
Q13. (MCQ) In LangChain, Chains execute a hardcoded linear sequence, while Agents use the LLM as a reasoning engine to dynamically determine which steps to take. An Agent is given a goal, uses a calculator tool, observes the result is wrong, then switches to a web search tool. Which characteristic of Agents does this demonstrate?
A) High predictability — the Agent always follows the same tool sequence B) Low flexibility — the Agent cannot adapt when a tool fails C) High flexibility — the Agent dynamically retries with different tools based on observed results D) Linear execution — the Agent processes tools in a predetermined order
Answer: C
- A) — Incorrect. This describes Chains, not Agents. Agents have lower predictability because the LLM might choose unexpected paths.
- B) — Incorrect. This is the exact opposite — low flexibility is a Chain characteristic. The scenario demonstrates an Agent adapting to failure.
- C) — Correct. Agents have high flexibility: they can retry or use different tools if one fails. The Agent Loop works by analyzing the goal, choosing a tool, observing the result, and deciding whether to use another tool or deliver the final answer. Switching from calculator to web search after an unsatisfactory result is dynamic adaptation.
- D) — Incorrect. Linear execution in a predetermined order describes Chains. The Agent dynamically changed its tool selection based on the observed result — the opposite of predetermined ordering.
Q14. (MCQ) In LangGraph, a Conditional Edge checks the State and finds tool_call_required = True, so it routes execution to the Tool Node. After the tool executes, another Conditional Edge checks the updated State and routes back to the Agent Node for further reasoning. This back-and-forth between Agent and Tool nodes is what distinguishes LangGraph from LangChain. What graph-theoretic concept enables this?
A) Directed Acyclic Graph (DAG) — data flows forward without revisiting nodes B) Cyclic Graph — execution can loop back to previously visited nodes based on state conditions C) Binary Tree — each node has exactly two children for branching decisions D) Spanning Tree — all nodes are visited exactly once
Answer: B
- A) — Incorrect. DAGs (which LangChain uses) explicitly prohibit cycles — data flows in one direction without revisiting nodes. The back-and-forth described here violates the acyclic constraint.
- B) — Correct. LangGraph is designed for Cyclic Graphs where data can flow in loops. A node can route execution back to a previous node indefinitely until a specific condition is met. The Agent → Tool → Agent loop is a cycle enabled by Conditional Edges that inspect the State, making LangGraph a true state machine.
- C) — Incorrect. Binary trees restrict each node to two children and don't allow cycles. LangGraph nodes can have arbitrary numbers of edges and can loop back to any previous node.
- D) — Incorrect. Spanning trees visit all nodes exactly once with no cycles. The Agent-Tool loop revisits the Agent node multiple times — the opposite of single-visit traversal.
Q15. (MCQ) A developer is making a single API call to OpenAI to generate a short text response. No RAG, no tools, no memory, no multi-step workflow. Should they use LangChain?
A) Yes — LangChain optimizes all LLM API calls for better performance B) Yes — all production LLM applications should use a framework C) No — the native OpenAI SDK is cleaner for a single simple API call, and LangChain introduces unnecessary abstraction and overhead D) No — LangChain cannot connect to OpenAI's API
Answer: C
- A) — Incorrect. LangChain doesn't optimize individual API calls — it orchestrates multi-component workflows. For a single call, it adds overhead without benefit.
- B) — Incorrect. Not all LLM applications need a framework. A critical part of AI engineering is knowing your tools' limitations and when simpler approaches suffice.
- C) — Correct. The material explicitly states: do not use LangChain if you are only making a single, simple API call to OpenAI — the native OpenAI SDK is cleaner. LangChain introduces abstraction and overhead that is only justified when orchestrating multi-component workflows.
- D) — Incorrect. LangChain absolutely supports OpenAI — it's one of the primary providers. The recommendation against using it here is about appropriateness, not capability.
Q16. (MCQ) In LangGraph, an "Agent Node" and a "Tool Node" differ in what they do with the State. What distinguishes them?
A) Agent Nodes can only read State while Tool Nodes can only write to State B) Agent Nodes use an LLM to make decisions while Tool Nodes execute functions like running code or calling APIs C) Agent Nodes are always the first node in a graph while Tool Nodes are always the last D) Agent Nodes operate on text data while Tool Nodes operate exclusively on numerical data
Answer: B
- A) — Incorrect. Both Agent Nodes and Tool Nodes read the current State and return partial updates. Neither is restricted to read-only or write-only access.
- B) — Correct. Agent Nodes are nodes that use an LLM to make decisions (reasoning, planning, tool selection). Tool Nodes are nodes that execute functions (running Python code, calling a weather API, querying a database). The distinction is between LLM-powered reasoning and deterministic function execution.
- C) — Incorrect. Node ordering is defined by Edges, not by node type. An Agent Node can appear anywhere in the graph, and Tool Nodes aren't restricted to the final position.
- D) — Incorrect. Both node types can process any data type available in the State. Tool Nodes frequently handle text (search results, API responses), and Agent Nodes process numerical data (deciding on calculations).
Q17. (MCQ) A LangChain RAG application has two phases: Ingestion and Execution. During the Ingestion phase, documents are loaded, split, embedded, and stored. During the Execution phase, a user asks a question. In what order do the Execution-phase components operate?
A) Retriever → LLM → Prompt Template → Memory B) Prompt Template → Retriever → LLM → Memory C) Retriever → Prompt Template → LLM → Memory D) LLM → Retriever → Prompt Template → Memory
Answer: C
- A) — Incorrect. The LLM cannot generate an answer before the Prompt Template combines the question with retrieved context. The template must be assembled before the LLM sees it.
- B) — Incorrect. The Prompt Template cannot be fully assembled before retrieval, because it needs the retrieved paragraphs to combine with the user's question. Retrieval must happen first.
- C) — Correct. The execution flow is: (1) The Retriever finds the top relevant paragraphs from the Vector Store, (2) a Prompt Template combines the user's question with the retrieved paragraphs, (3) the LLM reads the assembled prompt and generates an answer, (4) Memory stores this Q&A pair for the next interaction.
- D) — Incorrect. The LLM cannot generate a grounded answer before retrieval — that would defeat the entire purpose of RAG (the LLM would be answering from its parametric knowledge alone, which leads to hallucination).
Q18. (MSQ — Select ALL that apply) Which of the following scenarios warrant using LangGraph over LangChain?
A) An agent performing iterative code generation: write code → run tests → if tests fail, pass errors back to the coder → repeat B) A simple prompt formatting and output parsing wrapper around an LLM API C) A multi-agent team where a planner delegates to a researcher, who passes findings to a writer, who can send work back for revisions D) Enterprise workflows requiring Human-in-the-Loop approval gates
Answer: A, C, D
- A) — Correct. Iterative correction (code → test → fix → repeat) requires loops — execution flowing back to a previous node based on test results. This is a cyclic workflow that DAG-based LangChain chains cannot handle.
- B) — Incorrect. Simple prompt formatting and output parsing is a linear operation perfectly suited for LangChain (or even the raw SDK). LangGraph's graph infrastructure would be massive overkill.
- C) — Correct. A multi-agent team with bidirectional revision flows (writer → researcher → writer) is exactly the multi-actor, cyclical workflow LangGraph is built for. Each agent is an independent node with conditional edges enabling back-and-forth routing.
- D) — Correct. Enterprise HITL checkpoints for manual approval gates are a native LangGraph feature via Checkpointers and breakpoints. LangChain makes pausing and resuming mid-chain difficult.
Q19. (MCQ) LangChain manages state by passing it implicitly from step to step in a chain, with memory typically being a list appended to the prompt. LangGraph takes a fundamentally different approach. How does LangGraph manage state?
A) Each node maintains its own private state that is invisible to other nodes B) State is stored exclusively in the LLM's context window and is never externalized C) A centralized, explicit State object is updated via Reducers by any node in the graph D) State is managed by the Conditional Edges, which store variables between routing decisions
Answer: C
- A) — Incorrect. Private per-node state would prevent nodes from sharing information. LangGraph's State is explicitly shared — every node reads it, acts on it, and returns partial updates to it.
- B) — Incorrect. Relying solely on the LLM's context window would make state volatile and limited by token counts. LangGraph's State is an explicit Python data structure that exists outside the LLM, and Checkpointers can persist it to databases.
- C) — Correct. In LangGraph, State is the single source of truth — a centralized, explicit data structure (TypedDict or Pydantic model) updated via Reducers by any node. Every node reads the current state, performs logic, and returns a partial update. Reducers define the merge behavior (overwrite vs. append).
- D) — Incorrect. Conditional Edges read the State to make routing decisions, but they don't store or manage it. State management is handled by the State object and Reducers, not by edges.
Q20. (MCQ) A developer wants hyper-optimized control over every single byte of data in their LLM pipeline and finds that LangChain's generic wrappers sometimes obscure underlying system errors. What does the material recommend?
A) Use LangGraph instead, which provides more transparent data handling B) Add more Callbacks to monitor every byte passing through the pipeline C) Do not use LangChain — its abstractions can obscure errors when absolute low-level control is required D) Switch to a different LLM provider that is more compatible with LangChain
Answer: C
- A) — Incorrect. LangGraph adds more abstraction (graph primitives, state management, checkpointers), not less. It solves different problems (cyclical workflows) and doesn't address the low-level control concern.
- B) — Incorrect. Callbacks provide monitoring and logging hooks, but they don't remove the abstraction layers that obscure errors. You can observe what's happening, but you still can't control every byte through LangChain's generic wrappers.
- C) — Correct. The material explicitly warns: do not use LangChain if you require absolute, hyper-optimized control over every single byte of data passing through your pipeline, as LangChain's generic wrappers can sometimes obscure underlying system errors. In such cases, working directly with the provider's native SDK is more appropriate.
- D) — Incorrect. The issue is with LangChain's abstraction layer, not the LLM provider. Switching providers while staying within LangChain's wrappers doesn't resolve the transparency concern.