Prompt engineering is the inner product -- the instruction. Context engineering is the outer envelope -- what supporting information lives alongside it. System prompt, user message, retrieved chunks, tool definitions, memory snippets, prior turns: all compete for attention.
Failures of context engineering look like model bugs but aren't: the right answer was never in context, or was buried under noise, or placed where the model deprioritized it. Known effects: lost-in-the-middle (attention degrades for mid-context content), recency bias (last content has outsized influence), negative transfer (irrelevant retrieved docs degrade answers).
Example Prompt
Before composing the final prompt, assemble context in this priority order:
1. System prompt (role, rules, output format) -- stable across turns.
2. Summary of conversation state so far (if > 5 turns).
3. Top-k retrieved documents, with source attributions.
4. The user's current message, last.
If total context > 80% of window, prune from (3) first, then (2).When to use it
- RAG / agent systems where many inputs compete for attention
- Long-running sessions where conversation history exceeds window
- You've observed correct answers in context but wrong outputs
When NOT to use it
- Short single-turn prompts -- there's nothing to engineer
- You haven't measured -- premature optimization of context you don't understand
