mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
fix(responses): avoid sending empty tools list in follow-up turns
Drop tools=[] from transformed chat-completion requests so providers like Anthropic return normal assistant text after tool_result turns. Made-with: Cursor
This commit is contained in:
parent
289f698a3c
commit
e6d5e3af02
1 changed files with 6 additions and 2 deletions
|
|
@ -229,9 +229,13 @@ class LiteLLMCompletionResponsesConfig:
|
|||
if litellm_logging_obj:
|
||||
litellm_logging_obj.stream_options = stream_options
|
||||
|
||||
# only pass non-None values
|
||||
# only pass non-None / non-empty values
|
||||
# Explicitly exclude an empty tools list — sending tools=[] to providers
|
||||
# like Anthropic in a tool_result conversation makes them return empty content.
|
||||
litellm_completion_request = {
|
||||
k: v for k, v in litellm_completion_request.items() if v is not None
|
||||
k: v
|
||||
for k, v in litellm_completion_request.items()
|
||||
if v is not None and not (k == "tools" and v == [])
|
||||
}
|
||||
return litellm_completion_request
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue