Skip to content

fix: ensure input_schema is always present for Vertex AI proxy compatibility#233

Open
hanzheng1954 wants to merge 1 commit into
boldsoftware:mainfrom
hanzheng1954:fix/vertex-tool-input-schema
Open

fix: ensure input_schema is always present for Vertex AI proxy compatibility#233
hanzheng1954 wants to merge 1 commit into
boldsoftware:mainfrom
hanzheng1954:fix/vertex-tool-input-schema

Conversation

@hanzheng1954

Copy link
Copy Markdown

Problem

When using Shelley with a custom Anthropic-compatible endpoint backed by Vertex AI (e.g. Langdock), requests fail with:

LLM request failed: status 400 Bad Request: {"message":[{"expected":"object","code":"invalid_type","path":["tools",9,"input_schema"],"message":"Invalid input: expected object, received undefined"}]}

Root Cause

Server-side tools (e.g. web_search_20250305) are created without an InputSchema in claudetool/toolset.go. The wire struct in ant.go uses json:"input_schema,omitempty", so a nil schema causes the input_schema key to be completely absent from the JSON.

Anthropic's own API is lenient and accepts this. However, Vertex AI-backed proxies strictly require input_schema to be present as an object on every tool.

Fix

In fromLLMTool(), default to an empty object schema {"type":"object","properties":{}} when InputSchema is nil. This is the defensive serialization-layer fix that covers any current or future tool that omits InputSchema.

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.

…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.
@cla-bot

cla-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant