Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Long sessions: lost instructions and drift
card 2 of 6
Dilution, compaction, pollution
builds on: What the agent sees: its context
**Dilution:** your turn-1 rule is now a few lines among tens of thousands of tokens of files and test output. As context grows, models follow such instructions less reliably, especially when recent material (a failing test, the current file) pulls another way. **Compaction:** when the context fills, the tool swaps old turns for a summary. The summary keeps the task but can drop 'minor' rules. **Pollution:** failed attempts stay in context, and the agent reasons from them. **Later cost:** rule breaks land quietly in a change you trusted.
Terms on this card
- context
- Everything in the model's input for the current step: your messages, instruction files, files it has read and tool outputs.
- turn
- One exchange in a session: your message or a tool result, plus the agent's response to it.
- tokens
- The small chunks of text a model reads and writes. Context size and limits are measured in tokens, roughly three-quarters of a word each.
- Compaction
- The process of shrinking a full context by summarising older turns. Details the summary leaves out are gone for the agent.
- Later cost
- The concrete damage a shortcut does after merge, such as a hidden bug, data corruption or maintenance burden.
Lesson goal: Explain how a filling context weakens attention to early constraints, how summarising or compacting the context can drop them, and how a pile of failed attempts pollutes later reasoning. Recognise drift when the agent starts violating rules it followed at the start. ·
the whole lesson