Context Engineering: Windows, Budgets, Memory, and Retrieval

Prompt engineering is a subset. Context engineering is the whole game. A prompt is a string you type. Context is everything that goes into the model's window: system instructions, retrieved documents, tool definitions, conversation history, few-shot examples, and the prompt itself. The best AI engineers in 2026 are context engineers. They decide what goes in, what stays out, and in what order.

Build 1.5 hr Python

Prerequisites: Phase 10 (LLMs from Scratch), Phase 11 Lesson 01-02

#Learning Objectives

  • Calculate token budgets across all context window components (system prompt, tools, history, retrieved docs, generation headroom)
  • Implement context window management strategies: truncation, summarization, and sliding window for conversation history
  • Prioritize and order context components to maximize the model's attention on the most relevant information
  • Build a context assembler that dynamically allocates tokens based on query type and available window space
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.