- Newest
- Most votes
- Most comments
Your observation is spot on. While not explicitly detailed in the docs, it’s a known behavior in managed LLM environments: outputConfig (and specifically the JSON schema) is treated as part of the model's instruction state. Since the schema dictates how the model must structure its response, it is bundled into the cache key. Consequently, even if your system prompt remains identical, a change in the schema results in a different hash and a cache miss. To get a hit, the entire request configuration up to (and including) the cache_point must remain static.
Based on the available documentation, I cannot find explicit information about whether outputConfig is included in Bedrock's prompt caching key. The documentation describes outputConfig as an optional parameter that controls the output configuration for a model response in calls to Converse or ConverseStream, and it includes a textFormat property for structured output parameters. However, the interaction between outputConfig (specifically JSON schema definitions) and prompt caching is not documented in the sources provided.
Your observation that changing the JSON schema in outputConfig causes a prompt cache miss is an important finding. This suggests that the schema definition may indeed be part of the caching key, even though the cached content (the system prompt with cache point) remains unchanged. This behavior would mean that different structured output schemas are treated as distinct requests for caching purposes, which could have significant implications for cache efficiency when using structured outputs with varying schemas.
This appears to be an undocumented aspect of how prompt caching interacts with structured outputs. Given that this behavior affects cache hit rates and could impact both performance and costs, it would be valuable to have this interaction explicitly documented or clarified in the official documentation.
Sources
OutputConfig - Amazon Bedrock
[Class: Aws::BedrockRuntime::Types::OutputConfig
— AWS SDK for Ruby V3](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/BedrockRuntime/Types/OutputConfig.html)
Relevant content
- asked a year ago
- asked 10 months ago
