Skip to content

Fix Nova grounding web_search_options={} not applying systemTool#20044

Merged
krrishdholakia merged 2 commits intoBerriAI:litellm_oss_staging_01_31_2026from
jquinter:fix/nova-grounding-web-search-options
Jan 31, 2026
Merged

Fix Nova grounding web_search_options={} not applying systemTool#20044
krrishdholakia merged 2 commits intoBerriAI:litellm_oss_staging_01_31_2026from
jquinter:fix/nova-grounding-web-search-options

Conversation

@jquinter
Copy link
Contributor

Relevant issues

Fixes follow-up bugs from #19598

Pre-Submission checklist

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all scoped unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 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:

# BEFORE (broken): {} is falsy in Python, so web_search_options={} never triggers
if param == "web_search_options" and value and isinstance(value, dict):

# AFTER (fixed): matches Anthropic's pattern (anthropic/chat/transformation.py:796)
if param == "web_search_options" and isinstance(value, dict):

web_search_options={} is the documented API to enable grounding, but {} is falsy, so value and isinstance(value, dict) short-circuits to False.

Bug 2: Pre-formatted tools mangled by _bedrock_tools_pt

_map_web_search_options returns a BedrockToolBlock(systemTool={"name": "nova_grounding"}) — already in Bedrock format. This gets added to optional_params["tools"] via _add_tools_to_optional_params. But later, _process_tools_and_beta passes all tools through _bedrock_tools_pt(), which expects OpenAI-format tools (with function.name, function.parameters, etc.). This corrupts the systemTool into an empty toolSpec:

{"toolSpec": {"inputSchema": {"json": {"type": "object", "properties": {}, "required": []}}, "name": "", "description": ""}}

Fix: Separate systemTool blocks from OpenAI-format tools before _bedrock_tools_pt processes them, then append them after transformation.

Verification

All 6 existing Nova grounding tests pass:

  • test_bedrock_nova_grounding_request_transformation
  • test_bedrock_nova_grounding_web_search_options_non_streaming
  • test_bedrock_nova_grounding_with_function_tools
  • test_bedrock_nova_web_search_options_ignored_for_non_nova
  • test_bedrock_nova_web_search_options_mapping
  • test_bedrock_tools_pt_does_not_handle_system_tool

See verification comment on #19598 for full details including mocked and live test scripts.

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>
@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Error Error Jan 30, 2026 4:00am

Request Review

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>
@krrishdholakia krrishdholakia changed the base branch from main to litellm_oss_staging_01_31_2026 January 31, 2026 23:09
@krrishdholakia krrishdholakia merged commit ea1c0d4 into BerriAI:litellm_oss_staging_01_31_2026 Jan 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>
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