Yesterday, we built a RAG chain that could answer a single question. But if you followed up with "Can you explain that further?", the AI would get confused. Why? Because it didn't have contextual history. Today, we solve the hardest part of RAG: Conversational Memory . We'll teach the AI to understand that "it" or "that" refers to things mentioned earlier in the chat. ποΈ The Problem: The "Query Re-writing" Challenge If you ask: "How does LangChain work?" "Can you give me an example of it?" The retriever doesn't know what "it" is. It will literally search your database for the word "it," which is useless. To fix this, we add a step called History-Aware Retrieval . The AI takes your follow-up question and the chat history, then "re-writes" it into a standalone question that the retriever can understand. π οΈ Step 1: Contextualizing the Question We create a sub-chain that looks at the history and the new question to produce a "search-friendly" query.β¦