13 / 87 · 02 AI-Augmented Test Design · Context Feeding Strategies← prev⊞ allnext →☰ Read as one page
3.4Anti-Pattern: The Context Dump
Do not paste your entire codebase into the prompt. LLMs degrade with irrelevant context. A focused 200-line excerpt produces better tests than a 5000-line dump.
This is called the needle-in-haystack problem -- the more hay, the harder the LLM works to find the needle. Research from 2024-2025 consistently shows that models perform best when relevant context is placed at the beginning or end of the prompt, and performance degrades with large amounts of irrelevant middle content.
Symptoms of Context Overload
- Generated tests reference functions from the wrong file
- Tests mix styles from different parts of the codebase
- The LLM "forgets" constraints mentioned early in the prompt
- Output is shorter and less detailed than expected (model ran out of output tokens processing bloated input)
The Fix: Context Windowing
Instead of dumping everything, use a context window approach:
Step 1: Feed the spec (Priority 1) -- generate initial tests
Step 2: Review output -- identify style mismatches
Step 3: Feed 2-3 existing tests as style examples (Priority 2) -- regenerate
Step 4: Review output -- identify missing domain rules
Step 5: Add domain constraints (Priority 3) -- regenerate specific tests
This iterative approach keeps each prompt focused and produces better results than a single massive prompt.