The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
[Fix] CI/CD - responses_api_testing (#18295)
Alexsander Hamir5a76aada3c14
diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.pyindex af0847e3e24..ad910c9cd97 100644--- a/litellm/responses/litellm_completion_transformation/transformation.py+++ b/litellm/responses/litellm_completion_transformation/transformation.py@@ -321,7 +321,22 @@ class LiteLLMCompletionResponsesConfig:# If we had session messages but they got filtered out,# restore themcombined_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_messageslitellm_completion_request["litellm_trace_id"] = chat_completion_session.get(diff --git a/tests/llm_responses_api_testing/test_anthropic_responses_api.py b/tests/llm_responses_api_testing/test_anthropic_responses_api.pyindex df818ce5c7d..5df1045b7c0 100644--- a/tests/llm_responses_api_testing/test_anthropic_responses_api.py+++ b/tests/llm_responses_api_testing/test_anthropic_responses_api.py@@ -90,11 +90,18 @@ def test_multiturn_tool_calls():# Get the response ID and tool call ID from the responseresponse_id = response.id- tool_call_id = ""+ tool_call_id = Nonefor 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 functionfollow_up_response = litellm.responses(