Fix Nova grounding web_search_options={} not applying systemTool#20044
Merged
krrishdholakia merged 2 commits intoBerriAI:litellm_oss_staging_01_31_2026from Jan 31, 2026
Conversation
Two bugs prevented web_search_options={} from working for Nova grounding:
1. Empty dict falsy check: The condition `value and isinstance(value, dict)`
short-circuits to False when value is {} (empty dict is falsy in Python).
Changed to `isinstance(value, dict)` to match Anthropic's implementation.
2. Pre-formatted tools mangled by _bedrock_tools_pt: The systemTool
(already in Bedrock format) was added to optional_params["tools"], but
_process_tools_and_beta passed all tools through _bedrock_tools_pt which
expects OpenAI-format tools. This corrupted the systemTool into an empty
toolSpec. Fixed by separating systemTool blocks before transformation
and appending them after.
Fixes follow-up to BerriAI#19598
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
python-multipart ^0.0.22 requires Python >=3.10 but the project supports >=3.9. Add python = ">=3.10" marker so Poetry can resolve dependencies for Python 3.9. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ea1c0d4
into
BerriAI:litellm_oss_staging_01_31_2026
5 of 8 checks passed
Sameerlite
pushed a commit
that referenced
this pull request
Feb 2, 2026
) * Fix Nova grounding web_search_options={} not applying systemTool Two bugs prevented web_search_options={} from working for Nova grounding: 1. Empty dict falsy check: The condition `value and isinstance(value, dict)` short-circuits to False when value is {} (empty dict is falsy in Python). Changed to `isinstance(value, dict)` to match Anthropic's implementation. 2. Pre-formatted tools mangled by _bedrock_tools_pt: The systemTool (already in Bedrock format) was added to optional_params["tools"], but _process_tools_and_beta passed all tools through _bedrock_tools_pt which expects OpenAI-format tools. This corrupted the systemTool into an empty toolSpec. Fixed by separating systemTool blocks before transformation and appending them after. Fixes follow-up to #19598 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix python-multipart Python version constraint for Poetry lock python-multipart ^0.0.22 requires Python >=3.10 but the project supports >=3.9. Add python = ">=3.10" marker so Poetry can resolve dependencies for Python 3.9. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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
Fixes follow-up bugs from #19598
Pre-Submission checklist
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsallscoped unit tests onmake test-unitType
🐛 Bug Fix
Changes
Two bugs prevented
web_search_options={}from working for Nova grounding (introduced in #19598):Bug 1: Empty dict falsy check
In
converse_transformation.py,map_openai_params:web_search_options={}is the documented API to enable grounding, but{}is falsy, sovalue and isinstance(value, dict)short-circuits toFalse.Bug 2: Pre-formatted tools mangled by
_bedrock_tools_pt_map_web_search_optionsreturns aBedrockToolBlock(systemTool={"name": "nova_grounding"})— already in Bedrock format. This gets added tooptional_params["tools"]via_add_tools_to_optional_params. But later,_process_tools_and_betapasses all tools through_bedrock_tools_pt(), which expects OpenAI-format tools (withfunction.name,function.parameters, etc.). This corrupts the systemTool into an empty toolSpec:{"toolSpec": {"inputSchema": {"json": {"type": "object", "properties": {}, "required": []}}, "name": "", "description": ""}}Fix: Separate
systemToolblocks from OpenAI-format tools before_bedrock_tools_ptprocesses them, then append them after transformation.Verification
All 6 existing Nova grounding tests pass:
test_bedrock_nova_grounding_request_transformationtest_bedrock_nova_grounding_web_search_options_non_streamingtest_bedrock_nova_grounding_with_function_toolstest_bedrock_nova_web_search_options_ignored_for_non_novatest_bedrock_nova_web_search_options_mappingtest_bedrock_tools_pt_does_not_handle_system_toolSee verification comment on #19598 for full details including mocked and live test scripts.