feat(models): add configurable TTL for Bedrock cache points#2042
Open
mattdai01 wants to merge 1 commit intostrands-agents:mainfrom
Open
feat(models): add configurable TTL for Bedrock cache points#2042mattdai01 wants to merge 1 commit intostrands-agents:mainfrom
mattdai01 wants to merge 1 commit intostrands-agents:mainfrom
Conversation
Support 1-hour and 5-minute TTL options for Bedrock prompt caching. This allows users to extend cache lifetime beyond the default 5 minutes for supported models (Claude Opus 4.5, Haiku 4.5, Sonnet 4.5). - Add `ttl` field to `CacheConfig` for messages cache point - Add `cache_tools_ttl` field to `BedrockConfig` for tools cache point - Add optional `ttl` field to `CachePoint` TypedDict - Pass through TTL on user-supplied cachePoint blocks
Contributor
|
Is this PR related to #1219 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Author
|
I think we no longer have pass through on the cachePoint right? If you look at the _format_request_message_content function in the PR, it seems that it only passes through type currently, and drops ttl. now the behavior is that it drops everything except type and ttl. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support 1-hour and 5-minute TTL options for Bedrock prompt caching. This allows users to extend cache lifetime beyond the default 5 minutes for supported models (Claude Opus 4.5, Haiku 4.5, Sonnet 4.5).
ttlfield toCacheConfigfor messages cache pointcache_tools_ttlfield toBedrockConfigfor tools cache pointttlfield toCachePointTypedDictDescription
https://aws.amazon.com/about-aws/whats-new/2026/01/amazon-bedrock-one-hour-duration-prompt-caching/
Support 1-hour and 5-minute TTL options for Bedrock prompt caching. This allows users to extend cache lifetime beyond the default 5 minutes for supported models (Claude Opus 4.5, Haiku 4.5, Sonnet 4.5).
Previously, all cache points used Bedrock's default 5-minute TTL. With this change, users can configure extended TTL through:
Changes
Related Issues
Documentation PR
Type of Change
New feature
Testing
Unit tests passed, did a quick test checking cacheReadInputTokens in bedrock response was > 0 even after 5 min ttl when 1 hr was enabled.
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.