@@ -314,7 +314,11 @@ async def test_cache_point_adds_cache_control(allow_model_requests: None):
314314 {
315315 'role' : 'user' ,
316316 'content' : [
317- {'text' : 'Some context to cache' , 'type' : 'text' , 'cache_control' : {'type' : 'ephemeral' }},
317+ {
318+ 'text' : 'Some context to cache' ,
319+ 'type' : 'text' ,
320+ 'cache_control' : {'type' : 'ephemeral' , 'ttl' : '5m' },
321+ },
318322 {'text' : 'Now the question' , 'type' : 'text' },
319323 ],
320324 }
@@ -339,8 +343,8 @@ async def test_cache_point_multiple_markers(allow_model_requests: None):
339343
340344 assert content == snapshot (
341345 [
342- {'text' : 'First chunk' , 'type' : 'text' , 'cache_control' : {'type' : 'ephemeral' }},
343- {'text' : 'Second chunk' , 'type' : 'text' , 'cache_control' : {'type' : 'ephemeral' }},
346+ {'text' : 'First chunk' , 'type' : 'text' , 'cache_control' : {'type' : 'ephemeral' , 'ttl' : '5m' }},
347+ {'text' : 'Second chunk' , 'type' : 'text' , 'cache_control' : {'type' : 'ephemeral' , 'ttl' : '5m' }},
344348 {'text' : 'Question' , 'type' : 'text' },
345349 ]
346350 )
@@ -389,7 +393,7 @@ async def test_cache_point_with_image_content(allow_model_requests: None):
389393 {
390394 'source' : {'type' : 'url' , 'url' : 'https://example.com/image.jpg' },
391395 'type' : 'image' ,
392- 'cache_control' : {'type' : 'ephemeral' },
396+ 'cache_control' : {'type' : 'ephemeral' , 'ttl' : '5m' },
393397 },
394398 {'text' : 'What is in this image?' , 'type' : 'text' },
395399 ]
@@ -466,7 +470,7 @@ def tool_two() -> str: # pragma: no cover
466470 'name' : 'tool_two' ,
467471 'description' : '' ,
468472 'input_schema' : {'additionalProperties' : False , 'properties' : {}, 'type' : 'object' },
469- 'cache_control' : {'type' : 'ephemeral' },
473+ 'cache_control' : {'type' : 'ephemeral' , 'ttl' : '5m' },
470474 },
471475 ]
472476 )
@@ -496,7 +500,7 @@ async def test_anthropic_cache_instructions(allow_model_requests: None):
496500 {
497501 'type' : 'text' ,
498502 'text' : 'This is a test system prompt with instructions.' ,
499- 'cache_control' : {'type' : 'ephemeral' },
503+ 'cache_control' : {'type' : 'ephemeral' , 'ttl' : '5m' },
500504 }
501505 ]
502506 )
@@ -540,12 +544,12 @@ def my_tool(value: str) -> str: # pragma: no cover
540544 'required' : ['value' ],
541545 'type' : 'object' ,
542546 },
543- 'cache_control' : {'type' : 'ephemeral' },
547+ 'cache_control' : {'type' : 'ephemeral' , 'ttl' : '5m' },
544548 }
545549 ]
546550 )
547551 assert system == snapshot (
548- [{'type' : 'text' , 'text' : 'System instructions to cache.' , 'cache_control' : {'type' : 'ephemeral' }}]
552+ [{'type' : 'text' , 'text' : 'System instructions to cache.' , 'cache_control' : {'type' : 'ephemeral' , 'ttl' : '5m' }}]
549553 )
550554
551555
0 commit comments