AI Agents by HandAll problemsAbout

All problems › Python drill · easy · ~5 min

d02 · Add a cache breakpoint

copies token cost

Solve it in your browser →

d02 · Add a cache breakpoint (~5 min)

Mutation and references. Edit drills.py. Standard library only; no model calls, no API key.

def add_cache_breakpoint(messages):

Return a new message list where the last content block of the last message has "cache_control": {"type": "ephemeral"}.

If that message's content is a string, turn it into [{"type": "text", "text": <the string>}] first. messages and everything inside it must be left unchanged.

Failure messages are enough to go on, so leave the tests unread until you submit.

Starter code and hidden tests open in the editor. Nothing to install.