From 779006fdf939f57030dbe5341f6d090eeb726387 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Mon, 12 Oct 2026 12:59:20 -0700 Subject: [PATCH] fix(anthropic): drop the json tool description that makes sonnet-5 omit required keys --- litellm/constants.py | 3 --- litellm/llms/anthropic/chat/transformation.py | 2 -- .../anthropic/chat/test_anthropic_chat_transformation.py | 1 - .../chat/test_databricks_chat_transformation.py | 2 -- tests/unit/llms/vertex_ai/test_vertex.py | 9 +-------- 5 files changed, 1 insertion(+), 16 deletions(-) diff --git a/litellm/constants.py b/litellm/constants.py index 88c2123476c..38d16d61d7b 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1586,9 +1586,6 @@ OPENAI_FINISH_REASONS: Final = [ ] HUMANLOOP_PROMPT_CACHE_TTL_SECONDS: Final = int(os.getenv("HUMANLOOP_PROMPT_CACHE_TTL_SECONDS", 60)) # 1 minute RESPONSE_FORMAT_TOOL_NAME = "json_tool_call" # default tool name used when converting response format to tool call -RESPONSE_FORMAT_TOOL_DESCRIPTION: Final = ( - "Return the final answer as this structured object, filling every required field." -) ########################### Logging Callback Constants ########################### AZURE_STORAGE_MSFT_VERSION: Final = "2019-07-07" diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index fefa40bd91f..0aeef3d06e6 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -20,7 +20,6 @@ from litellm.constants import ( DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_XHIGH_THINKING_BUDGET, - RESPONSE_FORMAT_TOOL_DESCRIPTION, RESPONSE_FORMAT_TOOL_NAME, ) from litellm.litellm_core_utils.core_helpers import map_finish_reason @@ -1755,7 +1754,6 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): _tool: Final = AnthropicMessagesTool( name=RESPONSE_FORMAT_TOOL_NAME, - description=RESPONSE_FORMAT_TOOL_DESCRIPTION, input_schema=_input_schema, ) return _tool diff --git a/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py index 4d46c1a30c5..4e8971c1524 100644 --- a/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py +++ b/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py @@ -7498,7 +7498,6 @@ def test_vertex_claude_tool_emulated_response_format_returns_the_object_the_mode ) json_tool = next(tool for tool in request["tools"] if tool["name"] == RESPONSE_FORMAT_TOOL_NAME) assert json_tool["input_schema"]["required"] == ["tier", "summary"] - assert json_tool["description"] assert "output_format" not in request assert "output_config" not in request completion_response = { diff --git a/tests/unit/llms/databricks/chat/test_databricks_chat_transformation.py b/tests/unit/llms/databricks/chat/test_databricks_chat_transformation.py index c66efe21749..c6e0ecd2b41 100644 --- a/tests/unit/llms/databricks/chat/test_databricks_chat_transformation.py +++ b/tests/unit/llms/databricks/chat/test_databricks_chat_transformation.py @@ -16,7 +16,6 @@ from litellm.constants import ( DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, - RESPONSE_FORMAT_TOOL_DESCRIPTION, ) from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler from litellm.llms.databricks.chat.transformation import ( @@ -2144,7 +2143,6 @@ def test_databricks_claude_json_schema_preserves_refs_in_tool_parameters() -> No "function": { "name": "json_tool_call", "parameters": JSON_SCHEMA_RESPONSE_FORMAT["json_schema"]["schema"], - "description": RESPONSE_FORMAT_TOOL_DESCRIPTION, }, } ] diff --git a/tests/unit/llms/vertex_ai/test_vertex.py b/tests/unit/llms/vertex_ai/test_vertex.py index c5aaa010a96..044a07859f9 100644 --- a/tests/unit/llms/vertex_ai/test_vertex.py +++ b/tests/unit/llms/vertex_ai/test_vertex.py @@ -22,7 +22,6 @@ import pytest import litellm from litellm import Router, get_optional_params -from litellm.constants import RESPONSE_FORMAT_TOOL_DESCRIPTION from litellm.llms.vertex_ai.gemini.transformation import _process_gemini_media from litellm.types.llms.vertex_ai import BlobType @@ -2693,13 +2692,7 @@ def test_gemini_pro_json_schema_args_sent_httpx( request_body: Final = json.loads(route.calls[0].request.content) if "claude" in model: assert request_body["tool_choice"] == {"type": "tool", "name": "json_tool_call"} - assert request_body["tools"] == [ - { - "name": "json_tool_call", - "description": RESPONSE_FORMAT_TOOL_DESCRIPTION, - "input_schema": _RECIPES_SCHEMA, - } - ] + assert request_body["tools"] == [{"name": "json_tool_call", "input_schema": _RECIPES_SCHEMA}] else: assert request_body["generationConfig"]["response_mime_type"] == "application/json" assert request_body["generationConfig"]["response_json_schema"] == _RECIPES_SCHEMA