Repository navigation
Studio: keep earlier messages when you send audio - #12244
Conversation
NilayYadav
left a comment
There was a problem hiding this comment.
Codex review coverage
Mirror: NilayYadav#136, pinned to upstream head 1ab98be3b3dd7db0b8b57827eca510a1147f0163 (same commit and tree 150be7cd on the mirror and on this PR).
Rounds: 2. Converged because Codex approved the current head: "Didn't find any major issues" on 1ab98be3b3 (comment).
Items:
- Round 1, P1, "Append audio after a trailing assistant turn": rejected. On
mainboth backends already caption the recording with that same last user text (inference.pyfalls back to the newest non-empty user message; MLX took the newest user text), so the recording was bound to that question before this PR too. The Studio UI never sends a trailing assistant turn with audio,continue_final_messageis refused on the audio route, and the image path attaches media the same way.
Also fixed during review (found by hand, not by Codex): the reply to an earlier recording was paired with the typed question before it, because the empty recording turn was dropped and the later reply replaced the earlier one. Fixed in 1ab98be3b3.
Final Codex result on 1ab98be3b3: no major issues.
NilayYadav
left a comment
There was a problem hiding this comment.
Review + reproduction evidence
Pinned review: 1ab98be3b3dd7db0b8b57827eca510a1147f0163. 1 finding, fixed in 1ab98be3b3 (the reply to an earlier recording was re-paired with the typed question before it).
I reproduced the chat flow on fresh upstream main (ca5e2fd) and on the PR with Studio installed by install.sh --local on Linux with an NVIDIA L4, gemma-3n-E2B-it loaded from the picker, recordings attached from the composer, Chromium 1440x900:
- main: after typing "My name is Nilay and my favourite colour is teal", a recording asking "What is my name?" gets a reply saying it does not have a name (no earlier turn reaches the model). A bare recording of "Please count from one to five." sent after "Write a haiku about the sea." gets another haiku ("Blue waves crash and foam, Salty air and sunlit spray, Deep secrets reside.").
- PR head: the same steps give "Nilay." and "Please count from one two five.". A second recording, "What was the poem you wrote for me? Please say it again.", gets the earlier haiku back word for word.
- PR as first submitted (
c9fe6b6): that second recording got a brand new haiku. The browser sends an earlier recording as an empty user turn; the helper dropped it and then let the next reply replace the real one.1ab98be3b3drops that reply together with its recording, with tests on both backends.
-
Test A/B on Modal (the GitHub Actions mirrors head and fix reverted sat queued for over 90 minutes and never started): with the fix reverted,
test_the_reply_to_an_earlier_recording_stays_off_the_question_before_itandtest_mlx_generate_audio_input_deltas_and_rejectfail; on the head,test_generation_budget.pyis 18 passed (6 fixed vs main) and the CPU run oftest_generation_budget.py,test_mlx_inference_backend.pyandtest_vision_client_tools.pyis 7 fixed, 312 unchanged, 0 failing. The one red upstream check (workflow-trigger lint) is red onmainatca5e2fdand501b15ftoo. -
Unchanged paths: an image turn ("The number in the picture is 42. Your name is Nilay.") and a single audio turn over
/v1/chat/completions(222 prompt tokens) are identical on both sides; an API request with a system message and an unanswered user turn returns 200 on both. Whisper, GGUF audio and text turns do not reach this code. -
Speed, 3 warm runs each: a single audio turn is 5.70 s on main and 5.58 s on the PR. With history the prompt grows by the history only (224 to 243 tokens here).
-
MLX was checked through the tests above and the mlx-vlm 0.4.4 to 0.7.1 prompt builder, not on a Mac by hand.
Left as a suggestion: on MLX a whitespace-only caption sent through the raw API no longer falls back to "Please transcribe this audio." (the UI trims input, so only API callers can hit it).
Conclusion: real bug, fixed on both backends; with 1ab98be3b3 the audio turn keeps the chat and pairs every earlier reply with the right question.
…istory An earlier recording or picture sent without text replays as an empty user turn. Dropping it together with its reply meant a voice-only conversation still lost every earlier exchange; the reply is kept, with the empty turn, as the GGUF path already does. Turns after the newest user turn are left out, as before the branch, and a recording turn whose text is only whitespace is captioned with the transcribe default on MLX, as the structured CUDA render already appends it.
|
Pushed
The branch is 9 commits behind |
|
Codex review and CI on
|
Lyxot
left a comment
There was a problem hiding this comment.
LGTM. Audio turns now keep the earlier conversation on both safetensors backends, and a recording sent without text is no longer paired with an older question. Codex converged and CI is green apart from the Playwright-registration check that is red on main too.

With a safetensors audio model (transformers on an NVIDIA GPU, or MLX on a Mac), a message with a recording was answered as if it were the first message of the chat, so every earlier turn was dropped. On the GPU path a recording sent without typed text was also paired with the last question you typed, so the model answered that old question instead of listening.
Audio turns now keep the earlier conversation, as image turns already do since #10944 and as GGUF always has. A recording sent on its own is read as "Please transcribe this audio." on both backends.
Gemma's template refuses turns that do not alternate, so, much like the text path, empty replies and tool turns are left out and when two messages from the same side follow each other only the later one is kept, so a question that never got a reply gives way to the recording. Text, image and GGUF turns behave as before.