fix: ensure input_schema is always present for Vertex AI proxy compatibility#233
Open
hanzheng1954 wants to merge 1 commit into
Open
fix: ensure input_schema is always present for Vertex AI proxy compatibility#233hanzheng1954 wants to merge 1 commit into
hanzheng1954 wants to merge 1 commit into
Conversation
…ibility
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.
|
We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please contact @crawshaw at david@bold.dev to get yourself added. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using Shelley with a custom Anthropic-compatible endpoint backed by Vertex AI (e.g. Langdock), requests fail with:
Root Cause
Server-side tools (e.g.
web_search_20250305) are created without anInputSchemainclaudetool/toolset.go. The wire struct inant.gousesjson:"input_schema,omitempty", so anilschema causes theinput_schemakey to be completely absent from the JSON.Anthropic's own API is lenient and accepts this. However, Vertex AI-backed proxies strictly require
input_schemato be present as an object on every tool.Fix
In
fromLLMTool(), default to an empty object schema{"type":"object","properties":{}}whenInputSchemais nil. This is the defensive serialization-layer fix that covers any current or future tool that omitsInputSchema.Testing
Verified the fix resolves 400 errors against Langdock's Vertex AI proxy (
https://api.langdock.com/anthropic/eu/v1/messages) while remaining fully compatible with the official Anthropic API.