Back to LLMs Mind Map
中文·English
LLMsID: context-engineering

Context Engineering

上下文工程
🎯Core Definition
context engineering treats the finite context window as a scarce resource to manage systematically — three pillars: (1) system prompts — fixed role, behavior rules, and format constraints stable across turns, versioned over time (e.g. "say so when unsure", output JSON structure); (2) memory tiers — layered by stability and recency: system rules > current user intent > conversation history > retrieved evidence and tool results, with long histories compressed (summarization-style context compaction) or truncated by relevance; (3) token budgets — explicit allocation of the window WW: instruction, history, retrieval, and reserved output WoutW_{\text{out}} such that iti+WoutW\sum_i t_i + W_{\text{out}} \le W, with cost approximated by cost=cintin+couttout\text{cost} = c_{\text{in}} \cdot t_{\text{in}} + c_{\text{out}} \cdot t_{\text{out}} — over budget means truncation or summarization.
💡Use Cases
prompt architecture for long conversations, RAG Q&A, and agent systems; multi-turn memory pruning and compression; cost optimization under per-token pricing; a favorite interview question — design context management for a 200K-window agent.
Key Problems Solved
unmanaged stuffing buries key instructions (echoing Lost-in-the-Middle), lets history bloat eat the budget, and scales cost linearly with context. Context engineering upgrades "how to write prompts" into "how to allocate the window", making the accuracy/cost/latency trade-off explicit.
🎯5 High-Frequency Exam Points
1
What are the principles of system-prompt design, and how do you layer it against user input and retrieval to avoid override?
2
Typical memory tiers and their lifetimes; when and how does context compaction trigger?
3
For a 200K window, how do you budget instruction/history/retrieval/output, and why must output be reserved?
4
Under per-token pricing, when do you resend long history vs use summary/prompt caching?
5
Context engineering vs Lost-in-the-Middle: where in the window should critical info go to maximize usage?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Context Engineering"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardLong-Context ExtensionNext CardClassic NLP Tasks

🔗 More LLMs Knowledge Cards

Agent & Tool CallingAlignment Tax & Preference DataScaled Dot-Product AttentionAttention Variants MHA/MQA/GQA