feat(bedrock): add prompt caching for supported models#1360
Merged
krissetto merged 1 commit intodocker:mainfrom Jan 19, 2026
Merged
feat(bedrock): add prompt caching for supported models#1360krissetto merged 1 commit intodocker:mainfrom
krissetto merged 1 commit intodocker:mainfrom
Conversation
Assisted-By: cagent
Contributor
|
This generally looks good to me, thanks for the contribution! ❤️ @dgageot since you've been deep diving on anthropic caching bits lately, you might be interested in taking a look here and maybe comparing bedrock to some of the tests you've been doing with anthropic's api |
Contributor
|
Seems to work fine, I'm merging this |
krissetto
approved these changes
Jan 19, 2026
krissetto
reviewed
Jan 19, 2026
Comment on lines
+136
to
+152
| func detectCachingSupport(ctx context.Context, model string) bool { | ||
| store, err := modelsdev.NewStore() | ||
| if err != nil { | ||
| slog.Debug("Bedrock models store unavailable, prompt caching disabled", "error", err) | ||
| return false | ||
| } | ||
|
|
||
| modelID := "amazon-bedrock/" + model | ||
| m, err := store.GetModel(ctx, modelID) | ||
| if err != nil { | ||
| slog.Debug("Bedrock prompt caching disabled: model not found in models.dev", | ||
| "model_id", modelID, "error", err) | ||
| return false | ||
| } | ||
|
|
||
| return m.Cost != nil && (m.Cost.CacheRead > 0 || m.Cost.CacheWrite > 0) | ||
| } |
Contributor
There was a problem hiding this comment.
this is something we can put in the modelsdev store as it could be useful for all providers
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.
Prompt caching is automatically enabled for models that support it (detected via models.dev) to reduce latency and costs. System prompts, tool definitions, and recent messages are cached with a 5-minute TTL.
To disable:
P.S. Benchmarked with
examples/pr-reviewer-bedrock.yaml: 92% cache read vs 8% cache write.Assisted-By: cagent