Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Learn/LangChain Mastery/Part 7 · 6. Memory & State Management
Lesson 47 of 68

Why Memory Breaks Systems

LLMs are stateless. The illusion of continuity is your job.

Derpx0610 Jan · 1 min read
LangChain Mastery
Why Memory Breaks SystemsConversationBuffer & Window MemoryConversationSummaryMemoryEntity MemorySession IsolationPersistence Layers (Redis / DB)
Contents
1. The Fiction of "Chat"2. Why "Just Keep History" FailsA. The Context Window LimitB. LatencyC. The "Lost in the Middle" Effect3. Memory is a System Problem4. Summary
0% read · 1 min leftBack to top ↑
Course outline & contents0%
LangChain Mastery
Why Memory Breaks SystemsConversationBuffer & Window MemoryConversationSummaryMemoryEntity MemorySession IsolationPersistence Layers (Redis / DB)
Contents
1. The Fiction of "Chat"2. Why "Just Keep History" FailsA. The Context Window LimitB. LatencyC. The "Lost in the Middle" Effect3. Memory is a System Problem4. Summary

1. The Fiction of "Chat"

When you talk to ChatGPT, it feels like a continuous conversation. But the model does not remember you. It does not remember what you said 2 seconds ago.

LLMs are Stateless Sequence Predictors. Every time you send a message, you are actually resending the entire conversation history up to that point.

Turn 1: Input: [User: Hi] Output: [AI: Hello]

Turn 2: Input: [User: Hi, AI: Hello, User: My name is Bob] Output: [AI: Nice to meet you Bob]

If you drop the history, the model forgets who Bob is instantly.

2. Why "Just Keep History" Fails

New engineers think: "Easy! I'll just append every message to a list string." This works for 5 minutes. Then it breaks.

A. The Context Window Limit

Models have a hard limit (e.g., 8k tokens). If your history is 9k tokens, the API throws an error. You must delete something. But what?

B. Latency

Sending 100 words takes 100ms. Sending 10,000 words takes 2s. Infinite memory = Infinite latency.

C. The "Lost in the Middle" Effect

As history grows, the model's attention dilutes. It starts ignoring instructions buried in the middle of the chat logs.

3. Memory is a System Problem

Memory is not a feature of the model. It is a feature of the Application Layer. You are building a "State Engine" that sits in front of a "Stateless Processor."

If this engine fails, you get:

  1. Hallucination: The AI invents facts because it forgot the retrieved docs.
  2. Privacy Leaks: User B sees User A's history because you messed up session isolation.

4. Summary

To build a chatbot, you must become a State Architect. You must decide what to remember, what to forget, and where to store it.

Key Intuition: "The model lives in the eternal Now. Only the System has a Past."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonConversational RAG & HistoryNext lesson →ConversationBuffer & Window Memory