- Newest
- Most votes
- Most comments
This is expected behavior, not a bug. When you change the JSON schema structure in your structured output configuration, it invalidates the prompt cache. This is by design because the schema is part of the constrained decoding process that affects how the model generates tokens.
Structured outputs on Amazon Bedrock use a grammar-based approach where the JSON schema is compiled into a grammar that constrains token generation. These compiled grammars are cached per account for 24 hours from first access. However, changing the JSON schema structure invalidates this cache because it fundamentally changes the constraints on the model's output generation.
In your example, when you switch from SCHEMA_A (with summary and key_points fields) to SCHEMA_B (with only a topic field), you're changing the schema structure itself, which causes the cache miss you're observing in step 3.
It's worth noting that if you only changed the name or description fields in your schema while keeping the structure the same, the cache would not be invalidated. But structural changes to the schema—like different properties, types, or requirements—will cause a cache miss.
This behavior makes sense from a technical perspective: the schema directly influences the token generation process through constrained decoding, so different schemas require different processing paths and cannot share the same cached state.
Sources
Structured outputs on Amazon Bedrock: Schema-compliant AI responses | Artificial Intelligence
Relevant content
- asked a month ago
- asked a year ago
- asked 10 months ago
