|
9 | 9 | from strands.models import BedrockModel, CacheConfig |
10 | 10 | from strands.types.content import ContentBlock |
11 | 11 |
|
| 12 | +# Model ID used for prompt-caching TTL integration tests. Per |
| 13 | +# https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html |
| 14 | +# the models that officially support 1h TTL on CachePoint are |
| 15 | +# Claude Opus 4.5, Claude Haiku 4.5, and Claude Sonnet 4.5. Using Sonnet 4.5 |
| 16 | +# here for longer expected support lifecycle than Haiku. |
| 17 | +_CACHE_TTL_MODEL_ID = "us.anthropic.claude-sonnet-4-5-20250929-v1:0" |
| 18 | + |
12 | 19 |
|
13 | 20 | @pytest.fixture |
14 | 21 | def system_prompt(): |
@@ -589,10 +596,12 @@ def test_prompt_caching_cache_tools_ttl(): |
589 | 596 | prefix because Bedrock's tool-prefix cache threshold varies by model and region. |
590 | 597 | The critical behavior under test here is that the TTL field is accepted end-to-end. |
591 | 598 |
|
592 | | - Uses Claude Haiku 4.5 which supports TTL in CachePointBlock on Bedrock. |
| 599 | + Uses Claude Sonnet 4.5 which supports TTL in CachePointBlock on Bedrock per |
| 600 | + https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html |
| 601 | + (Claude Opus 4.5, Claude Haiku 4.5, and Claude Sonnet 4.5 all support 1h TTL). |
593 | 602 | """ |
594 | 603 | model = BedrockModel( |
595 | | - model_id="us.anthropic.claude-haiku-4-5-20251001-v1:0", |
| 604 | + model_id=_CACHE_TTL_MODEL_ID, |
596 | 605 | streaming=False, |
597 | 606 | cache_tools="default", |
598 | 607 | cache_tools_ttl="5m", |
@@ -624,10 +633,11 @@ def test_prompt_caching_cache_config_auto_with_ttl(): |
624 | 633 | Verifies that the cache point appended to the last user message by _inject_cache_point |
625 | 634 | carries the configured TTL, and that Bedrock accepts the request. |
626 | 635 |
|
627 | | - Uses Claude Haiku 4.5 which supports TTL in CachePointBlock on Bedrock. |
| 636 | + Uses Claude Sonnet 4.5 which supports TTL in CachePointBlock on Bedrock per |
| 637 | + https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html |
628 | 638 | """ |
629 | 639 | model = BedrockModel( |
630 | | - model_id="us.anthropic.claude-haiku-4-5-20251001-v1:0", |
| 640 | + model_id=_CACHE_TTL_MODEL_ID, |
631 | 641 | streaming=False, |
632 | 642 | cache_config=CacheConfig(strategy="auto", ttl="5m"), |
633 | 643 | ) |
@@ -662,10 +672,11 @@ def test_prompt_caching_aligned_1h_ttl_across_checkpoints(): |
662 | 672 | This test sets 1h TTL on all three checkpoints simultaneously and verifies the |
663 | 673 | call succeeds. |
664 | 674 |
|
665 | | - Uses Claude Haiku 4.5 which supports 1h TTL. |
| 675 | + Uses Claude Sonnet 4.5 which supports 1h TTL per |
| 676 | + https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html |
666 | 677 | """ |
667 | 678 | model = BedrockModel( |
668 | | - model_id="us.anthropic.claude-haiku-4-5-20251001-v1:0", |
| 679 | + model_id=_CACHE_TTL_MODEL_ID, |
669 | 680 | streaming=False, |
670 | 681 | cache_tools="default", |
671 | 682 | cache_tools_ttl="1h", |
|
0 commit comments