Lesson 17
Context and Memory Management
AI-generated
- Understand how AI context windows work
- Know when conversations get too long (and what happens)
- Use effective context-setting at conversation start
- Manage information across long conversations
- Know when to start fresh vs. continue
One of the most frustrating things about AI: it forgets. You have a great conversation, come back the next day, and AI has no idea what you were talking about.
But even within a single conversation, strange things happen. AI might "forget" something you said earlier, or start contradicting itself, or lose track of your requirements.
Understanding how AI memory works is the key to working around these limitations. This lesson explains what is happening behind the scenes and gives you practical strategies for managing context effectively.
Think of AI's context window like short-term memory. It can hold a certain amount of information, and everything it says is based on what is in that window.
The Technical Reality (Simplified)
When you chat with AI, every message in the conversation (yours and AI's) is fed into the model together. The model can only process a limited amount of text at once. This limit is the "context window."
| Model | Context Window (approx) |
|---|---|
| Claude 3.5 Sonnet | 200,000 tokens (~150,000 words) |
| GPT-4 | 128,000 tokens (~96,000 words) |
| GPT-3.5 | 16,000 tokens (~12,000 words) |
A "token" is roughly 3/4 of a word. So 100,000 tokens is about 75,000 words.
What This Means Practically
- Your entire conversation must fit in the context window
- Older messages might get trimmed as conversations get very long
- AI has no memory of previous conversations (each starts fresh)
- Very long documents can fill up the window, leaving less room for conversation
The "It's All Text" Insight
AI does not actually remember anything. Every time you send a message, the entire conversation history is processed fresh. What feels like memory is just the conversation text being included in each new response.
Long conversations can degrade in quality. Here is what happens and why.
Signs Your Conversation Is Too Long
- AI starts forgetting requirements you stated earlier
- Responses become inconsistent with earlier parts of the conversation
- AI gets confused about what it already said vs. what you said
- Quality or coherence noticeably drops
- AI starts repeating itself or going in circles
Why This Happens
- Context trimming: Very long conversations may get truncated, losing early messages
- Attention dilution: AI has to process more text, potentially missing important details
- Accumulated confusion: Small misunderstandings compound over many exchanges
- Goal drift: The conversation's original purpose gets buried under new topics
The 15-20 Exchange Rule of Thumb
Conversations typically work well for 15-20 back-and-forth exchanges. Beyond that, consider whether a fresh start might serve you better.
This is not a hard rule. Complex projects can run longer. Simple Q&A can go much longer. But if quality is dropping, conversation length is often the cause.
Your first message in a conversation is critical. It sets the foundation for everything that follows.
What to Include in Opening Context
- Who you are (relevant background)
- What you need (the goal)
- Important constraints (what to avoid, requirements)
- Format preferences (how you want responses)
A Strong First Message Template
"I need help with [goal].
Background: I'm a [role/context] working on [project/situation].
Constraints:
- [Constraint 1]
- [Constraint 2]
For this conversation, please [communication preference].
Let's start with [specific first step]."
Example
"I need help planning my wedding.
Background: I'm getting married in 6 months. Budget is $20,000. We want something small (50 guests) but memorable.
Constraints:
- Outdoor venue strongly preferred
- Several guests have dietary restrictions (vegetarian, gluten-free)
- I'm handling most planning myself (no wedding planner)
For this conversation, please be direct and give me actionable steps, not vague suggestions.
Let's start with: What should I book first, and how far in advance?"
Why Front-Loading Works
AI gives disproportionate attention to the beginning of conversations. By putting key information upfront, you ensure it shapes all subsequent responses.
For conversations that need to go long, summarization keeps things on track.
Periodic Summarization
Every 10-15 exchanges, pause and consolidate:
"Before we continue, let's summarize where we are. What have we decided so far, and what's still open?"
This creates a fresh checkpoint that AI can reference.
The Context Reset
When conversations get unwieldy, you can reset without starting over:
"Let me recap our conversation so far: [your summary]. Going forward, use this recap as our starting point. What should we tackle next?"
This gives AI a clean, compressed version of the important context.
Document Building with Summaries
For long projects, maintain a running document:
- End each session: "Summarize what we accomplished and what's next"
- Start next session: "Here's where we left off: [paste summary]. Let's continue."
Checking AI's Understanding
Periodically verify AI is tracking correctly:
"Quick check: What do you understand my main requirements to be?"
If AI's answer reveals gaps or misunderstandings, correct them immediately.
Sometimes the best strategy is starting over. Know when to make that call.
Start Fresh When:
- The conversation has accumulated too many confusing tangents
- AI keeps making the same mistakes despite corrections
- You have learned new information that changes everything
- The original goal has significantly shifted
- Quality has noticeably degraded
Making Fresh Starts Efficient
Do not just re-type your original question. Use what you learned:
- Summarize key context and decisions from the old conversation
- Identify what went wrong (so you can avoid repeating it)
- Write a strong first message with refined requirements
- Reference any outputs from the old conversation you want to build on
The "Paste and Continue" Technique
If you have useful output from a previous conversation:
"I'm starting a new conversation but want to build on previous work. Here's what I had: [paste]. Let's continue from here. Specifically, I want to [next step]."
- Context window is finite: Everything in your conversation must fit; older content may be lost
- Front-load important context: Your first message shapes everything after
- Summarize periodically: Keep long conversations on track with checkpoints
- Watch for drift: If quality drops or AI forgets things, the conversation may be too long
- Fresh starts are strategic: Sometimes starting over with better context beats continuing
Test context management with this exercise:
- Start a conversation about planning something complex (a trip, event, or project)
- Have 10+ back-and-forth messages, adding details and making decisions
- Ask: "Summarize what you know about my preferences and requirements so far"
- Note what AI remembered and what it missed
- Start a new conversation with this opening: "I'm planning [same thing]. Here's what I've already decided: [paste AI's summary plus any corrections]. Let's continue from here."
- Compare the quality of responses in the new conversation vs. the end of the old one
- Context window research: https://arxiv.org/abs/2307.03172
- Anthropic context documentation: https://docs.anthropic.com/en/docs/build-with-claude/context-windows
- Studies on long-form AI conversations: https://arxiv.org/abs/2308.09945