Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: refuse /v1/responses input_file and file_id image parts instead of dropping them
Nilay Yadav242fea98ce88
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.pyindex 535c0650d09..08ca385f439 100644--- a/studio/backend/routes/inference.py+++ b/studio/backend/routes/inference.py@@ -27755,6 +27755,26 @@ def _responses_reasoning_output_item(return ResponsesOutputReasoning(**kwargs).model_dump()+def _reject_unsupported_responses_message_part(part) -> None:+ """Refuse the two attachment shapes the local adapter cannot serve, instead of dropping them.++ ``_responses_tool_output_content`` already answers these exact shapes with a typed 400.+ Genuinely unmodelled future part types still drop.+ """+ part_type = getattr(part, "type", None)+ if part_type == "input_file":+ _raise_unsupported_openai_parameter(+ "input",+ "Responses input_file message parts are not supported by the local adapter.",+ )+ if part_type == "input_image" and getattr(part, "file_id", None):+ _raise_unsupported_openai_parameter(+ "input",+ "Responses input_image message parts with file_id are not supported by the local "+ "adapter. Use image_url instead.",+ )++def _normalise_responses_input(payload: ResponsesRequest) -> list[ChatMessage]:"""Convert a ResponsesRequest's ``input`` into a Chat-format ``ChatMessage`` list.@@ -27898,8 +27918,8 @@ def _normalise_responses_input(payload: ResponsesRequest) -> list[ChatMessage]:messages.append(ChatMessage(role = "assistant", content = text))continue- # User (and any other remaining roles) -- keep multimodal when present,- # drop unknown content parts silently.+ # User (and any other remaining roles) -- refuse an attachment we cannot serve,+ # drop genuinely unmodelled parts silently.parts: list = []for part in item.content:if isinstance(part, (ResponsesInputTextPart, ResponsesOutputTextPart)):@@ -27911,7 +27931,8 @@ def _normalise_responses_input(payload: ResponsesRequest) -> list[ChatMessage]:image_url = ImageUrl(url = part.image_url, detail = part.detail),))- # ResponsesUnknownContentPart and anything else: drop.+ else:+ _reject_unsupported_responses_message_part(part)if parts:# Collapse single-text-part content to a plain string so roles that# reject multimodal arrays (e.g. legacy templates) still accept it.diff --git a/studio/backend/tests/test_responses_tool_passthrough.py b/studio/backend/tests/test_responses_tool_passthrough.pyindex 45c1dfc53ea..70fbfeeaaa8 100644--- a/studio/backend/tests/test_responses_tool_passthrough.py+++ b/studio/backend/tests/test_responses_tool_passthrough.py@@ -818,6 +818,61 @@ class TestNormaliseResponsesInputWithTools:assert exc.value.status_code == 400assert "image_url" in str(exc.value.detail)+ def test_input_file_message_part_rejected_clearly(self):+ # Same shape function_call_output already refuses; dropped here, it answered 200.+ payload = ResponsesRequest(+ input = [+ {+ "role": "user",+ "content": [+ {"type": "input_text", "text": "summarise this"},+ {+ "type": "input_file",+ "file_data": "data:application/pdf;base64,AAA",+ "filename": "report.pdf",+ },+ ],+ }+ ],+ )+ with pytest.raises(HTTPException) as exc:+ _normalise_responses_input(payload)+ assert exc.value.status_code == 400+ assert "input_file" in str(exc.value.detail)++ def test_file_id_image_message_part_rejected_clearly(self):+ payload = ResponsesRequest(+ input = [+ {+ "role": "user",+ "content": [+ {"type": "input_text", "text": "what is in this?"},+ {"type": "input_image", "file_id": "file_abc"},+ ],+ }+ ],+ )+ with pytest.raises(HTTPException) as exc:+ _normalise_responses_input(payload)+ assert exc.value.status_code == 400+ assert "file_id" in str(exc.value.detail)++ def test_unmodelled_message_part_still_drops_silently(self):+ # A future part type must not 400 a turn whose text is perfectly servable.+ payload = ResponsesRequest(+ input = [+ {+ "role": "user",+ "content": [+ {"type": "input_text", "text": "hello"},+ {"type": "input_something_new", "value": 1},+ ],+ }+ ],+ )+ msgs = _normalise_responses_input(payload)+ assert [(m.role, m.content) for m in msgs] == [("user", "hello")]+def test_empty_function_call_output_gets_no_output_sentinel(self):payload = ResponsesRequest(input = [