Skip to content

Conversation

@gotsysdba
Copy link
Contributor

Title

OCI streams tool calls progressively, so early chunks may be missing required fields. Add empty string defaults for missing fields before Pydantic validation happens. The fix is backward-compatible and only affects the specific case where OCI returns incomplete tool call data during streaming.

Relevant issues

Fixes #16897

Pre-Submission checklist

  • 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
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix
✅ Test

Changes

  • Modified litellm/llms/oci/chat/transformation.py
    • Added logic to handle missing required fields in OCI streaming tool calls
    • The fix adds empty string defaults for missing arguments, id, and name fields before Pydantic validation
    • This prevents ValidationError when OCI streams incomplete tool call structures
  • Test suite at tests/test_litellm/llms/oci/chat/test_oci_streaming_tool_calls.py
    • Test for missing arguments field
    • Test for missing id field
    • Test for missing name field
    • Test for all fields missing
    • Test for complete tool calls (regression test)
    • Test for multiple tool calls with mixed missing fields
    • Test for chunks without tool calls

@vercel
Copy link

vercel bot commented Nov 21, 2025

@gotsysdba is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@gotsysdba
Copy link
Contributor Author

Tests:
image

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.

OCI Provider: Pydantic validation error with streamed responses and tools

1 participant