fix(xai): default missing function tool parameters

This commit is contained in:
Ben Vargas
2026-05-16 17:57:40 -06:00
parent 8b3670b8dd
commit 2607888a97
2 changed files with 15 additions and 0 deletions
@@ -726,6 +726,7 @@ func normalizeXAITool(tool gjson.Result) ([]byte, bool, bool) {
return nil, false, false
}
raw = updatedTool
toolType = xaiFunctionToolType
changed = true
}
if toolType == xaiWebSearchToolType && tool.Get("external_web_access").Exists() {
@@ -736,6 +737,14 @@ func normalizeXAITool(tool gjson.Result) ([]byte, bool, bool) {
raw = updatedTool
changed = true
}
if toolType == xaiFunctionToolType && !tool.Get("parameters").Exists() {
updatedTool, errSet := sjson.SetRawBytes(raw, "parameters", []byte(`{"type":"object","properties":{}}`))
if errSet != nil {
return nil, false, false
}
raw = updatedTool
changed = true
}
return raw, changed, true
}