Back to AI Systems Engineer Mind Map
中文·English
🚀 AI Systems EngineerID: aie-context-budget-compaction

Context Budgeting & Memory Compaction

上下文预算分配与记忆 Compaction
🎯Core Definition
Context Window Token Budgeting & Progressive Memory Compaction treats the finite LLM context window as scarce RAM managed through strict partition budgeting and automatic memory compaction; the budget allocation matrix partitions total tokens (e.g. 8k/32k) into: Fixed System & Tool Definitions (20%), Dynamic Working Memory (50% for recent detailed tool/thought traces), Output Buffer (20% for generation), and Safety Margin (10%); Progressive Compaction triggers when working memory saturates: 1) Sliding Window Truncation (retaining recent KK turns), 2) Recursive Semantic Summarization (using cheap small LLMs to distill older turns into dense structured state summaries), and 3) Tool Output Pruning (stripping multi-page raw JSON responses down to essential fields while offloading full payloads to vector stores).
💡Use Cases
Multi-hour 50+ turn conversational agents, autonomous codebase refactoring, and continuous research systems.
Key Problems Solved
Naively appending conversation histories causes context window overflow, 'Lost in the Middle' attention degradation, and skyrocketing token fees; dynamic compaction ensures constant-memory, bounded-cost execution indefinitely.
🎯5 High-Frequency Exam Points
1
Diagram the 4-tier context window token budget partitioning and dynamic reallocation thresholds?
2
Explain how recursive summarization preserves structured task states, active constraints, and resolved sub-goals without data loss?
3
Explain the 'Lost in the Middle' attention bias and why placing critical system constraints at the beginning and end maximizes retrieval accuracy?
4
How should tool execution wrappers safely truncate massive 50k-token CLI logs or HTML payloads before passing them to the LLM?
5
How to structure conversation history sequentially to preserve static prompt prefixes and maximize cloud KV Cache reuse?
🔗Foundational Prerequisite Cards (Click to Review)
Updated 2026-08-14
🎯
Test Your Knowledge: Practice Questions for "Context Budgeting & Memory Compaction"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardLoop Hard Termination & Stagnation GuardsNext CardTool Validation, Idempotency & Fallbacks

🔗 More AI Systems Engineer Knowledge Cards

AIE vs MLE Competency ModelPrompt Chains & Jailbreak DefenseStructured Output & Constrained DecodingEval Benchmarks: RAGAS & SWE-bench