Non-FictionAI Operator

AI Context Window Management eBook

Provide effective context to AI for better code ge

by Dorris Aracely

  • English
  • 150 pages
  • 2026
  • SamEnrico

Provide effective context to AI for better code generation results.

Formats

Free sample

Chapter 1: The 70% Rule...--–- Emily stared at her screen, defeated. For the past forty-five minutes, she had been wrestling with an AI coding assistant to refactor a legacy authentication module. The first ten minutes were magical—the AI understood her intent, suggested elegant solutions, and generated code that looked like it came from a senior architect. Then, slowly, imperceptibly at first, things began to unravel.The AI started asking questions it should have known the answers to. "What database are you using again?" Emily had mentioned Postgre SQL in her very first message.

Then it began ignoring constraints she had carefully laid out. "Don't touch the user session table," she had written in bold. Twenty minutes later, the AI suggested dropping and recreating that exact table. By minute forty-five, when Emily asked the AI to explain its latest refactoring attempt, it responded with a cheerful but useless "I'd be happy to help! Could you please share the code you're referring to?"Emily wasn't frustrated with the AI.

She was frustrated with herself. She knew, somewhere in her gut, that she had done something wrong—but what? She had provided clear instructions. She had pasted relevant files. She had corrected mistakes.

Why did the AI keep forgetting?The answer, which Emily would discover after three more failed sessions and a late-night deep dive into transformer architecture papers, was both simple and profound: she had been treating the AI's context window like an infinite notebook when it was actually a finite whiteboard that was constantly being erased from the top down.This chapter is the story of that discovery. It is the foundation upon which every other technique in this book is built. If you skip this chapter, the rest of the book will still work—but you will be applying tactics without understanding the strategy. And in the world of AI context management, strategy is everything.Welcome to the 70% Rule.The Brain in the Jar Every large language model you interact with—GPT-4, Claude, Gemini, Llama—shares a fundamental limitation that no amount of clever engineering can completely overcome. They are, to use a metaphor that will recur throughout this book, brains in jars.Imagine a brilliant mathematician who has no long-term memory.

Every time you speak to her, she forgets everything that happened more than a few minutes ago. She can solve complex problems, write beautiful proofs, and explain difficult concepts—but only using the information you give her in this exact conversation, right now, and only as much of it as can fit on a small whiteboard in front of her. Once the whiteboard fills up, old information starts falling off to make room for new information, whether you still need it or not.That is your AI. It is not stupid. It is not lazy.

It is amnesiac by design.The technical term for this whiteboard is the context window—the number of tokens (roughly, words or sub-words) that the AI can consider at any single moment. When you paste a 5,000-line file into a chat, you are not "uploading" it to the AI's memory. You are writing it on the whiteboard. When you ask a follow-up question, that question also goes on the whiteboard. When the AI generates a response, that response goes on the whiteboard too.And here is the critical insight that changes everything: the whiteboard has a fixed size, and the oldest information falls off first.When you paste a long error log, then ask a question, then the AI responds, then you paste another file—every single one of those actions consumes space.

At some point, the AI stops remembering your very first instruction. Not because it wants to. Not because it is being difficult. Because the mechanism that makes it intelligent—the attention system that connects words to other words—has a physical limit built into its architecture.The Architecture of Forgetting To understand why the 70% Rule works, you need to understand just enough about transformer architecture to be dangerous. I promise to keep the math to a minimum.A transformer-based LLM processes tokens in parallel through something called attention.

When you give the AI a prompt, every token in that prompt pays attention to every other token. This is what allows the AI to understand that in the sentence "Alice gave Bob her book," the word "her" refers to Alice, not Bob. The attention mechanism connects related concepts across the entire context window.But attention has a cost. The computational complexity of attention grows quadratically with context length. Twice as many tokens means four times as much computation.

Four times as many tokens means sixteen times as much computation. This is why context windows are not infinite—they are engineering trade-offs between memory and speed.When you exceed the context window, the model simply stops seeing the oldest tokens. There is no warning. No "sorry, I forgot your first instruction." The tokens are dropped from the attention calculation, and from the perspective of the model, they never existed.This is called context decay, and it has five unmistakable symptoms:Symptom 1: Repetition. The AI starts asking questions it already asked ten minutes ago.

"What framework are you using?" "What is the name of the main function?" This is not the AI being lazy—it is the AI genuinely having lost that information.Symptom 2: Ignored constraints. You explicitly said "do not modify the database schema," but the AI suggests a migration that drops a table. The constraint fell off the whiteboard, and the AI no longer knows it exists.Symptom 3: Hallucinated file names. The AI starts referring to User Authenticaton Service.js when your file is actually named User Authentication Service.js. The correct spelling fell off the whiteboard, and the AI is guessing.Symptom 4: Lost variable references.

The AI suggests code that uses user Data when your variable is named user Info. The mapping between the two fell off the whiteboard.Symptom 5: Basic setup amnesia. The AI asks "what programming language are we using?" forty minutes into a session. This is the nuclear warning sign that context decay has progressed to catastrophic levels.If you have experienced any of these symptoms—and every developer who has spent more than an hour with an AI coding assistant has—you have been the victim of context decay. And like Emily in our opening story, you probably blamed yourself.You should not have.

You just did not know the rule.The 70% Rule: Why Waiting Is Losing Here is the rule that will save you hundreds of hours of frustration over the course of your career:Compact or reset when your context window reaches 70% usage. Never let it exceed 80%.This is not a suggestion. It is not a best practice. It is a hard law of working effectively with LLMs, derived from empirical testing across thousands of coding sessions and multiple model architectures.Why 70%? Why not 50% or 90%?Let me walk you through the reasoning.The 50% Trap: Some engineers, being naturally conservative, advocate compacting at 50%.

Their logic is sound—earlier is safer—but it is also wasteful. If you compact at 50%, you are discarding half of your available context window. Over a long session, you will compact…

This is the end of the free sample. Get the eBook to keep going. Buy now

About this book

Provide effective context to AI for better code generation results.

Details

Author
Dorris Aracely
Publisher
SamEnrico
Language
English
Genre
Non-Fiction, AI Operator
Released
2026-05-30
Pages (approx.)
150
Available as
eBook, Audiobook

Read better in the ZLOADR app

Your eBooks on your phone or tablet. Sign in with your SamEnrico account and start reading.

More by Dorris Aracely

See all

You may also like

See all