[Fix] CI/CD - responses_api_testing (#18295)

This commit is contained in:
Alexsander Hamir 2025-12-20 10:27:58 -08:00 committed by GitHub
parent 01a517a2c6
commit 5a76aada3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 5 deletions

View file

@ -321,7 +321,22 @@ class LiteLLMCompletionResponsesConfig:
# If we had session messages but they got filtered out,
# restore them
combined_messages = session_messages
# If both are empty, we'll let it fail with a proper error message
else:
# Both are empty - this likely means function_call_output had empty/invalid call_id
# Provide a helpful error message
import litellm
raise litellm.BadRequestError(
message=(
f"Unable to create messages for completion request. "
f"This can happen when: "
f"1) Using previous_response_id without a session database, AND "
f"2) Input contains only function_call_output with empty or invalid call_id. "
f"Please ensure function_call_output has a valid call_id from a previous response. "
f"Original request: previous_response_id={previous_response_id}"
),
model=litellm_completion_request.get("model", ""),
llm_provider=litellm_completion_request.get("custom_llm_provider", ""),
)
litellm_completion_request["messages"] = combined_messages
litellm_completion_request["litellm_trace_id"] = chat_completion_session.get(

View file

@ -90,11 +90,18 @@ def test_multiturn_tool_calls():
# Get the response ID and tool call ID from the response
response_id = response.id
tool_call_id = ""
tool_call_id = None
for item in response.output:
if 'type' in item and item['type'] == 'function_call':
tool_call_id = item['call_id']
break
if hasattr(item, 'type') and item.type == 'function_call':
tool_call_id = getattr(item, 'call_id', None)
if tool_call_id:
break
# Validate that we got a tool call with a valid call_id
if not tool_call_id:
raise AssertionError(
f"Expected a function_call with a valid call_id in response.output, but got: {response.output}"
)
# Use await with asyncio.run for the async function
follow_up_response = litellm.responses(