What is LangChain and what problem does it solve?
LangChain is an open-source framework for building applications powered by LLMs. It solves the problem of connecting LLMs to external data, tools, and memory. Without LangChain, you write boilerplate for every: prompt formatting, chain-of-thought parsing, tool calling, memory management, and streaming. LangChain provides standardized abstractions so you can swap models (GPT-4 → Gemini) without rewriting business logic.
What is the difference between LangChain Chains and Agents?
Chains follow a fixed, predetermined sequence of steps — ideal for workflows where the path is known (query → embed → retrieve → generate). Agents are dynamic: the LLM decides at runtime which tools to call and in what order. Use chains for production stability and cost predictability. Use agents for open-ended tasks requiring reasoning. In production, most teams start with chains and only use agents where dynamic tool selection is genuinely needed.
How does LangChain Memory work and what are the types?
LangChain Memory stores conversation context to enable multi-turn conversations. Types: (1) ConversationBufferMemory — stores all messages (expensive for long conversations), (2) ConversationSummaryMemory — summarizes old messages with the LLM, (3) ConversationBufferWindowMemory — keeps last N messages, (4) VectorStoreRetrieverMemory — retrieves relevant past messages by semantic similarity. For production, use external memory (Redis/PostgreSQL) instead of in-memory solutions that reset on restart.
Explain LangChain Expression Language (LCEL) and why it matters.
LCEL is LangChain's declarative way to compose chains using the pipe operator (|). Example: chain = prompt | llm | output_parser. LCEL gives you: automatic async support, streaming by default, built-in retry logic, parallel execution (RunnableParallel), and easy debugging. Every component is a Runnable with .invoke(), .stream(), and .batch() methods. LCEL is now the recommended way to build all LangChain applications.
What is LangChain Tools and how are they used in agents?
Tools are functions that agents can call to interact with the world. Define with @tool decorator: @tool def search_web(query: str) -> str. Tools need: name (for LLM to identify), description (for LLM to know when to use), and a callable function. Common tools: web search (Tavily), code execution (Python REPL), database queries, API calls, file operations. In production, validate tool inputs, add timeouts, and handle errors gracefully.
How do you debug and trace LangChain applications?
Use LangSmith for production tracing — it records every LLM call, tool execution, and chain step with timing and cost data. Enable with LANGCHAIN_TRACING_V2=true env variable. For local debugging: set verbose=True on any chain, use callbacks (StdOutCallbackHandler), or use the @traceable decorator. LangSmith lets you replay failed requests, compare runs, and set up automated evaluation pipelines.
Know your weak spots before the interview
10-question AI readiness assessment → personalized study plan.
Take Free Assessment →Unlock 3,000+ Interview Questions
Get full access to all interview questions with detailed answers, explanations, and real company context
Unlock Full Access →