fix(anthropic): preserve optional Responses tool properties - #34784
Open
eugene-yao-zocdoc wants to merge 1 commit into
Open
Conversation
Contributor
Author
Contributor
Greptile SummaryThis PR preserves Anthropic tool strictness across OpenAI-compatible adapters
Confidence Score: 5/5The PR appears safe to merge No blocking failure remains
|
| Filename | Overview |
|---|---|
| litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py | Moves an explicit Anthropic strict setting to the OpenAI function-tool level without leaking it into the parameters schema |
| litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py | Emits explicit Responses function-tool strictness, defaulting ordinary Anthropic tools to non-strict handling |
| litellm/types/llms/anthropic.py | Extends the Anthropic custom-tool TypedDict with the optional top-level strict field |
| tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py | Verifies explicit strict validation remains at the Chat Completions function level |
| tests/test_litellm/llms/anthropic/experimental_pass_through/responses_adapters/test_responses_adapters_transformation.py | Verifies optional properties remain optional and explicit Responses strict validation is preserved |
Reviews (2): Last reviewed commit: "fix(anthropic): preserve optional Respon..." | Re-trigger Greptile
eugene-yao-zocdoc
marked this pull request as ready for review
July 27, 2026 14:22
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
eugene-yao-zocdoc
changed the base branch from
litellm_oss_daily_2026_07_20
to
litellm_internal_staging
July 27, 2026 20:01
Generated with AI Co-Authored-By: Claude Code
eugene-yao-zocdoc
force-pushed
the
fix/anthropic-responses-optional-tool-schema
branch
from
July 27, 2026 20:05
64906dd to
6dbd305
Compare
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Linear ticket
Pre-Submission checklist
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
A live OpenAI Responses API probe using a synthetic search-tool schema reproduced the provider behavior behind this bug:
strictwas omitted, Responses normalized the tool tostrict: true, changedrequiredfrom["query"]to["query", "cursor", "context_channel_id"], and generated empty strings for the optional fields.strict: false, Responses preservedrequired: ["query"]and generated only{"query":"zz_responses_probe"}.The patched adapter now emits
strict: falsefor ordinary Anthropic tools while preserving an explicit top-level Anthropicstrict: truerequest. The sibling Chat Completions adapter also keeps an explicitstrictvalue at function level rather than placing it inside the JSON Schema.After rebasing onto
litellm_internal_staging, focused verification against commit6dbd305fpassed:The edited modules pass
py_compile, andgit diff --checkreports no errors.Type
🐛 Bug Fix
Changes
strictfield to the Anthropic tool type.strictdoes not leak into the parameters schema.Final Attestation