Skip to content

Add ChatMessageExtensions with UsePromptCaching #4340

Open
gcarney-ai wants to merge 4 commits intoaws:developmentfrom
gcarney-ai:gcarney-ai/add-chat-message-extensions
Open

Add ChatMessageExtensions with UsePromptCaching #4340
gcarney-ai wants to merge 4 commits intoaws:developmentfrom
gcarney-ai:gcarney-ai/add-chat-message-extensions

Conversation

@gcarney-ai
Copy link

Description

I have added a new file named ChatMessageExtensions with a single extension: UsePromptCaching. This change creates AdditionalProperties on the message if it is not already populated, and adds CachePoint ContentBlock. I used the Prompt caching for faster model inference for reference. The UsePrompCaching method takes an optional parameter CacheTTL which allows users to pass in either 5Min or 1Hr...defaulting to 5 min.

Motivation and Context

Prompt caching is a crucial piece for both latency and cost optimization, by placing it in a public extension, it enables discovery and reduces duplicate code written by consumers.

Testing

No existing test fixtures for this project. But I manually tested each case.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@boblodgett boblodgett requested a review from normj February 25, 2026 18:31
@dscpinheiro dscpinheiro changed the base branch from main to development February 26, 2026 16:04
@boblodgett boblodgett requested review from jnunn-aws and removed request for normj March 3, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant