Context engineering: cut the noise
The session is huge and the agent is getting slow, vague, and expensive. Now what?
The idea inside
Context engineering is deciding what the model gets to see. When the window fills with noise, clear it, compact it, or start fresh; anything dropped can be reloaded, so it's safe.
After this lesson
You can do basic context engineering: decide when to clear, compact, or open a new session, and what survives each, so the model sees signal, not noise.
Where it leads
But re-sending all that context each turn sounds expensive, unless you cache it.
Inside this lesson
That's the real lesson stage, paused. Claim your pass to operate it.
See how AI actually works, end to end.
This lesson is one stop on the full arc. Unlock all of it, and keep it for life.
What you get
- The 34-lesson main path, a finishable route from a word to agents
- Goal tracks for using AI at work and building AI features
- Boss labs that make you apply a whole act, not just recognize it
- Spaced recall that brings each idea back before you forget
- Course memory: every term defined, with links to where it first appears
- A shareable capability card when you finish the main path
- Lifetime access on every device, every future lesson included
Not videos to watch. You predict, operate the machine, then prove it. That is why it stays.
99 interactive lessons and challenges. No videos, no code.
Free launch pass: lifetime access, no card needed
New here? The first lessons are free to try. Start with lesson 0.1
What this lesson shows
Context engineering is deciding what the model gets to see. When the window fills with noise, clear it, compact it, or start fresh; anything dropped can be reloaded, so it's safe.
The question it opens with
The session is huge and the agent is getting slow, vague, and expensive. Now what?
The walkthrough, in the lesson's own words
- Add a few turns. Guess what happens to answer quality first.
- Your session is huge, slow, and vague. What do you do?
- Try each move. Watch the bar, the quality meter, and what survives.
- Drop the noise, keep the signal, restart when a thread is done.
- Before you fill it past halfway: what happens to the agent's answer quality?
- Right, it sags, it doesn't break. Replies get vaguer and less accurate, even on easy tasks. Add turns and watch.
- It doesn't stay high or crash to zero, it quietly sags: vaguer, less accurate, even on easy tasks. Add turns and watch.
- The context window is a fixed budget, not memory: system prompt + tools + the whole chat history + files + your message, every single turn. As it fills, the model gets slower, pricier, and less accurate. Anthropic calls this context rot, the same sag you watched in 5.4, now inside an agent session.
- Replies are vague and every turn costs more. Which move keeps your progress but shrinks the window?
- Studies find models recall the very start and very end of a long window better than the middle, the "lost in the middle" effect. A shorter, focused context keeps the parts that matter where the model attends best.
- Pruning is safe: files and CLAUDE.md, the agent's own notes file (you will meet it properly in 6.16), live OUTSIDE the window and reload on demand. Only the live chat vanishes, the model can always re-read what it needs.
- Context engineering is the whole job of deciding what fills the window: the instructions, your request, retrieved documents, memory, tool results, and the conversation so far. The model can only reason about what is in the window, so what you put there is the real lever. Cutting the noise is one move. Letting an agent fetch its own context (next act) is another.
- Late in a long agent session, the replies turn vague and start missing things you said earlier. Why does answer quality sag, and what's the move?
- As the context window fills, accuracy quietly degrades even on easy tasks, which is context rot. Run /compact to fold the history into a short summary and keep going, or /clear when the chat is full of dead ends. Your files and CLAUDE.md live outside the window, so pruning is safe and the agent can re-read what it needs.
- The quality curve is an estimated trend of context rot, not a live measurement.
- New session: a clean window; files + memory reload from outside on demand.
Key takeaway
You engineer the context: drop the noise, keep the signal, restart when a thread is done, so the model reasons over what matters, not clutter.
What you can do after this lesson
You can do basic context engineering: decide when to clear, compact, or open a new session, and what survives each, so the model sees signal, not noise.
Check yourself: Your session is bloated and the agent is getting vague. Best first move?
- Clear or compact the context(correct)
- Paste in even more files
- Repeat yourself louder
- Wait for it to reset on its own
A bloated window buries the signal. Clearing or compacting it restores focus; piling on more files only makes it worse.
Prefer reading first? This lesson has a companion explainer: Context engineering
Where it leads: But re-sending all that context each turn sounds expensive, unless you cache it.
This is the written summary. The lesson itself is interactive: you predict, drag and operate the mechanism above, and the reveal answers you.