Lesson 3 of 6
Send relevant context, not the whole repo
Choose targeted files, search hits, and short handoffs instead of resending the repository or full chat history by habit, and know when a summary is too lossy.
Default paste is usually the expensive one
Agents often reread src/, lockfiles, old transcripts, and the last failing log in full on every turn. That grows occupancy even when most bytes never affect the edit. Anthropic’s context-window guide is blunt: more context is not automatically better; as token count grows, accuracy can degrade (“context rot”). The same pile also raises billed input.
Before a run, name what the model must see: the brief, the files in the write set, and the exact failing assertion. Everything else is a candidate to leave out until a search or a citation proves it is needed. Do not start by zipping the repo into the prompt.
Prefer ranges, search, and excerpts
Give path plus line range (src/model.ts L40–90), a rg/grep hit list, or a retrieved excerpt — not cat of every file. Allow scoped discovery when paths are unknown; constrain the search root and output length. A file-name inventory can be useful and is not the same as sending every file’s contents. When you retrieve, paste the passage and its locator (path, function name), not “the docs somewhere.”
Re-sending the entire conversation because “the model might need it” is the same habit. Keep a handoff of facts: decision, files touched, command output, open questions. Drop compliment loops and repeated file dumps. If a later turn needs a file again, read that file; do not hope a stale paste is still true.
Summaries lose the details that fail tests
Summarisation is a tool, not a virtue. It is the wrong move when the missing detail is the acceptance criterion: exact error text, a 160-character limit, a storage key, a header name, or a permission rule. If you summarise those into “validation exists,” the agent will invent a different rule and burn retries.
Keep verbatim: numeric limits, error strings the tests assert, schema fields, and safety instructions. Summarise: long narrative background, already-merged discussion, and logs after you have extracted the failing line. If a summary would change what “pass” means, do not summarise it.
Compare a fat context pack to a thin one
For one task, build two packs. Pack Fat: whole file(s) plus leftover chat. Pack Thin: brief + line ranges + the failing test snippet + a 10-line handoff. Count input tokens (count API, tokenizer, or logged input/prompt tokens). Re-run if you can; otherwise compare pack sizes and predict tool calls (thin packs usually cause targeted reads, which you should still log).
Example / simulated: Fat occupancyIn 41 000 vs Thin 6 200; both still included the failing assertion. Your numbers will differ. If Thin dropped the assertion, it is not thinner — it is incomplete.