Ch 4: Memory, Summaries, and Context Control
Remember the genius locked in a room from Chapter 1? This time, you have hired them to help plan a neighborhood street festival.
The job keeps growing. There are notes about the music lineup, food stalls, volunteer shifts, poster ideas, and a rain backup plan. Every new note you slide under the door goes into the same notebook, because the genius has to reread the notebook to remember where the festival stands.
At first that feels easy. A few pages are nothing. But after days of planning, the notebook starts to bulge. Old vendor replies, early budget guesses, half-finished shift charts, backup plans, reminders, corrections.
Then one afternoon you need to send one more important update, and there are almost no blank pages left.
Now the problem is not brains. The genius is still brilliant. The problem is room. If the notebook gets too crowded, the genius slows down, loses sight of the most useful parts, or cannot continue until space is cleared.
So you need memory moves:
- Tear out the oldest pages — fast, harsh, and full of loss.
- Replace a stack with one summary slip — keep the big picture, lose the exact wording.
- Put the full notebook on a shelf and keep going from a shorter copy — save every detail somewhere safe while the genius keeps today's essentials close.
That is what long memory work looks like. Even a genius needs a way to keep the important parts nearby without dragging every old page through every new decision.
When The Pages Run Low
Long jobs fill memory because every step leaves a trace behind.
For the street festival, that pile might look like this:
- Early on: you pick a date, reserve the street, and sketch a rough budget.
- A little later: food stall requests, poster drafts, and volunteer signups start stacking up.
- Later still: someone asks for a rain backup plan, another person changes the music order, and three volunteers swap shifts.
- Eventually: the notebook is so crowded that every new update feels heavy, and the genius has to search through old pages just to answer a simple question.
If you wait until the notebook is already bursting, work stalls. The genius may miss a promise, lose a detail that still matters, or need you to reopen old pages before the next move can be made.
That is why memory management is not a bonus feature. It is what lets a helper stay useful on jobs that last longer than one quick exchange.
You are the helper outside the room. The genius has been helping you plan the neighborhood street festival for days.
Order these memory moves from roughest on detail to gentlest
Drag to reorder, or use Tab + Enter + Arrow keys.
- Keep every page exactly as it is
- Throw away almost everything except the latest notes
- Replace older pages with one summary slip
- Put the full notebook on the shelf and continue from a shorter copy
Key Insight
Memory care is always a tradeoff between detail and room. Keep every page, and the notebook gets heavy. Condense too hard, and you may lose something that still matters.
There is no single best move. It depends on the kind of job you are doing:
- Short jobs — a rough cleanout may be enough because the latest notes matter most.
- Long, layered jobs — summary slips are the best default because they keep the shape of the story while freeing room.
- Risky moments — save a full shelf copy before you squeeze things further, so you can reopen the old details if needed.
The genius from Chapter 1 learned the note-passing loop. In Chapter 2, they gained errands. In Chapter 3, they learned to plan. Now, in Chapter 4, they learn how to stay steady during a long job by keeping memory usable instead of letting old pages pile up forever.
In Chapter 5, the genius will learn a new habit: changing something carefully instead of rewriting the whole page every time. That is how long jobs stay safe, not just organized.
What You Can Do Next
You now have the four building blocks of a core coding agent: a loop (Chapter 1), tools (Chapter 2), a planner (Chapter 3), and memory management (Chapter 4). This agent can accept complex coding requests, plan them, execute them with tools, and manage its own context over long sessions.
But this agent runs in your working directory. It writes files alongside your code. If it makes a mistake, you have to manually undo the changes. What if it corrupts a file? What if two agents are working on different tasks in the same directory?
Part II: Execution Lanes starts with Chapter 5: Safe File Editing and Patch Application, where you will learn to make changes safely using structured diffs instead of overwriting files.