Context Engineering: Designing Prompts That Stay Fast, Accurate, and Cheap
Why stuffing a 200K window degrades accuracy, how attention thins out over long transcripts, and the layer ordering that keeps cache hits near 100%.
Prompt engineering writes one message; context engineering manages state
Context engineering treats the context window as scarce working memory. Every token competes for attention, grows the KV cache , and adds latency.
Context rot: why more tokens can make a smart model dumber
Because self-attention softmax splits a fixed 1.0 weight budget across every token, piling on raw logs and stale tool outputs dilutes probability mass onto distractors. Deleting low-signal context often makes the model noticeably sharper.
Static first, dynamic last: ordering blocks for cache hits
Due to the causal attention mask , changing one byte near the top invalidates every cached tensor below it. Place static rules and tools first, and volatile timestamps or queries last to protect Prompt Caching (and avoid stray boundary spaces shown in Tokenization ).
Surviving long horizons: clearing and compaction
Three lightweight habits keep 60-step agent loops sharp without blowing the budget: replace old tool dumps with one-line placeholders, run anchored compaction around 70% capacity, and offload noisy searches to scratchpads or subagents.