AgenticGlossary
Context Engineering
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
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, where there's nothing to engineer
- You haven't measured; that's premature optimization of context you don't understand
Articles that use this
- Prompt Architecture for Managed Agent Runtimes: What Changes When You Stop Owning the Orchestration LoopAgentic
- When to Use Subagents: Delegation Prompts That Keep a Long-Context Agent FocusedAgentic
- Context Engineering for Agents: Manage What Your LLM Sees Across 50 Turns Without Losing the ThreadAgentic
- Context Rot: Why Long AI Chats Get Worse and When to Start FreshTechniques
- How to Prompt Reasoning Models: OpenAI's Seven-Part Prompt Structure, ExplainedTechniques

