Free self-study · No account needed · Progress stays in this browser. Back it up before clearing site data or changing devices.

← All weeks

LLM Engineering / Week 06

Context Engineering

Build a conversation context manager. Apply one context manager to long conversations, with budget, compaction, and constraint-retention fixtures.

Your lessons

  1. 01

    Budgeting a model request

    60 minutes planned · 7 sections
    Start →
  2. 02

    Selecting useful evidence for context

    60 minutes planned · 7 sections
    Start →
  3. 03

    Compacting a conversation without losing decisions

    60 minutes planned · 7 sections
    Start →

// Put it into practice

A conversation context manager

  1. Download week06.py from a lesson's practice section. Follow its setup instructions before running it.
  2. Lesson 1: Build a token ledger and compare dropping old messages with preserving current constraints.
  3. Lesson 2: Answer a policy question from a small dated document set under a fixed token budget.
  4. Lesson 3: Compact a conversation containing a decision, a tentative option, and a revoked constraint.
  5. Run the supplied assertions and record actual results; a simulated contract check does not certify real model quality.
Download week 6 Python lab ↓

Read the script’s setup instructions and run it on your own computer. The website does not execute code or verify your results.

// Independent work

W06-LAB

Week 6: A conversation context manager

Apply one context manager to long conversations, with budget, compaction, and constraint-retention fixtures.

Extend the guided artifact rather than start a second project. Fresh-session tests preserve explicit decisions, uncertainty, revoked instructions, and source links.

What to produce

  • A conversation context manager
  • Setup commands, data or generation procedure, versions, and recorded outputs
  • Acceptance results and a precise limitation

Check your work

  • Fresh-session tests preserve explicit decisions, uncertainty, revoked instructions, and source links.
  • Each claimed execution is supported by actual saved output.
  • Fixture results and real model results are identified separately.
  • Setup and reproduction use the taught tools without private credentials.
Self-assessment rubric
Technical correctness · 35 points
Implementation or analysis follows the relevant technical mechanism and handles the stated case.
Evaluation and evidence · 30 points
Reproducible tests, appropriate baseline, and accurate interpretation.
Engineering quality · 20 points
Clear structure, safe boundaries, and usable reproduction instructions.
Explanation and reflection · 15 points
Explains tradeoffs, limitations, and next experiment with evidence.

// Retrieve before you reread

Week 6 knowledge check

Try all 6 questions. Check your answers, review the explanations, and retry whenever you like. Answers are checked on this device.

1. A 2048-token window reserves 256 output tokens. Complete serialized input measures 1800 tokens. Fits?
2. A request ledger counts characters but labels them model tokens. What must be corrected?
3. An old policy says 45 days; its replacement says 100 days with a project-green exception of 150. Project-green answer?
4. A deterministic first-match selector changes answers when documents reorder. What was measured?
5. A conversation chooses local output, considers a table tentatively, and revokes email delivery. Correct compaction?
6. After three compactions, a summary says email is preferred although email was revoked. What failed?

Next: week 7 →