promptdojo_

Prompt caching correctly — the variable input goes LAST — step 7 of 9

This agent runs 30-minute sessions, but the dev shipped without ttl, relying on the provider default. Anthropic's default cache TTL is 5 minutes — so this code re-writes its cache up to 6× per session instead of once, quietly overspending on every run.

Fix the cache_control to pass ttl: "1h" explicitly so the cache survives the whole session (and so the TTL is pinned regardless of any future provider default changes).

Expected output:

ttl: 1h
The break is on line 5 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.