Welcome to the course on Context Engineering for AI. It covers the principles, techniques, and practices for building robust, reliable, and efficient AI systems — from a single well-designed prompt to autonomous agents running unattended.
2026 edition. The field reorganized substantially between 2023 and 2026. This edition follows that reorganization: it teaches four nested disciplines — prompt → context → harness → loop — and ends with a unifying architecture for agentic systems. See CHANGELOG.md for what changed from the previous edition.
Nine modules. Modules 1–4 build the foundation; 5–6 make systems that act and that you can trust; 7–8 cover the frontier and the architecture that ties it together; 9 covers making structure explicit — and what happens when systems start rewriting it themselves.
-
Module 9: Graph Engineering and Autonomous Meta-Harness Systems
- Lesson 1: Graph Engineering — Making Structure Explicit
- Lesson 2: Knowledge and Memory Graphs
- Lesson 3: Continuous Vector Memory Graphs
- Lesson 4: Execution Graphs — Orchestration as Structure
- Lesson 5: Standing Up the Four Graphs — A Practical Setup Guide
- Lesson 6: Autonomous Meta-Harness Systems
- Lesson 7: Governing Systems That Rewrite Themselves
The course ships a small, dependency-free reference harness in code/ — standard library only, no API key, no install.
cd code
python3 -m unittest discover -s tests -t . # 134 tests
python3 examples/03_agent_loop.py # the same model under two harnesses
python3 examples/09_meta_harness.py # a reward hack caught by the gateTen auto-graded exercises turn the reading into practice — you implement, the tests grade:
python3 exercises/check.py # grade all ten
python3 exercises/check.py ex04 # grade oneSix optional live-model labs show what the offline mock deliberately hides — real non-determinism, real cache counters, real injection. They need an API key and cost well under $1 in total; without a key they exit cleanly. See code/labs/.
The course validates itself. Everything above, plus links, task alignment, prose code blocks, and every diagram:
python3 tools/validate_course.py # 9 checks, the same ones CI runsIts test suite is the course's argument in falsifiable form. Each claim has a test that fails if the mechanism is removed — that a loop must not exit on self-report, that tool errors must never raise, that injection cannot amplify absent capability, that a 20-case eval set cannot detect a 10% change, that a graph must refuse an undeclared edge type, that superseding a fact must not destroy history, and that a held-out gate catches an optimizer fitting your evaluator. See code/README.md, including its honest limitations.
| File | What it's for |
|---|---|
| CHEATSHEET.md | Every decision the course asks you to make, on one page. Start here when building |
| ANTI_PATTERNS.md | Diagnostic reference organized by symptom — what you're seeing, what's causing it, and the fix people try first that doesn't work |
| INDEX.md | Concept → lesson → implementation |
| templates/ | The architecture spec, eval set, red-team cases, tool spec, compaction prompt, and AGENTS.md skeleton |
| code/exercises/ | Ten auto-graded exercises — implement, then python3 exercises/check.py |
| code/labs/ | Six optional live-model labs (API key, < $1 total) |
| tools/validate_course.py | The course's own harness: 9 checks, run by CI on every change |
| FINAL_PROJECT.md | Build, measure, and attack a complete agentic system |
| GLOSSARY.md | Definitions, including superseded terms marked (historical) |
| REFERENCES.md | Primary sources, with a note on which figures to trust |
| CHANGELOG.md | What changed in this edition, and why |
SOLUTIONS.md in each module |
Worked answers to the hands-on tasks |
- Python, read and write. Code examples are Python; the reference harness needs 3.10+.
- Comfort with an API client — HTTP requests, JSON, environment variables.
- No ML background required. Nothing here involves training a model.
- Helpful but not assumed: having built something with an LLM API and watched it behave badly in production. If you have, several lessons will land as recognition rather than instruction.
Roughly 35–44 hours including the hands-on tasks. Each module README states its own estimate, its learning outcomes, and a short Check yourself set.
Work the modules in order; each builds on the last. Do the hands-on tasks before reading the solutions — many are designed so the intuitive answer is the wrong one, and discovering that yourself is the point.
Then do the exercises. The reading tells you a loop must not exit on the model's self-report; ex04 fails until your loop actually refuses a model that claims success without doing the work. That gap is where the learning is.
Three paths through it:
| If you are… | Read |
|---|---|
| Building something now | CHEATSHEET.md → M1 L4 → M8 L4 → fill in templates/architecture-spec.md → return to the modules your thinnest planes need |
| Debugging something broken | ANTI_PATTERNS.md, by symptom |
| Learning the field properly | Modules 1→8 in order, hands-on tasks included, then the Final Project |
If you read only two lessons: Module 1, Lesson 4 is the map, and Module 8, Lesson 4 is the destination.
Techniques churn; frameworks churn faster. These have held across every model generation so far, and they are what the rest of the course implements:
- Context is finite and degrades. Every technique in Modules 3 and 4 exists because of this.
- Verification must live outside the agent. A system that grades its own homework will pass.
- Capability must be scoped. What an agent can do bounds what can go wrong — including what an attacker can make it do.
- You can't improve what you can't measure. Without evals, every change is a guess with a confident narrator.