fix(litellm): pass a flat Responses-style function tool through the chat bridge unchanged

This commit is contained in:
mateo-berri 2026-09-21 11:14:59 -07:00
parent 325d17aca9
commit c1ba76154e
2 changed files with 19 additions and 1 deletions

View file

@ -1115,7 +1115,7 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge):
responses_tools: Final[list[ALL_RESPONSES_API_TOOL_PARAMS]] = []
for tool in tools:
# convert function tool from chat completion to responses API format
if tool.get("type") == "function":
if tool.get("type") == "function" and isinstance(tool.get("function"), dict):
function_tool = cast(ChatCompletionToolParamFunctionChunk, tool.get("function"))
responses_tools.append(
FunctionToolParam(

View file

@ -830,6 +830,24 @@ def test_convert_tools_to_responses_format():
assert result[0]["name"] == "test"
def test_convert_tools_to_responses_format_passes_flat_function_tool_through():
from litellm.completion_extras.litellm_responses_transformation.transformation import (
LiteLLMResponsesTransformationHandler,
)
handler = LiteLLMResponsesTransformationHandler()
flat_tool = {
"type": "function",
"name": "shell",
"description": "Run a shell command",
"parameters": {"type": "object", "properties": {"cmd": {"type": "string"}}, "required": ["cmd"]},
}
converted = handler._convert_tools_to_responses_format([flat_tool])
assert converted == [flat_tool]
def test_extract_extra_body_params_reasoning_effort_override():
"""Test that reasoning_effort from extra_body overrides top-level reasoning_effort"""
from litellm.completion_extras.litellm_responses_transformation.transformation import (