fix(responses): accept empty function argument deltas (#33341)

This commit is contained in:
daniel-meismer-zocdoc 2026-07-15 16:03:07 -04:00 committed by GitHub
parent 6a797f97b2
commit 265bf871bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -1196,7 +1196,7 @@ class OpenAiResponsesToChatCompletionStreamIterator(BaseModelResponseIterator):
)
elif event_type == "response.function_call_arguments.delta":
content_part: Optional[str] = parsed_chunk.get("delta", None)
if content_part:
if isinstance(content_part, str):
tool_call_index = parsed_chunk.get("output_index", 0)
return ModelResponseStream(
choices=[

View file

@ -257,3 +257,24 @@ def test_translate_responses_chunk_passthrough_chat_completion_chunk():
assert result.choices[0].delta.content == "Hi! How can I help?"
assert result.choices[0].finish_reason is None
def test_translate_responses_chunk_accepts_empty_function_argument_delta():
from litellm.completion_extras.litellm_responses_transformation.transformation import (
OpenAiResponsesToChatCompletionStreamIterator,
)
result = OpenAiResponsesToChatCompletionStreamIterator.translate_responses_chunk_to_openai_stream(
{
"type": "response.function_call_arguments.delta",
"item_id": "fc_test",
"output_index": 0,
"delta": "",
"sequence_number": 3,
}
)
tool_calls = result.choices[0].delta.tool_calls
assert tool_calls is not None
assert tool_calls[0].function is not None
assert tool_calls[0].function.arguments == ""