feat(cache): add TTL support to CachePoint for prompt caching#1660
feat(cache): add TTL support to CachePoint for prompt caching#1660mkmeral merged 11 commits intostrands-agents:mainfrom
Conversation
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
|
Great fix for the Bedrock model path! There's an analogous issue in the LiteLLMModel path that would be worth including here or as a follow-up PR. The problemLiteLLMModel._format_system_messages() in src/strands/models/litellm.py also drops the ttl field from CachePoint when converting to cache_control: The fix:Why it mattersWhen using LiteLLMModel pointed at a Databricks external model endpoint (which proxies to AWS Bedrock), the cache_control field is forwarded verbatim to the endpoint via LiteLLM's DatabricksConfig. Bedrock supports "5m" and "1h" TTL values on Claude 4.5+ models. Without this fix, the TTL specified in CachePoint(ttl="1h") is silently dropped and Bedrock falls back to the default 5-minute TTL. Suggested tests (mirroring the structure of the new test_bedrock.py tests in this PR):
|
|
Assessment: Comment Clean, well-scoped feature addition that correctly adds optional TTL support to Review Categories
Nice contribution that addresses a real customer need (issue #1243) with a minimal, clean implementation. |
# Conflicts: # src/strands/types/content.py
|
Assessment: Comment The key feedback from the previous review ( Remaining items from previous review
Overall, this is in good shape for merge. The core changes are clean and well-tested across both Bedrock and LiteLLM paths. |
|
Thank you for your contribution @kpx-dev ! I've enabled auto-merge, once MacOS tests pass, it will merge. ps: Integ tests are failing due to setup issue, the added tests passed previously, so I am okay merging |
|
thank you @mkmeral . Looks like MacOS tests passed but not merging yet? Something is blocking it? |
|
thank you so much team! |
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.