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.

Make the multi-turn smoke actually assert that history reached the model (#10009)

Daniel Hanad1a74bee9ca
diff --git a/.github/scripts/studio_smoke/multi_turn_chat.py b/.github/scripts/studio_smoke/multi_turn_chat.py
index e1687cf900c..f5250c01fac 100644
--- a/.github/scripts/studio_smoke/multi_turn_chat.py
+++ b/.github/scripts/studio_smoke/multi_turn_chat.py
@@ -22,6 +22,7 @@ between the three callers: each boots its server on its own port.
from __future__ import annotations
import os
+import re
import sys
SEED = 3407
@@ -29,9 +30,17 @@ MAX_TOKENS = 80
# Turn 2 cannot be answered without turn 1, and turn 4 without turn 3, so a server that
# drops history fails here rather than returning something plausible.
+#
+# Turn 2 asks for the ANSWER, not the question. gemma-3-270m-it answers "What did I ask
+# before?" with "I am doing well! How can I help you today?" whether or not the history is
+# attached, so that phrasing probes nothing.
+#
+# 58+27 rather than 1+1 so the answer cannot be guessed. Deriving the expected value from
+# turn 1 is only worth anything if turn 1 is unpredictable: with a fixed 1+1 it reduces to
+# hardcoding "2", which a history-less server can produce by luck.
PROMPTS = [
- "What is 1+1?",
- "What did I ask before?",
+ "What is 58+27?",
+ "What was the answer to my previous question?",
"What is the capital of France?",
"Repeat the city name",
]
@@ -118,10 +127,19 @@ def check(label: str, first: list[str], second: list[str]) -> None:
f"{label} non-deterministic at turn {i} with temperature=0.0:\n"
f" run1: {a!r}\n run2: {b!r}"
)
- # Turn 2 should mention the earlier question and turn 4 the city turn 3 produced.
+ # Turn 2 should carry turn 1's answer and turn 4 the city turn 3 produced.
# Lower-cased substring checks, so formatting jitter is not a failure.
joined = " ".join(first).lower()
- assert "1" in first[0], f"{label}: turn-1 answer should contain '1', got {first[0]!r}"
+ numbers = re.findall(r"\d+", first[0])
+ assert numbers, f"{label}: turn-1 answer should contain a number, got {first[0]!r}"
+ # From turn 1's reply, not a literal, so a turn 2 that contradicts turn 1 fails too.
+ # Last number, since "58 + 27 = 95" restates the operands first. Per turn, since the
+ # joined text already holds turn 1.
+ answer = numbers[-1]
+ assert answer in first[1], (
+ f"{label}: turn 2 must carry turn 1's answer {answer!r}, so history reached the "
+ f"model. Got {first[1]!r}"
+ )
assert (
"paris" in joined
), f"{label}: expected 'paris' somewhere in the four-turn transcript: {first}"
diff --git a/tests/studio/test_smoke_workflows_share_one_script.py b/tests/studio/test_smoke_workflows_share_one_script.py
index 855a346461b..93ee6c9110e 100644
--- a/tests/studio/test_smoke_workflows_share_one_script.py
+++ b/tests/studio/test_smoke_workflows_share_one_script.py
@@ -67,11 +67,11 @@ def test_a_divergent_second_run_is_a_failure_not_a_warning(script):
Asserted through behaviour rather than the text of the check, so rewriting it is
fine and weakening it is not.
"""
- clean = ["1 is 2", "you asked about 1+1", "paris", "paris"]
+ clean = ["1 is 2", "you asked about 2", "paris", "paris"]
script.check("ok", clean, list(clean)) # the baseline passes, or nothing below means anything
with pytest.raises(AssertionError, match = "non-deterministic"):
- script.check("drift", clean, ["1 is 2", "you asked about 1+1", "paris", "london"])
+ script.check("drift", clean, ["1 is 2", "you asked about 2", "paris", "london"])
def test_trailing_whitespace_alone_is_still_tolerated(script):
@@ -80,7 +80,7 @@ def test_trailing_whitespace_alone_is_still_tolerated(script):
llama-server varies a final newline between identical greedy runs depending on where
the stream is closed. Tightening this to an exact match would fail on that.
"""
- clean = ["1 is 2", "you asked about 1+1", "paris", "paris"]
+ clean = ["1 is 2", "you asked about 2", "paris", "paris"]
script.check("whitespace", clean, [t + "\n" for t in clean])
@@ -93,7 +93,7 @@ def test_an_empty_reply_is_a_failure_in_either_run(script):
Linux copy asserted both before this was consolidated onto the macOS one, which
asserted only the first.
"""
- clean = ["1 is 2", "you asked about 1+1", "paris", "paris"]
+ clean = ["1 is 2", "you asked about 2", "paris", "paris"]
with pytest.raises(AssertionError, match = "empty turn"):
script.check("first", ["", "b", "paris", "paris"], ["", "b", "paris", "paris"])
with pytest.raises(AssertionError, match = "empty turn"):
@@ -106,11 +106,30 @@ def test_an_empty_reply_is_a_failure_in_either_run(script):
def test_history_grounding_is_still_checked(script):
- """Two of the four turns are answerable only from the earlier ones. That is what the
- 'paris' check is for: it fails when history is dropped, rather than when the model is
- wrong about France."""
+ """Two of the four turns are answerable only from the earlier ones. Those checks fail
+ when history is dropped, rather than when the model is wrong about France."""
+ good2 = "you asked about 2"
with pytest.raises(AssertionError, match = "paris"):
- script.check("nohistory", ["1 is 2", "b", "c", "d"], ["1 is 2", "b", "c", "d"])
+ script.check("nohistory", ["1 is 2", good2, "c", "d"], ["1 is 2", good2, "c", "d"])
+
+ # Without a turn-2 check a server dropping every turn but the last still passed:
+ # "1" comes from turn 1 and "paris" from turn 3.
+ with pytest.raises(AssertionError, match = "history reached the model"):
+ script.check(
+ "noturn2", ["1 is 2", "b", "paris", "paris"], ["1 is 2", "b", "paris", "paris"]
+ )
+
+
+def test_turn_2_is_checked_against_turn_1_not_a_literal(script):
+ """A hardcoded digit would accept a turn 2 that contradicts turn 1. The fixtures carry
+ their own numbers, which is the point: the check reads turn 1 rather than a literal, so
+ it holds whatever PROMPTS asks."""
+ contradiction = ["1 is 3", "the answer was 2", "paris", "paris"]
+ with pytest.raises(AssertionError, match = "history reached the model"):
+ script.check("contradiction", contradiction, list(contradiction))
+
+ consistent = ["1 is 3", "the answer was 3", "paris", "paris"]
+ script.check("consistent", consistent, list(consistent))
def test_the_script_needs_no_environment_to_import(script):