<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[from full stack to AI]]></title><description><![CDATA[Exploring Full-Stack Development, GenAI, RAG, LangChain, LangGraph, NLP, and the engineering behind modern AI applications.]]></description><link>https://buildwithvartika.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 13:15:12 GMT</lastBuildDate><atom:link href="https://buildwithvartika.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[From LangChain to LangGraph, MCP, and Agentic AI
]]></title><description><![CDATA[The Next Evolution of Generative AI In the previous articles, we explored how Retrieval-Augmented Generation (RAG) extends Large Language Models by giving…]]></description><link>https://buildwithvartika.hashnode.dev/from-langchain-to-langgraph-mcp-and-agentic-ai</link><guid isPermaLink="true">https://buildwithvartika.hashnode.dev/from-langchain-to-langgraph-mcp-and-agentic-ai</guid><dc:creator><![CDATA[Vartika Sharma]]></dc:creator><pubDate>Sun, 26 Jul 2026 11:19:28 GMT</pubDate><content:encoded><![CDATA[<p><strong>The Next Evolution of Generative AI</strong></p>
<p>In the previous articles, we explored how Retrieval-Augmented Generation (RAG) extends Large Language Models by giving them access to external knowledge. Instead of relying only on their training data, RAG systems retrieve relevant information from documents before generating a response.</p>
<p>While this solves one major limitation of LLMs—<strong>lack of up-to-date knowledge</strong>—it still doesn't enable them to <strong>perform actions</strong>.</p>
<p>A RAG chatbot can answer questions about company policies.</p>
<p>But can it:</p>
<ul>
<li><p>Book a meeting?</p>
</li>
<li><p>Send an email?</p>
</li>
<li><p>Create a GitHub repository?</p>
</li>
<li><p>Query a database?</p>
</li>
<li><p>Call an API?</p>
</li>
<li><p>Fix code and create a pull request?</p>
</li>
</ul>
<p>The answer is <strong>no</strong>.</p>
<p>This introduces the next evolution in Generative AI: <strong>AI Agents</strong>.</p>
<p>Unlike a traditional chatbot, an AI Agent doesn't just retrieve information and generate text. It can reason about a task, decide what needs to be done, use external tools, observe the results, and continue working until the objective is completed.</p>
<p>This ability to <strong>think, act, and adapt</strong> is what makes AI Agents fundamentally different from traditional LLM applications.</p>
<p><strong>From chatbots to Agents</strong></p>
<p>let's compare the evolution of ai applications</p>
<p>Traditional chatbots :- they could not reason, adapt or learn. Every response had to be manually programmed.</p>
<p>Large Language Models :- Instead of following fixed rules, they could understand natural language and generate human-like responses.</p>
<p>LLM's still had one major drawback that they could not interact with the outside world, they could only generate text.</p>
<p>RAG :- Instead of relying only on training data, the AI could retrieve relevant information from external documents before generating an answer.Now the AI could answer questions using up-to-date company documents, manuals, research papers, or internal knowledge bases.</p>
<p>This made responses more accurate and reduced hallucinations.</p>
<p><strong>The Missing Piece :-</strong></p>
<p>Now imagine you ask:</p>
<blockquote>
<p>"Read the unread support emails, categorize them by priority, create Jira tickets for critical issues, notify the engineering team on Slack, and send me a summary."</p>
</blockquote>
<p>Let's think about what this requires.</p>
<p>The AI must:</p>
<ol>
<li><p>Read Gmail.</p>
</li>
<li><p>Decide which emails are important.</p>
</li>
<li><p>Create Jira tickets.</p>
</li>
<li><p>Send Slack messages.</p>
</li>
<li><p>Generate a summary.</p>
</li>
<li><p>Keep track of which steps have already been completed.</p>
</li>
<li><p>Handle failures if one of the tools doesn't work.</p>
</li>
</ol>
<p>This is no longer a single question.</p>
<p>It's a <strong>workflow</strong>.</p>
<p>More importantly, the workflow requires <strong>reasoning, decision-making, memory, and the ability to use external tools</strong>.</p>
<p>A traditional chatbot cannot do this.</p>
<p>An LLM cannot do this.</p>
<p>Even a RAG system cannot do this.</p>
<p>This is where <strong>AI Agents</strong> enter the picture.</p>
<h3>What is an AI Agent?</h3>
<p>Imagine you ask your AI assistant to perform certain taks for you like send an email, generate text, write documentations.</p>
<p>A normal chatbot would reply with here's how you can do it</p>
<p>But an AI agent would do all these for you it won't just tell you it'll perform the tasks.</p>
<p><strong>The four core Abilities of an AI agent</strong></p>
<ol>
<li><p><strong>Reasoning :-</strong> The first responsibility of an AI Agent is understanding the user's goal. Instead of immediately generating an answer, it analyzes the problem and decides what needs to be done. For example: "Find the cheapest laptop under ₹60,000." The agent realizes that it must: Search available products. Compare specifications. Compare prices. Recommend the best option. This planning process is called reasoning.</p>
</li>
<li><p><strong>Tool Usage :-</strong> Reasoning alone is not enough. The agent also needs the ability to interact with external systems. These external capabilities are called tools. Examples include: Web Search Calculator Weather API Gmail Google Calendar GitHub Database queries Python execution File readers Instead of pretending to know everything, the agent can simply use the appropriate tool whenever necessary.</p>
</li>
<li><p><strong>Memory :-</strong> Imagine asking: "Plan a Europe trip." Ten minutes later you ask: "Replace Paris with Amsterdam." The agent should understand that you're referring to the same itinerary without starting over. This ability to retain relevant context is called memory. Memory allows an agent to maintain continuity across multiple interactions and long-running tasks.</p>
</li>
<li><p><strong>Action :-</strong> After reasoning and selecting the correct tool, the agent performs an action. Examples include: Sending an email. Creating a calendar event. Executing code. Booking a ticket. Updating a database. Creating a GitHub issue. Unlike a chatbot, which only produces text, an AI Agent can influence the external world through these actions.</p>
</li>
</ol>
<img src="https://cdn.hashnode.com/uploads/covers/697e0009d21f937525dea5e3/58090db6-1d76-48df-91e5-bbbf7d77e1fa.png" alt="" style="display:block;margin:0 auto" />

<p>A typical AI Agent consists of several key components:</p>
<ul>
<li><p><strong>User Goal:</strong> Every task begins with an objective, such as "Create a weekly sales report and email it to my manager."</p>
</li>
<li><p><strong>Large Language Model (LLM):</strong> Acts as the brain of the agent, reasoning about the problem, deciding what to do next, and selecting the appropriate tools.</p>
</li>
<li><p><strong>Planning:</strong> Complex tasks are broken down into smaller, manageable steps before execution.</p>
</li>
<li><p><strong>Memory:</strong> Stores conversation history, intermediate results, and user preferences, allowing the agent to maintain context across multiple interactions.</p>
</li>
<li><p><strong>Tool Selection &amp; Execution:</strong> The agent uses external tools such as search engines, APIs, databases, calendars, or code interpreters whenever additional information or actions are required.</p>
</li>
<li><p><strong>Observation:</strong> After every action, the agent evaluates the outcome. If the task isn't complete or an error occurs, it adjusts its plan and tries again.</p>
</li>
</ul>
<p>This continuous <strong>Think -&gt; Plan -&gt; Act -&gt; Observe</strong> loop is what makes AI Agents fundamentally different from traditional chatbots. While a chatbot typically generates a single response, an AI Agent can perform multiple reasoning cycles and interact with external systems until it successfully achieves the user's goal.</p>
<p>This architecture also explains why frameworks like <strong>LangChain</strong> and <strong>LangGraph</strong> exist - they provide the building blocks needed to implement planning, memory, tool calling, and execution without developers having to build everything from scratch.</p>
<h2>Why was LangChain Created ?</h2>
<p>Now that we understand how can AI agent works internally one question naturally arises :</p>
<p>Do developers have to build all of these components themselves?</p>
<p>Imagine building an AI assistant that can search web, read PDF's, remember previous conversations, query a database and send emails. You would need to manually write code for prompt management, API integrations, conversation memory, tool execution, error handling, and the logic to connect all these components together.</p>
<p>As AI applications became more complex, This approach quickly became difficult to maintain.</p>
<p>This is where <strong>LangChain</strong> comes in.</p>
<p>LangChain is an open-source framework designed to simplify the development of LLM-powered applications. Instead of writing everything from scratch, it provides reusable components that allow developers to build AI applications much faster.</p>
<p>With LangChain, developers can:</p>
<ul>
<li><p>Connect Large Language Models such as OpenAI, Gemini, Claude, or Llama.</p>
</li>
<li><p>Integrate external tools like search engines, databases, APIs, and calculators.</p>
</li>
<li><p>Manage conversation history and memory.</p>
</li>
<li><p>Build Retrieval-Augmented Generation (RAG) pipelines.</p>
</li>
<li><p>Create AI agents capable of using multiple tools.</p>
</li>
<li><p>Chain together multiple LLM calls into a single workflow.</p>
</li>
</ul>
<p>In simple terms, <strong>LangChain acts as the glue that connects an LLM with the outside world</strong>, making it easier to build intelligent AI applications without reinventing the same infrastructure for every project.</p>
<p>However, as developers began building more sophisticated AI agents, they discovered that many real-world workflows were no longer simple linear chains. Tasks often required loops, conditional decisions, retries, and multiple execution paths.</p>
<p>These limitations eventually led to the creation of <strong>LangGraph</strong>, a framework specifically designed for building more advanced and stateful AI agents.</p>
<h2><strong>Why LangChain Wasn't Enough</strong></h2>
<p>LangChain made it much easier to build LLM-powered applications by providing components for prompts, memory, tools, and Retrieval-Augmented Generation (RAG). For many applications, this was sufficient.</p>
<p>However, as AI agents became more capable, developers started building increasingly complex workflows. They wanted agents that could make decisions, retry failed tasks, call multiple tools, and continue working until a goal was achieved.</p>
<p>Consider the following task:</p>
<blockquote>
<p>"Research the latest AI news, summarize the important updates, create a presentation, email it to my team, and if the email fails, try again."</p>
</blockquote>
<p>This is no longer a simple sequence of steps.</p>
<p>The agent may need to:</p>
<ul>
<li><p>Search the web.</p>
</li>
<li><p>Decide which articles are relevant.</p>
</li>
<li><p>Generate a summary.</p>
</li>
<li><p>Create a presentation.</p>
</li>
<li><p>Send an email.</p>
</li>
<li><p>Retry if the email service is unavailable.</p>
</li>
<li><p>Continue from where it stopped instead of starting over.</p>
</li>
</ul>
<p>Traditional LangChain workflows were primarily designed as <strong>linear chains</strong>, where one step follows another in a fixed order.</p>
<pre><code class="language-plaintext">Prompt
   ↓
LLM
   ↓
Tool
   ↓
Output
</code></pre>
<p>While this works well for straightforward applications, real-world AI agents rarely operate in such a predictable sequence.</p>
<p>They often need to:</p>
<ul>
<li><p>Make decisions based on previous results.</p>
</li>
<li><p>Repeat steps until a task succeeds.</p>
</li>
<li><p>Branch into different execution paths.</p>
</li>
<li><p>Maintain state throughout long-running workflows.</p>
</li>
<li><p>Coordinate multiple tools over several iterations.</p>
</li>
</ul>
<p>These requirements made it difficult to represent complex agent behavior using simple chains.</p>
<p>To address these challenges, <strong>LangGraph</strong> was introduced.</p>
<p>Instead of representing an AI workflow as a straight line, LangGraph models it as a <strong>graph</strong>, where each node represents a task and edges determine what happens next. This allows agents to loop, branch, pause, resume, and maintain state throughout execution.</p>
<p>In simple terms:</p>
<ul>
<li><p><strong>LangChain is ideal for linear AI workflows.</strong></p>
</li>
<li><p><strong>LangGraph is designed for intelligent, stateful AI agents with complex decision-making.</strong></p>
</li>
</ul>
<p>LangGraph doesn't replace LangChain—it builds upon it. Many modern AI applications use both together, with LangChain providing reusable components and LangGraph orchestrating how those components interact in more sophisticated workflows.</p>
<h2>What is LangGraph ?</h2>
<p>Before diving into langraph let's understand what is a graph.</p>
<p>A graph is a data structure that consists of nodes and edges.</p>
<p><strong>nodes</strong> represent individual tasks or operations.</p>
<p><strong>edges</strong> represent how the application moves from one task to another.</p>
<p>Unlike a traditional chain, where execution always moves in a straight line, a graph allows multiple execution paths. It can make decisions, repeat tasks, pause execution, or take different routes depending on the current state of the workflow.</p>
<p>This flexibility makes graphs an ideal way to build AI agents.</p>
<h3><strong>Chain vs Graph</strong></h3>
<p>Imagine you are making a cup of coffee.</p>
<p>A simple workflow would look like this:</p>
<pre><code class="language-plaintext">Boil Water
      ↓
Add Coffee
      ↓
Pour into Cup
      ↓
Serve
</code></pre>
<p>Every step happens in exactly the same order.</p>
<p>This is how <strong>LangChain</strong> works.</p>
<p>Now imagine the customer says:</p>
<blockquote>
<p>"If there's no milk, make black coffee. If coffee beans are finished, order more. If the machine breaks, notify the manager."</p>
</blockquote>
<p>Now the workflow is no longer linear.</p>
<p>Depending on different conditions, the next step changes.</p>
<pre><code class="language-plaintext">          Start
             │
             ▼
      Check Ingredients
        │          │
        │          │
      Enough?     No
        │          │
        ▼          ▼
 Make Coffee   Order Supplies
        │
        ▼
   Check Machine
        │
   ┌────┴────┐
   │         │
 Working?   Broken
   │         │
   ▼         ▼
 Serve   Notify Manager
</code></pre>
<p>This is exactly how <strong>LangGraph</strong> works.</p>
<p>Instead of forcing every workflow into a straight line, it allows the agent to choose different execution paths based on what happens during execution.</p>
<p><strong>The Core Components of LangGraph :-</strong></p>
<ol>
<li>Nodes</li>
</ol>
<p>A node represents a single task.</p>
<p>for eg : -</p>
<p>search google</p>
<p>read pdf</p>
<p>call an API</p>
<p>generate a summary</p>
<p>send an email</p>
<p>query a database</p>
<ol>
<li>Edges</li>
</ol>
<p>Edges connect nodes together</p>
<p>They tell the agent where to go next.</p>
<p>for eg :-</p>
<p>search news -&gt; summarize articles -&gt; create report</p>
<ol>
<li>State</li>
</ol>
<p>The <strong>state</strong> stores everything the agent knows while it is working.</p>
<p>It may include :-</p>
<p>user input</p>
<p>conversation history</p>
<p>search results</p>
<p>API responses</p>
<ol>
<li>Conditional Edges</li>
</ol>
<p>Sometimes the next step depends on the result of the previous step.</p>
<p>for eg :-</p>
<p>If flights are available:</p>
<pre><code class="language-plaintext">Search Flights
      │
      ▼
Book Flight
</code></pre>
<p>If no flights are found:</p>
<pre><code class="language-plaintext">Search Flights
      │
      ▼
Suggest Another Date
</code></pre>
<p>The workflow changes dynamically.</p>
<p>These decision points are called <strong>Conditional Edges</strong>.</p>
<h2>Why LangGraph is Powerful</h2>
<p>Traditional applications usually follow one predefined path.</p>
<p>AI agents don't.</p>
<p>They constantly make decisions based on new information.</p>
<p>For example:</p>
<blockquote>
<p>Research AI news.</p>
</blockquote>
<p>↓</p>
<p>If fewer than five articles are found,</p>
<p>↓</p>
<p>Search another source.</p>
<p>↓</p>
<p>Summarize.</p>
<p>↓</p>
<p>Check summary quality.</p>
<p>↓</p>
<p>If summary is poor,</p>
<p>↓</p>
<p>Generate it again.</p>
<p>↓</p>
<p>Email the final report.</p>
<p>Notice something important.</p>
<p>The agent <strong>loops</strong> until it is satisfied.</p>
<p>A simple chain cannot easily represent this behavior.</p>
<p>A graph can.</p>
<hr />
<h2>Real-World Example</h2>
<p>Imagine building an AI coding assistant.</p>
<p>The user asks:</p>
<blockquote>
<p>"Fix the login bug."</p>
</blockquote>
<p>The workflow might look like this:</p>
<pre><code class="language-plaintext">Read Code
      │
      ▼
Find Bug
      │
      ▼
Generate Fix
      │
      ▼
Run Tests
      │
 ┌────┴─────┐
 │          │
Pass       Fail
 │          │
 ▼          ▼
Create PR  Fix Again
      ▲
      │
      └──────────────
</code></pre>
<p>This is a perfect example of why LangGraph exists.</p>
<p>The workflow contains:</p>
<ul>
<li><p>Decision making</p>
</li>
<li><p>Loops</p>
</li>
<li><p>State management</p>
</li>
<li><p>Multiple execution paths</p>
</li>
<li><p>Tool usage</p>
</li>
</ul>
<p>Trying to implement this using a simple chain would quickly become difficult and hard to maintain.</p>
<hr />
<h2>LangChain vs LangGraph</h2>
<p>Although they are often mentioned together, they solve different problems.</p>
<p><strong>LangChain</strong> provides the building blocks for LLM applications, such as prompts, memory, tools, and document retrieval.</p>
<p><strong>LangGraph</strong> provides the execution engine that controls how these components interact over time, allowing agents to branch, loop, retry, pause, and maintain state.</p>
<p>In simple words:</p>
<ul>
<li><p><strong>LangChain helps you build AI applications.</strong></p>
</li>
<li><p><strong>LangGraph helps you orchestrate intelligent AI agents.</strong></p>
</li>
</ul>
<p>Most modern AI systems use both together rather than choosing one over the other.</p>
<h2>What is MCP (Model Context Protocol)?</h2>
<p>Imagine you're building an AI assistant that can:</p>
<ul>
<li><p>Read Gmail</p>
</li>
<li><p>Access Google Drive</p>
</li>
<li><p>Search GitHub</p>
</li>
<li><p>Query a PostgreSQL database</p>
</li>
<li><p>Check Slack messages</p>
</li>
<li><p>Create Jira tickets</p>
</li>
</ul>
<p>Sounds straightforward, right?</p>
<p>Not really.</p>
<p>Before MCP, every AI application had to build separate integrations for every external tool.</p>
<p>For example, if your AI assistant wanted to connect to Gmail, Google Drive, Slack, GitHub, and Notion, you had to write separate code for each service, handle different authentication methods, learn different APIs, and maintain those integrations whenever the services changed.</p>
<p>As the number of tools increased, maintaining these integrations became increasingly difficult.</p>
<p>Developers faced the same problem repeatedly:</p>
<p><strong>Every AI application had to reinvent the wheel.</strong></p>
<p>This is the exact problem that <strong>Model Context Protocol (MCP)</strong> was designed to solve.</p>
<hr />
<h2>What is MCP?</h2>
<p><strong>Model Context Protocol (MCP)</strong> is an open standard that provides a common way for AI models to communicate with external tools, applications, and data sources.</p>
<p>Instead of writing a new integration for every AI application, developers expose their tools through an <strong>MCP Server</strong>, allowing any compatible AI assistant to access them using the same protocol.</p>
<p>Because of this, MCP is often called:</p>
<p><strong>"The USB-C for AI Applications."</strong></p>
<p>Just as a USB-C cable allows different devices to communicate using one standard connector, MCP provides a standard interface that allows AI assistants to communicate with different tools without requiring custom integrations every time.</p>
<hr />
<h2>Understanding MCP with an Example</h2>
<p>Imagine you buy a new keyboard.</p>
<p>Without USB, every computer manufacturer would need a different connector.</p>
<pre><code class="language-text">Keyboard A → Computer A

Keyboard B → Computer B

Keyboard C → Computer C
</code></pre>
<p>This would quickly become unmanageable.</p>
<p>USB solved this by introducing one universal standard.</p>
<p>MCP does exactly the same thing for AI applications.</p>
<p><strong>Keyboard -&gt; USB -&gt; Any Computer</strong></p>
<p>Instead of every AI assistant creating separate integrations for every service, they all communicate through the same protocol.</p>
<pre><code class="language-text">               AI Assistant
                     │
                    MCP
      ┌──────────────┼──────────────┐
      ▼              ▼              ▼
   GitHub         Gmail         PostgreSQL
</code></pre>
<p>One protocol.</p>
<p>Many tools.</p>
<hr />
<h2>The MCP Architecture</h2>
<p>An MCP-based application typically consists of three components.</p>
<h3>1. MCP Host</h3>
<p>The host is the AI application that the user interacts with.</p>
<p>Examples include:</p>
<ul>
<li><p>ChatGPT</p>
</li>
<li><p>Claude Desktop</p>
</li>
<li><p>Cursor</p>
</li>
<li><p>VS Code AI Extensions</p>
</li>
</ul>
<p>The host receives the user's request and decides whether an external tool is needed.</p>
<hr />
<h3>2. MCP Client</h3>
<p>The MCP Client is responsible for communicating with MCP servers.</p>
<p>It sends requests, receives responses, and transfers information between the AI assistant and external tools.</p>
<p>You can think of it as a translator between the AI model and the outside world.</p>
<hr />
<h3>3. MCP Server</h3>
<p>The MCP Server exposes external capabilities to AI applications.</p>
<p>Each server may provide access to:</p>
<ul>
<li><p>GitHub repositories</p>
</li>
<li><p>Google Drive</p>
</li>
<li><p>Gmail</p>
</li>
<li><p>Databases</p>
</li>
<li><p>File systems</p>
</li>
<li><p>Slack</p>
</li>
<li><p>Notion</p>
</li>
<li><p>Calendar applications</p>
</li>
<li><p>Custom APIs</p>
</li>
</ul>
<p>Instead of every AI assistant implementing these integrations independently, they simply connect to the appropriate MCP Server.</p>
<hr />
<h2>Why is MCP Important?</h2>
<p>Before MCP:</p>
<ul>
<li><p>Every AI application required separate integrations.</p>
</li>
<li><p>Developers repeatedly solved the same problem.</p>
</li>
<li><p>Maintaining dozens of APIs became difficult.</p>
</li>
<li><p>Switching AI providers often meant rebuilding integrations.</p>
</li>
</ul>
<p>With MCP:</p>
<ul>
<li><p>One standard protocol works across many AI applications.</p>
</li>
<li><p>Tool providers implement the integration once.</p>
</li>
<li><p>AI assistants can reuse existing MCP servers.</p>
</li>
<li><p>Developers spend less time writing integration code and more time building useful AI applications.</p>
</li>
</ul>
<hr />
<h2>LangChain vs LangGraph vs MCP</h2>
<p>These technologies are often mentioned together, but they solve completely different problems.</p>
<ul>
<li><p><strong>LangChain</strong> provides reusable building blocks for developing LLM applications.</p>
</li>
<li><p><strong>LangGraph</strong> manages complex agent workflows involving planning, memory, loops, and decision-making.</p>
</li>
<li><p><strong>MCP</strong> standardizes communication between AI applications and external tools.</p>
</li>
</ul>
<p>A simple analogy is:</p>
<ul>
<li><p><strong>LangChain</strong> helps you build the agent.</p>
</li>
<li><p><strong>LangGraph</strong> decides how the agent thinks and executes tasks.</p>
</li>
<li><p><strong>MCP</strong> allows the agent to interact with the outside world through a common language.</p>
</li>
</ul>
<p>They complement each other rather than compete with one another.</p>
<hr />
<h2>Putting Everything Together</h2>
<p>Let's revisit the evolution of modern Generative AI.</p>
<pre><code class="language-text">Large Language Models
        │
        ▼
Retrieval-Augmented Generation (RAG)
        │
        ▼
AI Agents
        │
        ▼
LangChain (Building Blocks)
        │
        ▼
LangGraph (Agent Orchestration)
        │
        ▼
MCP (Universal Tool Communication)
</code></pre>
<p>Each technology addresses a different limitation of the previous one.</p>
<p>Together, they form the foundation of modern AI systems capable of reasoning, using tools, maintaining state, and interacting with the real world.</p>
]]></content:encoded></item><item><title><![CDATA[Why most RAG applications fail in production.]]></title><description><![CDATA[Imagine spending a week building a RAG chatbot. You ingest hundreds of pdf's, connect a vector database, choose the latest embedding model, and finally…]]></description><link>https://buildwithvartika.hashnode.dev/why-most-rag-applications-fail-in-production</link><guid isPermaLink="true">https://buildwithvartika.hashnode.dev/why-most-rag-applications-fail-in-production</guid><dc:creator><![CDATA[Vartika Sharma]]></dc:creator><pubDate>Fri, 24 Jul 2026 10:12:34 GMT</pubDate><content:encoded><![CDATA[<p>Imagine spending a week building a RAG chatbot.</p>
<p>You ingest hundreds of pdf's, connect a vector database, choose the latest embedding model, and finally deploy it.</p>
<p>The demo looks incredible, your teammates ask questions and the chatbot answers them correctly.</p>
<p>but after sometime real users start using it.</p>
<p>The chatbot gives wrong answers confidently.</p>
<p>Another employees gets outdated company policies.</p>
<p>Someone else receives some confidential information that they should never have seen.</p>
<p>So what's the problem ?</p>
<p><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">The problem is not the LLM it is that RAG is much harder than most tutorials make it seem.</mark></strong></p>
<p>In this article, we'll explore why many Retrieval-Augmented Generation (RAG) applications fail in production, where these failures originate, and how modern AI systems are designed to overcome them.</p>
<p><em><strong>BEFORE we talk about failures let's understand what is RAG?</strong></em></p>
<p>RAG is a <mark class="bg-yellow-200 dark:bg-yellow-500/30">retrieval augmented generation</mark> which is different from traditional LLM, it finds the information and then gives an answer. For example, A student studies learns everything that is present inside a book and then it answers based on its memory, it might be wrong morever it cannot give updated info as if a llm was trained between 2020 to 2024 so it has data present of only between 2020 to 2024 it cannot tell anything that happens after 2024, THIS is the drawback that RAG deals with, RAG retrieves information and gives to the user, RAG consists of a set of process which includes</p>
<p>The Complete RAG pipeline :</p>
<p>Documents -&gt; Chunking -&gt; Embedding -&gt; Vector Database -&gt; User Question -&gt; Embedding -&gt; Retriever -&gt; Prompt -&gt; LLM -&gt; Answer</p>
<p>The RAG consists of two different pipelines :-</p>
<p><strong>1) Indexing pipeline (offline)</strong></p>
<p>This runs before user asks questions.</p>
<p>Its job is to prepare the knowledge base.</p>
<p>PDFs -&gt; Chunking -&gt; Embeddings -&gt; Vector Database</p>
<p><strong>It is like preparing a library.</strong></p>
<p><strong>2) Retrieval Pipeline (online)</strong></p>
<p>This runs every time a user asks a questions.</p>
<p>Question -&gt; Embedding -&gt; Retriever -&gt; Relevant Chunks -&gt; LLM -&gt; Answer</p>
<p><strong>It is like searching in a library.</strong></p>
<p><strong>Now we'll talk about the stages of RAG in detail :-</strong></p>
<p>Stage 1 :- Document Ingestion</p>
<p>The first step is collecting data from different sources. The knowledge can come from pdf's, word documents, websites, notion, API's, JSON files.</p>
<p>Stage 2 :- Data Cleaning and Processing</p>
<p>Raw data contains a lot of useless information. for example headers, footers, page numbers, navigation menus, advertisements, broken HTML, encoding issues. The processing stage removes them. Sometimes preprocessing also includes OCR, language detection, HTML parsing.</p>
<p>Stage 3 :- Chunking</p>
<p>LLM cannot understand an entire 500 - page PDF at once. So instead we divide the pdf into smaller chunks.</p>
<p>But you must be thinking why chunking??</p>
<p>Because embedding models have token limits.</p>
<p>Smaller chunks - retrieves better, cost less, and also improve relevance.</p>
<p>There are also types of chunking -</p>
<p>Fixed - Size Chunking</p>
<p>this means that size of all chunks is fixed and same. But this may lead to sentence cutting or change the meaning of stuff.</p>
<p>Recursive Chunking</p>
<p>In this chunking we split by heading -&gt; paragraph -&gt; sentence -&gt; Words This is a much smarter approach</p>
<p>Semantic Chunking</p>
<p>This is one of the best way to do chunking as this is done when the topic changes. This helps in keeping the meaning of the sentences intact new topic -&gt; new chunk</p>
<p>Stage 4 - MetaData Enrichment</p>
<p>Every chunk gets extra information. for example - metadata, document name, page number, author, creation date, department, language. MetaData improves filtering.</p>
<p>Stage 5 - Embedding Generation</p>
<p>Now at this stage every word is converted into numbers. Embedding model -&gt; Chunk -&gt; Vector. Example - "This medicine reduces fever."-&gt;[0.81, -0.45, 0.21, ...] A vector may have</p>
<ul>
<li><p>384 dimensions</p>
</li>
<li><p>768 dimensions</p>
</li>
<li><p>1024 dimensions</p>
</li>
<li><p>1536 dimensions</p>
</li>
<li><p>3072 dimensions</p>
</li>
</ul>
<p>depending on the embedding model.</p>
<p>Similar meanings produce nearby vectors.</p>
<p>Stage 6 - Vector Database Indexing</p>
<p>vectors are stored inside a vector database. Examples - pinecone, chroma, FAISS</p>
<p>Stage 7 - Query Processing</p>
<p>At this stage, the user starts asking questions.</p>
<p>Stage 8 - Query Embedding</p>
<p>The user query is embedded using the <strong>same embedding model</strong>. for example "what is maternity leave" now query embedding finds document chunks and query exist in the same vector space.</p>
<p>Stage 9 - Retrieval</p>
<p>The vector database searches for the nearest vectors. Example- Query Vector-&gt;Vector Search -&gt; Top K Results</p>
<p>stage 10 - Prompt Augmentation</p>
<p>Retrieved chunks are inserted into the prompt.</p>
<p>stage 11 - LLM generation</p>
<p>Finally the LLM generates the answer.</p>
<h3><strong>Why does RAG looks easy ?</strong></h3>
<p>Building a simple RAG application requires surprisingly little code. With frameworks like LangChain, LlamaIndex, or Haystack, you can load documents, create embeddings, store them in a vector database, retrieve relevant chunks, and generate answers in just a few dozen lines of code.</p>
<p>Everything works... until real users arrive.</p>
<p>Real users ask :- unpredictable questions, ambiguous questions, misspelled questions, questions outside your documents.</p>
<h3>Reason Most RAG applications fail in production</h3>
<p>Production RAG systems don't usually fail because the LLM is weak. They fail because every stage of the pipeline introduces opportunities for error. A mistake in chunking, retrieval, indexing, ranking, or prompt construction compounds downstream, leading to poor answers even if the language model itself is highly capable.</p>
<p>now we'll see some common failures one by one</p>
<ol>
<li><p>Bad Chunking</p>
</li>
<li><p>Wrong Embeddings</p>
</li>
<li><p>Weak Retrieval</p>
</li>
<li><p>Missing re-ranking</p>
</li>
<li><p>Context Window Limits</p>
</li>
<li><p>Hallucinations still exist</p>
</li>
<li><p>Prompt injection</p>
</li>
<li><p>Latency</p>
</li>
<li><p>Cost Explosion</p>
</li>
<li><p>Poor data quality</p>
</li>
</ol>
<p>The quality of a RAG system can never exceed the quality of the knowledge base it retrieves from. This is the most fundamental reason production systems fail.</p>
<p>Many developers focus on selecting the best LLM or the most advanced vector database but overlook the documents themselves. If the source data is outdated, inconsistent, duplicated, or incomplete, retrieval will faithfully return incorrect or misleading information. The language model then generates answers based on this flawed context.</p>
<p>Common data quality problems include:</p>
<ul>
<li><p>Outdated documents</p>
</li>
<li><p>Duplicate information</p>
</li>
<li><p>OCR errors from scanned PDFs</p>
</li>
<li><p>Missing pages</p>
</li>
<li><p>Broken HTML during web scraping</p>
</li>
<li><p>Conflicting information across documents</p>
</li>
<li><p>Inconsistent formatting</p>
</li>
<li><p>Noise such as headers, footers, advertisements, or navigation menus</p>
</li>
</ul>
<ol>
<li><p><strong>Bad Chunking</strong> :- If documents are split at the wrong places, important context gets separated or unrelated information gets grouped together. This leads to incomplete or irrelevant retrieval, causing the LLM to generate inaccurate answers.</p>
</li>
<li><p><strong>Wrong Embeddings</strong> :- Embeddings convert text into vectors for semantic search. Using a poor-quality or domain-inappropriate embedding model can fail to capture the true meaning of the text, resulting in relevant documents not being retrieved.</p>
</li>
<li><p><strong>Weak Retrieval</strong> :- A retriever is responsible for finding the most relevant chunks from the vector database. If it retrieves irrelevant or incomplete documents, even the best LLM cannot produce a correct answer because it only knows what it is given.</p>
</li>
<li><p><strong>Missing Re-ranking</strong> :- Initial vector search may return several loosely relevant chunks. A re-ranking model reorders these results based on deeper semantic understanding; without it, the LLM may receive lower-quality context instead of the most relevant information.</p>
</li>
<li><p><strong>Context Window Limits</strong> :- LLMs have a maximum number of tokens they can process in a single prompt. If too many chunks are retrieved, important information may be truncated or omitted, reducing answer quality.</p>
</li>
<li><p><strong>Hallucinations Still Exist</strong> :- RAG reduces hallucinations but does not eliminate them. If retrieved information is incomplete, ambiguous, or missing, the LLM may confidently generate information that is incorrect or unsupported.</p>
</li>
<li><p><strong>Prompt Injection</strong> :- Malicious documents or user inputs can contain instructions that manipulate the LLM, such as telling it to ignore previous instructions or reveal confidential data. Without proper safeguards, the model may follow these harmful instructions.</p>
</li>
<li><p><strong>Latency</strong> :- A RAG system performs multiple operations—embedding generation, vector search, re-ranking, and LLM inference—before producing an answer. As datasets grow, these steps can increase response time and negatively impact the user experience.</p>
</li>
<li><p><strong>Cost Explosion</strong> :- Every query consumes embedding, retrieval, and LLM resources. Large prompts, expensive models, and high traffic can quickly increase operational costs if the system is not optimized with caching, better retrieval, or smaller models.</p>
</li>
<li><p><strong>Poor Data Quality</strong> :- A RAG system is only as good as the documents it retrieves from. Outdated, duplicated, incomplete, or poorly formatted data leads to inaccurate retrieval, causing the LLM to generate misleading or incorrect responses.</p>
</li>
</ol>
<h3><strong>Common Data Quality problems</strong></h3>
<ol>
<li><p>Outdated Documents If the knowledge base contains old or obsolete information, the RAG system will retrieve and use it, even if newer information exists elsewhere. For example, an old HR policy may state 20 days of annual leave while the latest policy allows 25 days. Since the LLM trusts the retrieved context, it will confidently provide outdated answers.</p>
</li>
<li><p>Duplicate Information The same document may exist multiple times in the knowledge base due to repeated uploads or versioning. This wastes storage, increases retrieval time, and may cause duplicate chunks to dominate the search results. As a result, more relevant documents can be pushed out of the retrieved context.</p>
</li>
<li><p>OCR Errors from Scanned PDFs Scanned documents often require Optical Character Recognition (OCR) to convert images into text. Poor OCR quality can misread words, numbers, or entire sentences—for example, "1000" becoming "100O" or "leave" becoming "Ieave." These errors produce incorrect embeddings and reduce retrieval accuracy.</p>
</li>
<li><p>Missing Pages Documents may be uploaded with missing or corrupted pages due to scanning errors or incomplete file transfers. If important sections are absent, the retriever cannot find the required information, leading the LLM to generate incomplete or incorrect answers. Missing pages are especially problematic for legal, financial, and medical documents.</p>
</li>
<li><p>Broken HTML During Web Scraping When scraping websites, poorly parsed HTML can introduce broken text, missing paragraphs, or irrelevant navigation content into the dataset. Important information may be lost while useless elements are indexed. This reduces the quality of embeddings and retrieval results.</p>
</li>
<li><p>Conflicting Information Across Documents Large organizations often have multiple versions of the same document, each containing different information. For example, one policy may state a 30-day notice period while another states 60 days. If both are indexed, the RAG system may retrieve conflicting chunks, confusing the LLM and leading to inconsistent answers.</p>
</li>
<li><p>Inconsistent Formatting Documents collected from different sources often follow different formats, fonts, heading structures, and layouts. Some may use tables, while others use plain text or bullet points. This inconsistency makes document parsing, chunking, and metadata extraction more difficult, reducing overall retrieval quality.</p>
</li>
<li><p>Noise such as Headers, Footers, Advertisements, or Navigation Menus Many documents contain repeated content like page numbers, company logos, headers, footers, advertisements, or website navigation menus. If this noise is not removed during preprocessing, it gets embedded along with the actual content, wasting vector space and reducing the relevance of retrieved chunks. Clean documents lead to much more accurate retrieval.</p>
</li>
</ol>
]]></content:encoded></item></channel></rss>