This public repository contains the companion material for all 12 chapters of Cache Engineering for AI Agent Harnesses. The source code and fixtures are original, synthetic teaching examples. They are not production security controls or empirical performance benchmarks.
Each chapter folder contains a self-contained laboratory guide, exercise questions, checked solutions and its runnable Python script. Read the chapter, attempt the questions, then use the checked solutions to review your reasoning.
| Chapter | Topic | Companion material | Python lab |
|---|---|---|---|
| 1 | The Cache Problem in Agent Harness Engineering | Laboratory, questions and answers | Source code |
| 2 | Caching Taxonomy and Memory Hierarchy | Laboratory, questions and answers | Source code |
| 3 | Prompt Prefix Caching and Stable Context Design | Laboratory, questions and answers | Source code |
| 4 | Transformer KV-Cache and Attention Serving | Laboratory, questions and answers | Source code |
| 5 | Paged Attention, Quantisation and KV Eviction | Laboratory, questions and answers | Source code |
| 6 | Semantic Caching and Similarity Thresholds | Laboratory, questions and answers | Source code |
| 7 | Retrieval, RAG and Vector-Store Cache Strategies | Laboratory, questions and answers | Source code |
| 8 | Tool, API and Multi-Agent Result Caching | Laboratory, questions and answers | Source code |
| 9 | Invalidation, Consistency, Freshness and Provenance | Laboratory, questions and answers | Source code |
| 10 | Security, Tenant Isolation and Cache Poisoning | Laboratory, questions and answers | Source code |
| 11 | Cost, Latency, Energy and Adaptive Cache Policies | Laboratory, questions and answers | Source code |
| 12 | Benchmarking, Replay, Observability and Production Architecture | Laboratory, questions and answers | Source code |
Requirements: Python 3.10 or later, with the standard library. No API keys, external services, network access or third-party packages are required by the supplied synthetic labs.
From the repository root, run a chapter's script, for example:
python3 chapters/01/helix_ch01.pyRun all scripts from the repository root with:
python3 scripts/run_all_labs.pyThe verification workflow compiles and runs every exercise script in isolation. These checks confirm program behaviour only within its stated synthetic assumptions.
- The book manuscript remains in the cache repository; its repository may require author access.
- This repository is the canonical home for hands-on laboratories, runnable code, exercise questions and checked solutions.
- Architecture diagrams and in-text conceptual notation remain in the book because they are explanatory content rather than standalone exercise code.
- The original chapter's limitations, assumptions and examples are preserved in each companion guide; readers should not extrapolate synthetic outputs to real deployments.
Open a chapter from the table above. Changes to the manuscript's learning objectives should be reflected in the corresponding chapter guide and Python lab.