mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
refactor(responses): drop commentary from the tool_choice fix
This commit is contained in:
parent
cba076715d
commit
98bfbb99d2
3 changed files with 2 additions and 15 deletions
|
|
@ -7708,7 +7708,6 @@ def validate_chat_completion_tool_choice(
|
|||
if tool_choice is None or isinstance(tool_choice, str):
|
||||
return tool_choice
|
||||
elif isinstance(tool_choice, dict):
|
||||
# Handle Cursor IDE format: {"type": "auto"} -> unwrap to the bare string
|
||||
tool_choice_type = tool_choice.get("type")
|
||||
if tool_choice_type in ("auto", "none", "required") and "function" not in tool_choice:
|
||||
return tool_choice_type
|
||||
|
|
|
|||
|
|
@ -28,12 +28,7 @@ def test_validate_tool_choice_standard_dict():
|
|||
|
||||
|
||||
def test_validate_tool_choice_cursor_format():
|
||||
"""Cursor IDE format {"type": "auto"} must be unwrapped to the bare string.
|
||||
|
||||
No OpenAI surface accepts the object form of these values. Forwarding it
|
||||
verbatim makes the provider reject the call with
|
||||
"Invalid value: 'auto' ... param: tool_choice.type".
|
||||
"""
|
||||
"""Cursor IDE format {"type": "auto"} is unwrapped to the bare string."""
|
||||
assert validate_chat_completion_tool_choice({"type": "auto"}) == "auto"
|
||||
assert validate_chat_completion_tool_choice({"type": "none"}) == "none"
|
||||
assert validate_chat_completion_tool_choice({"type": "required"}) == "required"
|
||||
|
|
|
|||
|
|
@ -3419,14 +3419,7 @@ async def test_acompletion_bridge_normalizes_tool_choice_on_the_wire(
|
|||
tool_choice: str | dict[str, object],
|
||||
expected_wire_tool_choice: str | dict[str, str],
|
||||
) -> None:
|
||||
"""Object-wrapped tool_choice must never reach /v1/responses.
|
||||
|
||||
Clients (Cursor, Claude Code via /v1/messages) send ``{"type": "auto"}``.
|
||||
The Responses API only accepts a hosted-tool name in ``tool_choice.type``,
|
||||
so forwarding the wrapper verbatim fails the whole call with
|
||||
``Invalid value: 'auto' ... param: tool_choice.type`` -- which broke every
|
||||
tool call, including web search, on responses-mode models.
|
||||
"""
|
||||
"""Object-wrapped tool_choice must never reach /v1/responses."""
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue