Skip to content

Conversation

@KeremTurgutlu
Copy link

@KeremTurgutlu KeremTurgutlu commented Nov 19, 2025

Title

Currently anthropic server_tool_use is not included in usage metadata when stream=True and as a result not available in the response_obj.usage used by a custom logger. This PR adds server_tool_use to streaming usage.

image

Relevant issues

Fixes: #16631

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

Type

🐛 Bug Fix

Changes

Notes

Linting

Linting runs fine locally but for some reason failing in Github actions.

image

Tests

Only 2 tests are failing and both appear to be related to missing dependencies, I've run test-unit which I was expecting to build the required environment using potery:

================================================================================================================================= short test summary info ==================================================================================================================================
FAILED tests/test_litellm/llms/vertex_ai/vertex_gemma_models/test_vertex_gemma_transformation.py::TestVertexGemmaCompletion::test_acompletion_basic_request - litellm.exceptions.BadRequestError: litellm.BadRequestError: Vertex_aiException BadRequestError - vertexai import failed please run `pip install -U "google-cloud-aiplatform>=1.38"`. Got error: No module named 'vertexai'
FAILED tests/test_litellm/llms/gemini/test_gemini_common_utils.py::TestGoogleAIStudioTokenCounter::test_clean_contents_for_gemini_api_preserves_other_fields - ModuleNotFoundError: No module named 'google.genai'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 2 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================================ 2 failed, 892 passed, 11 skipped, 16 warnings in 205.77s (0:03:25) ============================================================================================================
make: *** [test-unit] Error 2

@vercel
Copy link

vercel bot commented Nov 19, 2025

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

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@KeremTurgutlu KeremTurgutlu force-pushed the fix-server-tool-use-in-streaming branch from b0fb7c1 to ce0b086 Compare November 22, 2025 14:24
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.

[Bug]: server_tool_use missing in usage when using stream=True

2 participants