Repository navigation
🪨 feat: Add Bedrock Prompt Caching Support - #8271
Conversation
|
@dustinhealy Hi there! Do you have any due dates for this? Thanks in advance |
Hi KiGamji, still need to write tests but planning to get this ready for review within the next couple days. |
|
Hopefully we'll see this merged in the next week 👍 |
It requires an upstream change for it to fully work: So we have to wait when that PR is tested/merged |
Note that the mentioned PR is adding cache point support only to |
|
@danny-avila @dustinhealy Hi there! Hope you consider this in any near time, as the mentioned PR was finally merged, and we would really like to see Bedrock with Prompt Caching! 👍 |
still waiting on package release for |
|
Lastly, rebase branch to latest (to resolve conflicts) |
c54a617 to
04e4335
Compare
|
|
|
@danny-avila @dustinhealy tagging for visibility too. We would like to see this, leading to huge cost savings! Thanks in advance for your work! |
|
any reason for this not being merged? |
not fully tested, will be part of next release a week from now. needs to be rebased with latest upcoming changes to dev branch |
|
@dustinhealy @danny-avila So this will be in the next release, right? :) |
|
@danny-avila Are there specific tests currently blocking this from being in the next release? Really looking forward to this feature, as I'm sure many others are. Anthropic has been severely tightening the belt on usage limits via subscriptions; general user sentiment seems to indicate that users are increasingly switching to Bedrock to access their models |
|
yeah, we are waiting for this too, as much as new Bedrock keys format support, and fixes for the PROXY env! |
|
Are there any blockers for this besides needing a rebase? |
The agents repo still needs a version bump for @langchain/aws in order for this feature to actually work + we still have to do some testing on the Bedrock side of things to make sure the prompt caching points are working as intended. I will rebase later today after I finish my current PR just to resolve the merge conflicts. Thanks all for your interest, we know this is highly anticipated feature, so we appreciate your patience in the meantime! |
Awesome, thank you. Your effort is greatly appreciated! |
I'm also very much looking forward to this feature being implemented, thank you @dustinhealy for your work on it! |
0daea04 to
cf0f9e8
Compare
|
@danny-avila Any chance to get this merged until October? I appreciate your time and effort in maintaining this huge project, but this PR is already two months old and it would need more effort for @dustinhealy to rebase and maintain it each time, unless it gets merged. Also, this is one of the mostly anticipated features by activity, along with conversation cost tracking (#9190, #8531), conversation pinning (#7550), PassKeys & E2EE, so I really hope you will give it some attention in the neartime. Thanks in advance! |
Very anticipated indeed!;) |
|
Would it be possible to also add this as an option for custom endpoints? |
|
With all the respect to Danny, I absolutely agree with this :/ |
|
#9798 seems to be dangling too |
|
With all due respect, dear Danny and the LibreChat Team, I believe this is not a serious approach for user-made contributions to such a project... |
|
A huge number of people and their users are waiting while being fed false promises. |
bbb3f1c to
415a652
Compare
|
Hey @dustinhealy - thanks for updating the feature branch. Hopefully we'll start to get some traction on this. |
415a652 to
d8bf695
Compare
|
Sorry for the wait on this. It's currently working but not for tool calling. @dustinhealy is looking into it |
Thank you for your work on this! |
cdb3cea to
83b76e0
Compare
|
It would be really amazing if you also review this, Danny: #8871 |
- fix: Update Bedrock Cache Control to Require cachePoint as a Separate Content Block - Modified the addBedrockCacheControl function to ensure cachePoint is added as a separate content block in the content array, rather than as a property of text objects. - refactor: move addBedrockCacheControl over to packages/api - ci: add tests for addBedrockCacheControl until full coverage reached
53cfea4 to
fbb9caa
Compare
* feat: Add Bedrock Cache Control Functionality - fix: Update Bedrock Cache Control to Require cachePoint as a Separate Content Block - Modified the addBedrockCacheControl function to ensure cachePoint is added as a separate content block in the content array, rather than as a property of text objects. - refactor: move addBedrockCacheControl over to packages/api - ci: add tests for addBedrockCacheControl until full coverage reached * ci: add test similar to example from the langchain PR * refactor: move addBedrockCacheControl logic and tests to agents repository * chore: remove extraneous comment * chore: update @librechat/agents dependency to version 3.0.12 * chore: update @librechat/agents dependency to version 3.0.13 * chore: update @librechat/agents dependency to version 3.0.14 * chore: update @librechat/agents to v3.0.15 * chore: update default value for prompt cache setting to true * refactor: set default promptCache to true for claude and nova models --------- Co-authored-by: Danny Avila <danny@librechat.ai>
* feat: Add Bedrock Cache Control Functionality - fix: Update Bedrock Cache Control to Require cachePoint as a Separate Content Block - Modified the addBedrockCacheControl function to ensure cachePoint is added as a separate content block in the content array, rather than as a property of text objects. - refactor: move addBedrockCacheControl over to packages/api - ci: add tests for addBedrockCacheControl until full coverage reached * ci: add test similar to example from the langchain PR * refactor: move addBedrockCacheControl logic and tests to agents repository * chore: remove extraneous comment * chore: update @librechat/agents dependency to version 3.0.12 * chore: update @librechat/agents dependency to version 3.0.13 * chore: update @librechat/agents dependency to version 3.0.14 * chore: update @librechat/agents to v3.0.15 * chore: update default value for prompt cache setting to true * refactor: set default promptCache to true for claude and nova models --------- Co-authored-by: Danny Avila <danny@librechat.ai>
* feat: Add Bedrock Cache Control Functionality - fix: Update Bedrock Cache Control to Require cachePoint as a Separate Content Block - Modified the addBedrockCacheControl function to ensure cachePoint is added as a separate content block in the content array, rather than as a property of text objects. - refactor: move addBedrockCacheControl over to packages/api - ci: add tests for addBedrockCacheControl until full coverage reached * ci: add test similar to example from the langchain PR * refactor: move addBedrockCacheControl logic and tests to agents repository * chore: remove extraneous comment * chore: update @librechat/agents dependency to version 3.0.12 * chore: update @librechat/agents dependency to version 3.0.13 * chore: update @librechat/agents dependency to version 3.0.14 * chore: update @librechat/agents to v3.0.15 * chore: update default value for prompt cache setting to true * refactor: set default promptCache to true for claude and nova models --------- Co-authored-by: Danny Avila <danny@librechat.ai>


Summary
Closes #7109
Adds a new parameter, Use Prompt Caching, for Bedrock endpoints, enabling cache points to be automatically embedded in messages sent to supported models
Change Type
Details
IntroducedaddBedrockCacheControlto insert cache points when Use Prompt Caching is enabled (api/app/clients/prompts/addBedrockCacheControl.js).Integrated logic into the Bedrock agent client so cache control is applied as appropriate (api/server/controllers/agents/client.js).Updated exports to makeaddBedrockCacheControlavailable (api/app/clients/prompts/index.js).promptCache(shown in UI as Use Prompt Caching) to Bedrock parameter settings and schema for configuration and validation (packages/data-provider/src/parameterSettings.ts,packages/data-provider/src/bedrock.ts).Testing
Test Configuration
Agent using AWS Bedrock endpoint with model: us.anthropic.claude-sonnet-4-20250514-v1:0 with Use Prompt Caching toggled on
Three message chain with high-token initial message (1000+ token) in order to trigger cache reads and cache writes.
Initial Input
Usage Metadata:
{ "inputTokens": 1794, "outputTokens": 26, "serverToolUsage": {}, "totalTokens": 1820 }Follow-up (triggers write to cache)
Usage Metadata:
{ "cacheReadInputTokenCount": 0, "cacheReadInputTokens": 0, "cacheWriteInputTokenCount": 1844, "cacheWriteInputTokens": 1844, "inputTokens": 4, "outputTokens": 58, "serverToolUsage": {}, "totalTokens": 1906 }Final follow-up (triggers read from cache)
Usage Metadata:
{ "cacheReadInputTokenCount": 1735, "cacheReadInputTokens": 1735, "cacheWriteInputTokenCount": 182, "cacheWriteInputTokens": 182, "inputTokens": 4, "outputTokens": 75, "serverToolUsage": {}, "totalTokens": 1996 }Checklist