Commit f8e7573
fix: sanitize tool input_schema for Anthropic adapter
When configuring Anthropic as the provider, any tool whose input_schema
contains a top-level oneOf/anyOf/allOf causes the API to reject the
entire request with HTTP 400:
Anthropic API error (HTTP 400 Bad Request invalid_request_error):
tools.1.custom.input_schema: input_schema does not support oneOf,
allOf, or anyOf at the top level
The OpenAI Responses adapter already handles this via
schema_sanitize::sanitize_for_responses, which strips root-level
composition keywords, merges alternative properties into the root
object, and surfaces dropped constraints as a description note so the
model still knows which parameters are expected.
Apply the same sanitization in the Anthropic adapter before sending
tool definitions, aligning both adapters for consistent schema
handling across providers.
Harvested from PR #4346 by @qinlinwang1 parent 17bde5e commit f8e7573
1 file changed
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
83 | 97 | | |
84 | 98 | | |
85 | | - | |
86 | | - | |
| 99 | + | |
| 100 | + | |
87 | 101 | | |
88 | 102 | | |
89 | 103 | | |
| |||
0 commit comments