Skip to content

[Bedrock] Fixes to only allow accepted fields for tool json schema - #10062

Merged
ishaan-jaff merged 10 commits into
mainfrom
litellm_fixes_bedrock_nova_transform
May 14, 2025
Merged

[Bedrock] Fixes to only allow accepted fields for tool json schema #10062
ishaan-jaff merged 10 commits into
mainfrom
litellm_fixes_bedrock_nova_transform

Conversation

@ishaan-jaff

@ishaan-jaff ishaan-jaff commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

[Bedrock] Fixes to only allow accepted fields for tool json schema

This PR addresses the issue with Bedrock tool input schema formatting. Previously, we were sending the entire JSON schema object directly, which could include non-standard keys like $id and $schema that are not supported in the Bedrock API's expected format.

Changes

  • Created a new ToolJsonSchemaBlock TypedDict to enforce proper schema structure
  • Updated the _bedrock_tools_pt function to extract only the allowed schema components

Testing

Confirmed this works for:

  • Bedrock Converse Nova + Anthropic model family

  • Bedrock Invoke Nova + Anthropic model family

  • OpenAI models

  • Added a specific test case that verifies the tool schema transformation removes unsupported JSON schema fields

  • Added passing $id and $schema in our base llm tool calling test suite, this will now test all our providers and make sure this request works

Relevant issues

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)[https://docs.litellm.ai/docs/extras/contributing_code]
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix
✅ Test

Changes

@vercel

vercel Bot commented Apr 16, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2025 11:48pm

@ishaan-jaff
ishaan-jaff merged commit 5e7869a into main May 14, 2025
ishaan-jaff added a commit that referenced this pull request May 14, 2025
…10062)

* add test_function_calling_with_tool_response to base llm tests

* run test suite for nova

* update test_function_calling_with_tool_response

* allowed ToolJsonSchemaBlock keys

* fix ToolJsonSchemaBlock

* add back pytest fixture

* test: test_prompt_caching
@ishaan-berri
ishaan-berri deleted the litellm_fixes_bedrock_nova_transform branch March 26, 2026 21:53
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…erriAI#10062)

* add test_function_calling_with_tool_response to base llm tests

* run test suite for nova

* update test_function_calling_with_tool_response

* allowed ToolJsonSchemaBlock keys

* fix ToolJsonSchemaBlock

* add back pytest fixture

* test: test_prompt_caching
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.

1 participant