spring-ai
spring-ai copied to clipboard
GH-6163: Omit null temperature/topP from BedrockProxyChatModel inferenceConfig
Summary
- Fixes
BedrockProxyChatModel.createRequest()to omittemperatureandtopPfromInferenceConfigurationwhen they arenull, rather than passingnullexplicitly to the AWS SDK builder - The previous code called
.temperature(null)/.topP(null)on theInferenceConfiguration.Builder, which caused the field to be present (as null) in the serialized Bedrock Converse request payload - Models like Claude Opus 4.7 reject the request with
"temperature is deprecated for this model"even when no temperature was configured by the caller, because Bedrock forwards the null field to the Anthropic API which treats its presence as an explicit (invalid) setting - Added two unit tests to
BedrockProxyChatModelTest— one verifying that null temperature/topP are absent from the built request, and one verifying that explicit values are still forwarded correctly
Test plan
- [x]
./mvnw -pl models/spring-ai-bedrock-converse test -Dtest="BedrockProxyChatModelTest"— 13 tests pass (11 existing + 2 new) - [ ] Manually test with
eu.anthropic.claude-opus-4-7and no temperature configured → should no longer produceValidationException: temperature is deprecated
Fixes: #6163