From a792106f2bd1b1dff3691b3c2ea58997482445ab Mon Sep 17 00:00:00 2001 From: hanzheng1954 <62579748+hanzheng1954@users.noreply.github.com> Date: Mon, 29 Jun 2026 22:33:24 +0800 Subject: [PATCH] fix: ensure input_schema is always present for Vertex AI proxy compatibility Some proxies (e.g. Vertex AI via Langdock) strictly require input_schema to be present on every tool object, even server-side tools where Anthropic's own API accepts omitting it. When InputSchema is nil (e.g. for web_search_20250305 server-side tool), the omitempty JSON tag causes the key to be absent entirely, triggering a 400 error from strict proxies: {"message":[{"expected":"object","code":"invalid_type", "path":["tools",9,"input_schema"], "message":"Invalid input: expected object, received undefined"}]} Fix: default to empty object schema {"type":"object","properties":{}} when InputSchema is nil in fromLLMTool. --- llm/ant/ant.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/llm/ant/ant.go b/llm/ant/ant.go index 6eaa3ee4..785a7f3c 100644 --- a/llm/ant/ant.go +++ b/llm/ant/ant.go @@ -608,11 +608,18 @@ func fromLLMToolChoice(tc *llm.ToolChoice) *toolChoice { } func fromLLMTool(t *llm.Tool) *tool { + schema := t.InputSchema + if schema == nil { + // Some proxies (e.g. Vertex AI via Langdock) strictly require input_schema + // to be present on every tool, even server-side tools where Anthropic's + // own API accepts omitting it. Default to an empty object schema. + schema = json.RawMessage(`{"type":"object","properties":{}}`) + } return &tool{ Name: t.Name, Type: t.Type, Description: t.Description, - InputSchema: t.InputSchema, + InputSchema: schema, CacheControl: fromLLMCache(t.Cache), } }