feat(cache): add TTL support to CachePoint for prompt caching#1660
feat(cache): add TTL support to CachePoint for prompt caching#1660kpx-dev wants to merge 6 commits intostrands-agents:mainfrom
Conversation
Add optional ttl field to CachePoint TypedDict to support AWS Bedrock's cache TTL configuration. The field accepts "5m" or "1h" values as specified in the Bedrock API. Updated BedrockModel to preserve ttl field when formatting cache point content blocks. Includes tests for TTL preservation and backward compatibility. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Head branch was pushed to by a user without write access
|
FYI this PR fails label size: https://github.com/strands-agents/sdk-python/actions/runs/22110060966 . Not sure if CI needs update or label input needs update |
zastrowm
left a comment
There was a problem hiding this comment.
One last nit (imports) - looks good
mkmeral
left a comment
There was a problem hiding this comment.
I'll approve. I want to try following up with strands command for nits, let's see how that works. the only nit is the import in the test
|
@mkmeral ing test failed due to the streaming model doesn't support 1hr, only 5m (not all model support both): https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html#prompt-caching-models So I updated the PR to target a specific model only. |
|
@kpx-dev I think it's more of a model limitation rather than streaming/nonstreaming difference, like the model list you sent. The problem was the default bedrock model id we use is sonnet 4, which doesnt support 1hr TTL. But either way, as long as the integ tests pass, I'm happy 😅 |
@mkmeral yea make sense. Looks like I need 2 approval before it can trigger CI for ing test? |
Description
Add optional ttl field to CachePoint TypedDict to support AWS Bedrock's cache TTL configuration. The field accepts "5m" or "1h" values as specified in the Bedrock API. Updated BedrockModel to preserve ttl field when formatting cache point content blocks. Includes tests for TTL preservation and backward compatibility.
Doc shows API supports ttl option now:
https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_CachePointBlock.html
launch announcement:
https://aws.amazon.com/about-aws/whats-new/2026/01/amazon-bedrock-one-hour-duration-prompt-caching/
more details:
https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html
Related Issues
#1243
Documentation PR
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.