kiro: only set additionalModelRequestFields for supported models
The field is rejected by models that don't support thinking/reasoning configuration. Check model name before setting the field; 'auto' and unknown models skip it to avoid ValidationException errors.
This commit is contained in:
parent
48bd852594
commit
f88b5fcc32
|
|
@ -283,6 +283,19 @@ func kiroSanitizeModel(model string) string {
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// kiroModelSupportsThinking returns true if the model supports
|
||||||
|
// additionalModelRequestFields for thinking/reasoning configuration.
|
||||||
|
// Only explicit model names are supported; "auto" routes through Kiro's
|
||||||
|
// model selection which may choose models that don't support this field.
|
||||||
|
func kiroModelSupportsThinking(model string) bool {
|
||||||
|
switch model {
|
||||||
|
case "claude-opus-4-5", "claude-opus-4", "claude-sonnet-4-5", "claude-sonnet-4":
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func buildKiroRequest(model string, messages []Message, tools []Tool, profileARN string, params GenerationParams) (*kiroGenerateRequest, error) {
|
func buildKiroRequest(model string, messages []Message, tools []Tool, profileARN string, params GenerationParams) (*kiroGenerateRequest, error) {
|
||||||
model = kiroSanitizeModel(model)
|
model = kiroSanitizeModel(model)
|
||||||
if len(messages) == 0 {
|
if len(messages) == 0 {
|
||||||
|
|
@ -349,8 +362,12 @@ func buildKiroRequest(model string, messages []Message, tools []Tool, profileARN
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set additionalModelRequestFields for reasoning/thinking support.
|
// Set additionalModelRequestFields for reasoning/thinking support.
|
||||||
if fields := kiroModelRequestFieldsFromParams(params); fields != nil {
|
// Only set for models known to support it (claude-opus-4, claude-sonnet-4).
|
||||||
req.AdditionalModelRequestFields = fields
|
// Other models (including "auto") may route to models that reject this field.
|
||||||
|
if kiroModelSupportsThinking(model) {
|
||||||
|
if fields := kiroModelRequestFieldsFromParams(params); fields != nil {
|
||||||
|
req.AdditionalModelRequestFields = fields
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue