spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

GH-6163: Omit null temperature/topP from BedrockProxyChatModel inferenceConfig

Open suryateja-g13 opened this issue 6 months ago • 0 comments

Summary

  • Fixes BedrockProxyChatModel.createRequest() to omit temperature and topP from InferenceConfiguration when they are null, rather than passing null explicitly to the AWS SDK builder
  • The previous code called .temperature(null) / .topP(null) on the InferenceConfiguration.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-7 and no temperature configured → should no longer produce ValidationException: temperature is deprecated

Fixes: #6163

suryateja-g13 avatar May 27 '26 16:05 suryateja-g13