Skip to content

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.

Studio: stop silently dropping earlier replies sent as item references (#16694)

Nilay5e702b1ef30c
diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py
index 9bc7cc97aee..55a47279bb6 100644
--- a/studio/backend/models/inference.py
+++ b/studio/backend/models/inference.py
@@ -4007,7 +4007,7 @@ class ResponsesUnknownInputItem(BaseModel):
"""Catch-all for unmodelled Responses input item types.
Covers ``reasoning`` items and future types, so unrelated turns don't 422.
- Normalisation replays reasoning text and drops every other unknown item.
+ Normalisation replays reasoning text, refuses ``item_reference``, drops the rest.
"""
type: str
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index 8fb831ef64c..10064d2b33b 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -39206,6 +39206,13 @@ def _normalise_responses_input(payload: ResponsesRequest) -> list[ChatMessage]:
continue
if isinstance(item, ResponsesUnknownInputItem):
+ if item.type == "item_reference":
+ _raise_unsupported_openai_parameter(
+ "input",
+ "Responses input items of type 'item_reference' are not supported. Send "
+ "the full conversation history in 'input', for example with 'store' set "
+ "to false.",
+ )
if item.type == "reasoning":
replayed = _coerce_responses_reasoning_text(
getattr(item, "content", None)
diff --git a/studio/backend/tests/test_responses_history_guard.py b/studio/backend/tests/test_responses_history_guard.py
index accfc7227de..5e40b12be4c 100644
--- a/studio/backend/tests/test_responses_history_guard.py
+++ b/studio/backend/tests/test_responses_history_guard.py
@@ -113,3 +113,36 @@ def test_full_history_without_history_reference_preserves_dispatch(
assert response.status_code == 200
assert messages_seen == [(item["role"], item["content"]) for item in history]
assert switch.await_count == int(stream)
+
+
[email protected]("stream", [False, True])
[email protected]("referenced_id", ["msg_0123456789ab", "rs_0123456789ab"])
+def test_item_reference_is_rejected_instead_of_dropped(
+ monkeypatch, responses_client, stream, referenced_id
+):
+ switch = AsyncMock(side_effect = AssertionError("model switch reached"))
+ generate = AsyncMock(side_effect = AssertionError("generation reached"))
+ monkeypatch.setattr(inference, "_maybe_auto_switch_model", switch)
+ monkeypatch.setattr(inference, "_responses_stream", generate)
+ monkeypatch.setattr(inference, "_responses_non_streaming", generate)
+
+ response = responses_client.post(
+ "/v1/responses",
+ json = {
+ "input": [
+ {"role": "user", "content": "My project code is AZURE-317."},
+ {"type": "item_reference", "id": referenced_id},
+ {"role": "user", "content": "What was my project code?"},
+ ],
+ "stream": stream,
+ },
+ )
+
+ assert response.status_code == 400
+ error = response.json()["error"]
+ assert error["code"] == "unsupported_parameter"
+ assert error["param"] == "input"
+ assert "item_reference" in error["message"]
+ assert "full conversation history" in error["message"]
+ switch.assert_not_called()
+ generate.assert_not_called()