Skip to content

feat(cache): add TTL support to CachePoint for prompt caching#1660

Open
kpx-dev wants to merge 3 commits intostrands-agents:mainfrom
kpx-dev:feat-support-prompt-caching-ttl
Open

feat(cache): add TTL support to CachePoint for prompt caching#1660
kpx-dev wants to merge 3 commits intostrands-agents:mainfrom
kpx-dev:feat-support-prompt-caching-ttl

Conversation

@kpx-dev
Copy link

@kpx-dev kpx-dev commented Feb 10, 2026

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

  • [x ] I ran hatch run prepare

Checklist

  • [x ] I have read the CONTRIBUTING document
  • [ x] I have added any necessary tests that prove my fix is effective or my feature works
  • [x ] I have updated the documentation accordingly
  • [ x] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • [x ] My changes generate no new warnings
  • [ x] Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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>
mkmeral
mkmeral previously approved these changes Feb 17, 2026
@mkmeral mkmeral enabled auto-merge (squash) February 17, 2026 17:00
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

zastrowm
zastrowm previously approved these changes Feb 17, 2026
"""

type: str
ttl: NotRequired[Literal["5m", "1h"]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do any of the other providers support this? E.g. should anthropic have something similar?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For AWS specific models, some supported 5m, some supports 1h: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html

Looks like Anthropic does support its ttl:
https://platform.claude.com/docs/en/build-with-claude/prompt-caching#1-hour-cache-duration

Should we also implement it in this same PR or create a new one? Happy to research it and send update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have an integ test validating all of the values are valid for bedrock?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need this PR merged in before we can test ttl correctly via integ test? Do you have a better approach you suggest? I'm happy to add that now, but don't know how yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, you can update the integ test already, and it will run as approval wofkflow in this PR. See https://github.com/strands-agents/sdk-python/blob/main/tests_integ/models/test_model_bedrock.py

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool I added it on my last commit. How can I test it locally? I just push and see if CI picks up.

auto-merge was automatically disabled February 17, 2026 18:09

Head branch was pushed to by a user without write access

@kpx-dev kpx-dev dismissed stale reviews from zastrowm and mkmeral via 230ed7c February 17, 2026 18:09
@github-actions github-actions bot added size/s and removed size/s labels Feb 17, 2026
@kpx-dev kpx-dev requested review from mkmeral and zastrowm February 17, 2026 18:43
@kpx-dev
Copy link
Author

kpx-dev commented Feb 17, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants