Preserve extra JSON Schema fields in Anthropic tools
buildTools was only copying "properties" and "required" into ToolInputSchemaParam, silently dropping root-level constraints like additionalProperties and $defs. Forward them through the SDK's ExtraFields map so the full schema reaches the API. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -235,10 +235,24 @@ func buildTools(tools []llm.Tool) []anthropic.ToolUnionParam {
|
||||
reqStrings = append(reqStrings, s)
|
||||
}
|
||||
}
|
||||
tool.InputSchema = anthropic.ToolInputSchemaParam{
|
||||
|
||||
extra := make(map[string]any)
|
||||
for k, v := range schema {
|
||||
switch k {
|
||||
case "type", "properties", "required":
|
||||
default:
|
||||
extra[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
inputSchema := anthropic.ToolInputSchemaParam{
|
||||
Properties: props,
|
||||
Required: reqStrings,
|
||||
}
|
||||
if len(extra) > 0 {
|
||||
inputSchema.ExtraFields = extra
|
||||
}
|
||||
tool.InputSchema = inputSchema
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user