Honor the Strict attribute on Anthropic tools

Merged
SU
3d ago
+113-3

#[Strict] on a tool sends strict: true on OpenAI and xAI but the Anthropic gateway drops it
so Claude can still call a strict tool with input that doesn't match its schema

repro on claude-sonnet-5-5 with a #[Strict] tool where color is an enum of red green blue and brightness is an integer
I asked it to call the tool with magenta and seventy plus an extra room field
all 5 calls hit handle() with {"color":"magenta","brightness":"seventy","room":"kitchen"}
with this change all 5 came through schema valid like {"color":"red","brightness":70}

tools with the attribute now get strict: true and additionalProperties: false
the schema goes through AnthropicSchemaSanitizer first because strict mode 400s on keywords like minimum
without that a strict tool with $schema->integer()->min(1) gets For 'integer' type, property 'minimum' is not supported
tools without the attribute go out exactly like before

I sent all of FileStorage::all() plus the two strict test fixtures and a tool with a minLength string and a nullable param to claude-sonnet-5-5 in one request and the API took all 12
the anthropic integration tests still pass on their pinned model too

one heads up
Anthropic caps strict schemas at 20 strict tools and 24 optional params per request so an agent past that would start getting a 400 for tools marked #[Strict]

https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use