CourseAgentic AI Engineer: The Complete Course · Module 7: Context Engineering · part 42 of 97
Part 42 · Module 7: Context Engineering

Lab: Budgets, compaction and notes for the shift

37 min read·13 Oct 2026
Module 7 · Lab · About 70 minutes · Needs: the Module 3 lab's tools.py, and lessons 1 and 2 (token budgets per section; compact_line, Notes, fresh, subagent and reuse)

What you are building

RETURNS-DESK/ AFTER THIS LAB model scripted or real context.py budget, compact, notes, fresh, sub-agent tools.py Module 3's, imported BrightCartSystems notes.json open items 5 tests
The finished piece: one new file of your code (blue) decides what the model (amber) sees on each call, goes through Module 3's tools.py (grey, kept as it was) and keeps the shift's memory in notes.json.

This lab moves the module's code into the returns-desk/ repository as one new file, returns_desk/context.py, that imports Module 3's tools.py and never replaces it. It holds a budget per section, compaction that keeps every id, a notes file behind two tools, fresh contexts, a read-only sub-agent, and a shift runner whose build hook decides what each call sees. Five tests pin it. One fact is traced throughout: R-1001's $129.00 refund on order 5521, waiting for Marta. Everything at BrightCart is simulated.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.