Skip to content

fix(models): Fix the zero result from the WebSearch tool#50

Merged
mirrorange merged 1 commit intomirrorange:mainfrom
soxfmr:fix/claude-websearch-tool-schema
Mar 12, 2026
Merged

fix(models): Fix the zero result from the WebSearch tool#50
mirrorange merged 1 commit intomirrorange:mainfrom
soxfmr:fix/claude-websearch-tool-schema

Conversation

@soxfmr
Copy link
Copy Markdown
Contributor

@soxfmr soxfmr commented Mar 12, 2026

The WebSearch tool always returns 0 result from the previous version. The rationale behind this issue is that we enforced input_schema for Tool requests, while the WebSearch requests may be sent in the following shapes:

  • server tool:
    • {"type":"web_search_20250305","name":"web_search","max_uses":5}
  • custom tool:
    • {"type":"custom","name":"WebSearch","custom":{"input_schema":...}}

Since they didn't fit the Tool definition, those requests were rejected:

INFO:     127.0.0.1:45470 - "POST /v1/messages?beta=true HTTP/1.1" 422 Unprocessable Entity 

We introduced several fixes for this issue:

  • Relax the Tool request model so Claude Code server tools no longer require a top-level input_schema field during request validation
  • Accept custom tools that keep their schema under custom.input_schema instead of flattening that field onto the tool object
  • Preserve support for optional tool metadata such as type, description, and nested custom configuration without rejecting relay requests up front

The WebSearch tool retrieved the result successfully after the fixes:

image

* relax the Tool request model so Claude Code server tools no longer require a top-level input_schema field during request validation
* accept custom tools that keep their schema under custom.input_schema instead of flattening that field onto the tool object
* preserve support for optional tool metadata such as type, description, and nested custom configuration without rejecting relay requests up front
* add request-model regressions for both server web-search tools and custom tool payloads sent by Claude Code
@mirrorange mirrorange merged commit 13b8cbd into mirrorange:main Mar 12, 2026
1 check passed
@soxfmr soxfmr deleted the fix/claude-websearch-tool-schema branch March 20, 2026 11:08
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.

2 participants