Skip to content

Add support for strict parameter in Anthropic tool schemas - #16725

Merged
2 commits merged into
BerriAI:mainfrom
Bradley-Butcher:bb/support-anthropic-structured-tool-calling
Nov 18, 2025
Merged

Add support for strict parameter in Anthropic tool schemas#16725
2 commits merged into
BerriAI:mainfrom
Bradley-Butcher:bb/support-anthropic-structured-tool-calling

Conversation

@Bradley-Butcher

@Bradley-Butcher Bradley-Butcher commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Add support for strict parameter in Anthropic tool schemas

Relevant issues

N/A

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit - existing tests are failing with default setup script. Can give details if required.
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
image

Type

🆕 New Feature

Changes

Problem:
Anthropic's API now supports a strict parameter in tool input schemas with the beta header flag: structured-outputs-2025-11-13 for structured outputs, but LiteLLM filters it out during the OpenAI → Anthropic parameter mapping. See https://docs.claude.com/en/docs/build-with-claude/structured-outputs#strict-tool-use for further details.

Solution:

  • Added "strict": Optional[bool] to the AnthropicInputSchema TypedDict in litellm/types/llms/anthropic.py (line 28)
  • This allows the strict parameter to pass through the filter in litellm/llms/anthropic/chat/transformation.py (lines 206-212)
  • Added test test_anthropic_strict_parameter_passthrough to verify the parameter is correctly passed through

Impact:
Users can now use Anthropic's strict mode for tool calling by including "strict": true in their tool parameters

@vercel

vercel Bot commented Nov 17, 2025

Copy link
Copy Markdown

@Bradley-Butcher is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Nov 17, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ghost
ghost merged commit d0c880e into BerriAI:main Nov 18, 2025
4 of 6 checks passed
"additionalProperties": Optional[bool],
"required": Optional[List[str]],
"$defs": Optional[Dict],
"strict": Optional[bool],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mind documenting this new feature @Bradley-Butcher

Here would be great:

Ryze0323 added a commit to Ryze0323/litellm that referenced this pull request Apr 8, 2026
…oolSpec

Bedrock Converse API supports strict: true in toolSpec since 2026-02-04 (GA).
Previously, both strict and additionalProperties were implicitly dropped
during OpenAI-to-Bedrock tool conversion because ToolSpecBlock and
ToolJsonSchemaBlock only whitelisted a subset of fields.

This change:
- Adds strict to ToolSpecBlock and passes it through when present
- Adds additionalProperties to ToolJsonSchemaBlock and passes it through
  when present (required by Bedrock when strict: true is set)

Without additionalProperties: false, Bedrock rejects strict: true requests
with: "For 'object' type, 'additionalProperties' must be explicitly set to false"

Fixes the gap where Anthropic direct API path already supports strict
(PR BerriAI#16725) but Bedrock Converse path does not.
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…#16725)

* support anthropic strict tools

* correct comment from copy-paste
This pull request was closed.
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