Skip to content

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

Merged
danielhanchen merged 4 commits into
mainfrom
fix/smoke-turn2-history-assertion
Aug 30, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
fix/smoke-turn2-history-assertion

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

What this fixes

multi_turn_chat.py opens by saying the conversation is built so that turns 2 and 4 are only answerable from the earlier turns, "so a server that drops history fails here rather than returning something plausible". Turn 4 does that. Turn 2 did not.

"What did I ask before?" reads like the stronger history probe, but gemma-3-270m-it, the model this smoke loads, answers it with "I am doing well! How can I help you today?" whether or not the history is attached. Nothing asserted that reply. The only content checks were:

assert "1" in first[0]
assert "paris" in joined

Turn 1 satisfies the first and turn 3 the second, so a server that dropped every turn before the last one still passed this test.

The change

Turn 2 asks for the answer rather than for the question. Measured against llama-server b10687-mix-67dfc8b with the same unsloth/gemma-3-270m-it-GGUF UD-Q4_K_XL file the workflow loads:

turn prompt reply
1 What is 1+1? 1 + 1 = 2
2 What was the answer to my previous question? The answer to your previous question was 2.
3 What is the capital of France? The capital of France is Paris.
4 Repeat the city name The capital of France is Paris.

Turn 2 now carries turn 1's answer, and the check asserts it per turn rather than over the joined transcript. That distinction matters: turn 1 already contains 2, so a joined check would pass on a server with no history at all.

Verification

Both directions, against the checking half of the script:

  • the measured transcript above passes
  • the old turn-2 reply, "I am doing well! How can I help you today?", now fails with turn 2 must repeat turn 1's answer, so history reached the model
  • that same reply passed every assertion before this change, which is the gap being closed

The three workflows share this one file since #9086, so Linux, macOS and Windows all pick it up.

Note on the determinism failures

GGUF inference smoke has been failing intermittently on main since 2026-08-30, always at turn 2, always with the same pair:

run1: 'I am doing not have the ability to ask questions before.'
run2: 'I am doing not understand.'

Two things I ruled out while looking at this, recorded so nobody repeats the work:

  • [Bug] apply_patch tool not exposed when launching Codex via unsloth codex . #9114 is not involved. It was the only commit between the last green run and the first red one, which makes it the obvious suspect, but every hunk it adds to routes/inference.py lives in _responses_* helpers, and _build_chat_request is reachable only from _responses_non_streaming and _responses_stream. This smoke uses Chat Completions and the Anthropic Messages API, neither of which touches the Responses path. Its models/inference.py changes are Responses schemas only.
  • llama.cpp is not involved. I ran the four-turn conversation directly against llama-server with that GGUF on b10360-mix-87da1a2 and b10687-mix-67dfc8b, with cache_prompt both true and false, across three servers at different thread counts and batch sizes, twice each. Every transcript was identical. The known prompt-cache non-determinism in Cache and system prompt on server makes output non-deterministic ggml-org/llama.cpp#4902 fits the signature well, but it did not reproduce here.

What the evidence does point at is a near-exact logit tie. All three observed turn-2 answers, including the healthy local one, begin "I am doing" and diverge at the very next token, which is what a tie looks like on a 270M model. I could not reproduce the flip locally, so I am not claiming this change fixes it, only that the turn it happens on was asserting nothing and testing nothing. If the flake follows the new prompt, the tie theory is wrong and worth reopening.

The four-turn smoke says turns 2 and 4 are answerable only from earlier turns, so a
server that drops history fails rather than returning something plausible. Turn 4
does that. Turn 2 did not.

"What did I ask before?" reads like the stronger probe but is not one:
gemma-3-270m-it, the model this smoke loads, answers "I am doing well! How can I
help you today?" whether or not the history is attached. Nothing asserted that
reply. The only content checks were "1" in turn 1 and "paris" somewhere in the
joined transcript, both satisfied by turns 1 and 3 alone, so a server that dropped
every turn before the last still passed.

Ask for the answer rather than the question. Measured against llama-server
b10687-mix-67dfc8b with the same GGUF the workflow loads, turn 2 becomes "The
answer to your previous question was 2.", which cannot be produced without turn 1.
Assert it per turn rather than over the joined transcript, since turn 1 already
contains "2" and a joined check would pass on a server with no history at all.

Verified both directions: the measured transcript passes, and the old turn-2 reply
now fails with the history message where it previously passed every assertion.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-30T11:26:18.985688Z db01026 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen added 2 commits August 30, 2026 11:07
…ures

Two things the first pass got wrong.

The new assertion broke tests/studio/test_smoke_workflows_share_one_script.py,
which is run unfiltered on every pull request by workflow-trigger-lint. Its
fixtures still used "you asked about 1+1" for turn 2, which carries no answer, so
the determinism and whitespace cases aborted on the history check and the grounding
case raised the wrong assertion. Fixtures updated to the new contract, and the
grounding test now covers both halves: a dropped turn 2 and a missing city.

The assertion itself was also too weak. A hardcoded "2" accepts a turn 2 that
contradicts turn 1, "1 + 1 = 3" followed by "the answer was 2", and 2 is guessable
by a model that never saw the history. Take the expected value from turn 1's reply
instead: the last number in it, since "1 + 1 = 2" restates the operands first. A
new test pins that, including the contradiction case.

No empty-numbers guard, because the preceding assertion already requires "1" in
turn 1, so the list cannot come back empty and a defensive branch there would be
unreachable.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Deriving the expected value from turn 1 only buys something if turn 1 is
unpredictable. With turn 1 fixed at 1+1 it reduced to hardcoding "2", which a
server that dropped history can produce by luck, so the false positive stayed open.

Measured the two candidate remedies against llama-server b10687-mix-67dfc8b with
the GGUF the workflow loads. Planting an explicit marker does not work on this
model: "Remember the number 47. What is 1+1?" followed by "What number did I ask
you to remember?" answers "I don't remember the number you asked me to remember."
That would have failed the smoke permanently.

An unguessable arithmetic answer does work. 58+27 gives "58 + 27 = 95" and turn 2
"The answer to your previous question was 95.", stable across runs, and turn 2 sent
with no history at all answers "I am doing well, thank you for asking!", which
carries no number and so fails the check as it should.

The turn-1 assertion becomes "contains a number" rather than "contains 1", which is
what it was really for and no longer depends on which operands are asked.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: db01026a92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 30, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 30, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 30, 2026
@danielhanchen
danielhanchen merged commit ad1a74b into main Aug 30, 2026
24 of 25 checks passed
@danielhanchen
danielhanchen deleted the fix/smoke-turn2-history-assertion branch August 30, 2026 11:43
danielhanchen pushed a commit that referenced this pull request Aug 30, 2026
`GGUF inference smoke` and the Mac inference lane have been red on main and on
essentially every open PR. They are two different failures on the same turn.

macOS is the assertion, not the server. #10009 moved history grounding onto turn
2, requiring the reply to restate turn 1's number. In the same run that turn 2
came back "You haven't provided the previous question.", turn 4 answered "The
capital of France is Paris." -- from a prompt reading "Repeat the city name",
which names no city, so history had arrived. Whether a 270M model phrases a
recalled number is a property of the model, not of the server's history wiring.

#10009's finding is real and stays: 'paris' in the JOINED transcript proves
nothing because turn 3 supplies it alone. Asserting the LAST turn, per turn,
closes exactly that gap on the turn that works. Sent that prompt with no history,
the model answers "Okay, I'm ready." -- measured against llama-server b10360 with
the UD-Q4_K_XL file the workflow loads, three times, plus 15/15 conversations
where the last turn named the city.

Windows is the older near-tie. Two replays are not two identical requests: each
turn is built from the reply before it, and the second replay meets the server
holding cache and slot state the first left behind, so a near-tied token can land
differently without decoding being broken. Both observed answers were correct.

The retry for that lives in main() and NOT in check(). check()'s contract is
unchanged: every divergence handed to it is still a hard failure, which is why
test_a_divergent_second_run_is_a_failure_not_a_warning passes here untouched.
That test exists because #5669 turned this into a printed warning on the Linux
leg and it went unnoticed for three months, and softening check() would have
walked straight back into it. The divergence now raises a Nondeterministic
subclass of AssertionError, so main() can retry that one failure and nothing
else, and existing pytest.raises(AssertionError) keeps matching.

Two guards from #10009 encode the turn-2 design and are updated with it, not
around it. Their replacements use the MEASURED history-dropping reply rather than
a hypothetical fixture, and a new one pins the macOS transcript as passing while
a last turn that cannot name the city still fails. Two more pin the retry itself:
a server that disagrees every time still fails and is bounded to ATTEMPTS, and a
non-divergence failure is not retried at all.

What I could not do: reproduce the Windows tie here. Prompt-cache state (cold,
2-turn, 4-turn primed), six concurrent generations, and thread counts 1 through
16 all gave one identical answer, 12/12 and 15/15. The tie is specific to those
runners.

tests/studio: 6630 passed, 195 skipped. Live end-to-end on the real GGUF passes.
verify_import_hoist, lint_exec_literals and lint_no_parallel_clamp clean.
danielhanchen added a commit that referenced this pull request Aug 30, 2026
…10025)

* Ground the multi-turn smoke on the turn that survives a 270M model

`GGUF inference smoke` and the Mac inference lane have been red on main and on
essentially every open PR. They are two different failures on the same turn.

macOS is the assertion, not the server. #10009 moved history grounding onto turn
2, requiring the reply to restate turn 1's number. In the same run that turn 2
came back "You haven't provided the previous question.", turn 4 answered "The
capital of France is Paris." -- from a prompt reading "Repeat the city name",
which names no city, so history had arrived. Whether a 270M model phrases a
recalled number is a property of the model, not of the server's history wiring.

#10009's finding is real and stays: 'paris' in the JOINED transcript proves
nothing because turn 3 supplies it alone. Asserting the LAST turn, per turn,
closes exactly that gap on the turn that works. Sent that prompt with no history,
the model answers "Okay, I'm ready." -- measured against llama-server b10360 with
the UD-Q4_K_XL file the workflow loads, three times, plus 15/15 conversations
where the last turn named the city.

Windows is the older near-tie. Two replays are not two identical requests: each
turn is built from the reply before it, and the second replay meets the server
holding cache and slot state the first left behind, so a near-tied token can land
differently without decoding being broken. Both observed answers were correct.

The retry for that lives in main() and NOT in check(). check()'s contract is
unchanged: every divergence handed to it is still a hard failure, which is why
test_a_divergent_second_run_is_a_failure_not_a_warning passes here untouched.
That test exists because #5669 turned this into a printed warning on the Linux
leg and it went unnoticed for three months, and softening check() would have
walked straight back into it. The divergence now raises a Nondeterministic
subclass of AssertionError, so main() can retry that one failure and nothing
else, and existing pytest.raises(AssertionError) keeps matching.

Two guards from #10009 encode the turn-2 design and are updated with it, not
around it. Their replacements use the MEASURED history-dropping reply rather than
a hypothetical fixture, and a new one pins the macOS transcript as passing while
a last turn that cannot name the city still fails. Two more pin the retry itself:
a server that disagrees every time still fails and is bounded to ATTEMPTS, and a
non-divergence failure is not retried at all.

What I could not do: reproduce the Windows tie here. Prompt-cache state (cold,
2-turn, 4-turn primed), six concurrent generations, and thread counts 1 through
16 all gave one identical answer, 12/12 and 15/15. The tie is specific to those
runners.

tests/studio: 6630 passed, 195 skipped. Live end-to-end on the real GGUF passes.
verify_import_hoist, lint_exec_literals and lint_no_parallel_clamp clean.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: danielhanchen <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant