From 91be6dcbfbd1f0b339be0ae33ef10ac9a75a1014 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Fri, 13 Mar 2026 19:36:44 +0100 Subject: [PATCH] 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 --- pkg/llm/anthropic/provider.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/llm/anthropic/provider.go b/pkg/llm/anthropic/provider.go index 32f62dfda..7620b653c 100644 --- a/pkg/llm/anthropic/provider.go +++ b/pkg/llm/anthropic/provider.go @@ -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 } }