Lesson 4 of 6 · 4 min read
Prompt Caching for Agents
Prompt caching reuses the provider's computation for a prefix identical to one it processed recently, which makes repeated input cheaper and faster. Agents benefit more than chat because each turn resends everything before it. The benefit depends on a byte-stable prefix: stable content first (system prompt, tools, fixed documents), history append-only, anything per-request or per-turn at the end. Timestamps, reordered tools, non-deterministic serialization and edits to earlier messages each turn a hit into a miss.
Get full Premium access · $25
All 19 topics with every worked answer, all lessons and courses, the full practice bank, and anything new that appears during your access.
6 months · One payment · No auto-renewal
Practise it as an interviewer asks it
What is context engineering, and why does an agent need it when the model already has a 200k-token window?What does an agent task cost? Show where the tokens, the seconds and the money go in one run, and what you would cut first.Your agent has a 200k-token window and falls apart at 55k. Why, and what do you change?Memory, context and retrieval: draw the difference for an assistant used for months.When does a second agent pay for itself?Find the right code in a two-million-line monorepo without flooding the context.