· technical  · 3 min read

Why Your AI Agent Sucks at Context (And How to Fix It)

DRAFT

Outline

Hook: “Remember what we discussed yesterday?” Your AI agent: “I don’t have access to previous conversations.” This is why AI agents feel impressive in demos but frustrating in real use—they’re amnesiacs with no memory of you, your work, or your context.

Core Argument: Context is the killer feature AI agents are missing. It’s not about bigger context windows—it’s about selective memory, relevance ranking, and knowing what context matters when. Fix context, and AI agents go from party tricks to indispensable tools.

Key Sections:

  1. The Three Types of Context AI Agents Need

    • Immediate context: Current conversation, task at hand
    • Session context: This project, this goal, recent history
    • Long-term context: Your preferences, past decisions, patterns
    • Why agents fail: they only have immediate context
    • Human analogy: Working with someone who has amnesia every 5 minutes
  2. Why “Just Use a Bigger Context Window” Doesn’t Work

    • GPT-4 Turbo: 128k tokens = 300 pages → still not enough
    • The “lost in the middle” problem: models ignore middle context
    • Cost explosion: $1 per query at max context
    • Attention dilution: too much context = worse performance
    • The real solution: selective, relevant context
  3. Strategy #1: Hierarchical Memory Systems

    • Working memory: Last 10 exchanges (always included)
    • Short-term memory: This session’s key points (summarized)
    • Long-term memory: User profile, preferences, past patterns (retrieved)
    • How to implement: Vector DB + metadata filters + recency weighting
    • Code example: Building a memory hierarchy
  4. Strategy #2: Context Retrieval (The RAG Approach)

    • Don’t stuff everything in—fetch what’s relevant
    • Query understanding: What context does this need?
    • Semantic search over: past conversations, documents, decisions
    • Reranking: Most relevant context goes first and last
    • Example: Agent retrieving “how we handled auth last time”
  5. Strategy #3: Explicit Context Setting

    • Let users declare context: “We’re working on the music app”
    • Context scopes: Project, domain, timeframe
    • Benefits: Precision, cost savings, user control
    • UI pattern: Context selector in chat interface
    • Example: 99 Minds project-based context
  6. Strategy #4: Progressive Context Building

    • Start minimal, add context as needed
    • Agent asks clarifying questions vs. assuming
    • Build context graph over time: entities, relationships, preferences
    • Example: “Which project?” → “The real estate app” → Loads that context
  7. Strategy #5: Context Compression

    • Summarize old conversations, keep essentials
    • Key decisions → structured memory, not raw text
    • Forget irrelevant details (yes, really)
    • Balance: What to remember vs. what to discard
    • Tool: LLMs for intelligent summarization
  8. Measuring Context Effectiveness

    • Metric: Questions answered without re-explanation
    • User frustration signals: Repeating themselves
    • Agent confusion signals: Asking for context it should have
    • A/B test: Good context vs. no context retention

Examples/Stories:

  • Personal: My RAG system remembers project context across weeks
  • Failure: Early 99 Minds didn’t remember user preferences, people complained
  • Success: Law firm tool that remembered case context → huge time savings
  • Technical detail: Implementing semantic search with recency bias
  • Cost comparison: Naive context stuffing vs. selective retrieval

Takeaways:

  • Context is 80% of what makes AI feel intelligent
  • Bigger context windows aren’t the answer—smarter retrieval is
  • Build memory systems: working, short-term, long-term
  • Let users explicitly set context when it matters
  • Test for: Does the agent remember what it should?

Cross-Links:

  • ← “How I Design AI Systems” (Series 1-7)
  • ← “RAG, But Make It Real Life” (Series 1-4)
  • → “From Legal Memos to Dream Circuits” (Series 1-9)
  • → “Personal Blueprint” (Series 3-22)
Back to Blog