Repository navigation
Studio: accept multiple audio files per message - #12267
Conversation
Audio-input models such as Gemma 4 can take several clips in one message, but Studio refused a second clip in the composer, native drops, Compare, and the chat route. - Add extra_audio_base64 and lift several input_audio parts from the latest user turn, up to 8 clips. - Keep the 25 MB and 30 minute caps across all clips together. - GGUF sends one input_audio part per clip; transcoded clips share the remaining byte budget. - Transformers passes one audio item per clip; Whisper transcribes each in turn. - MLX keeps one clip and refuses more, since mlx-vlm drops extras. - Send clips to the inference worker as raw float32 bytes instead of Python lists.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
The "(Python 3.13, l-r)" failures come from this PR, not main; they pass on main. The existing single-file audio tests still pin the old contract:
Updating those tests to the multi-file shape, or accepting a single object alongside a list in the new code, should clear them. The "Repo tests (CPU, studio)" and "workflow-trigger lint" failures are a separate issue on main that #12255 fixed; a rerun will clear them. |
- Decode each clip within the duration the earlier clips left, so a later clip can no longer allocate a full 30 minutes on its own. - Refuse several clips for a non-GGUF target on an MLX host before the model switch, instead of after loading it. - Compare: count clips that are still being read, so overlapping pastes or drops cannot exceed the per-message caps.
- Pass extra clips as extra_audio_arrays instead of overloading audio_array with a list, which misread a plain list of samples as many one-sample clips. The keyword is only passed when there are extra clips. - Decode the first clip exactly as before; the combined budget only applies to later clips. - Native drops: keep attaching the rest of the batch after one clip is refused, since a later smaller clip may still fit. - Compare: use the non-secure-context safe id helper for clip ids.
|
Thanks, both were real regressions from this PR. Fixed in 131280b:
Also added worker level tests for the single clip and multi clip shapes. |
An equal split of the WAV budget made the result depend on attachment order: a long m4a followed by a short clip got half the budget and fell under the 8 kHz floor, although both fit together. Decode the transcoded clips first, then give every clip the highest shared sample rate that fits the budget; clips already below it are left alone. Held clips now share one decoded sample ceiling, so peak memory stays at the single clip bound. A single clip still gets the whole budget, as before.
# Conflicts: # studio/backend/core/inference/inference.py
- Pick the shared WAV rate from the resampler's own output length and resample to it directly. Rebuilding the rate from a floored byte cap gave 7999 Hz at the 8 kHz floor and refused a request that fits. - Compare: block sending until a selected batch is fully read, so a slow later clip cannot miss the message.
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
# Conflicts: # studio/frontend/src/features/chat/shared-composer.tsx
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
4 similar comments
|
@codex review |
|
@codex review |
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5221400c7
ℹ️ 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".
| const addError = getAudioAddError( | ||
| counted.length, | ||
| counted.reduce((total, size) => total + size, 0), | ||
| file.size, | ||
| ); |
There was a problem hiding this comment.
Apply the MLX clip limit in compare mode
When either Compare pane targets an MLX-served model, this call omits the maxFiles argument and therefore allows up to eight clips. Sending two or more clips then starts the comparison and may load the model, only for the backend to reject the request with _MLX_MULTI_AUDIO_DETAIL; the regular composer avoids this by calling maxAudioFilesFor. Derive the limit from the selected comparison targets or reject the multi-clip draft before starting the comparison.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not a bug: Compare panes send through createOpenAIStreamAdapter (runtime-provider.tsx pairId adapter), whose send-time attachedMediaUnavailableReason gate gets audioCount and the pane model's isMlx, so a multi-clip MLX pane is refused before any request; the backend switch preflight also refuses on an MLX host before loading. Only the moment of the message differs (send vs attach).
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Audio-input models like Gemma 4 E4B accept several audio clips in one message, but Studio only allowed one. Seven separate checks enforced that: the composer adapter, native drops, the Compare composer, and the chat route. The request also had a single
audio_base64field, and each backend received a single waveform.This PR lets a message carry up to 8 audio files while keeping the per-message resource cost the same as a single maximal clip.
Changes
Request and validation
extra_audio_base64: list[str]field for clips after the first.audio_base64is always the first clip, so existing capability, routing and auto-switch checks still see the audio.input_audioparts on the latest user message are now lifted in order instead of rejected. Clips on earlier turns are still refused.Serving paths
input_audiopart per clip, in upload order. wav/mp3 pass through; other formats are transcoded to WAV and share the remaining byte budget, so several clips never forward more than one maximal clip could. KV admission charges each clip.audioitem per clip in the processor chat template. Whisper transcribes each clip in turn.tolist(). For a 60 s clip this is 3.8 MB instead of 8.6 MB pickled, and about 0.2 ms instead of about 20 ms to encode and decode.Frontend
extra_audio_base64from the current turn only. It stays undefined for text turns so they remain on the durable run path.Testing
test_chat_input_audio_part.pyfor clip order, the count cap, the combined size and duration caps, and the shared GGUF WAV budget. Existing preflight tests are updated for the clip list. Audio related test files matchmain(the few failures there also fail on an unmodified checkout).npm run typecheckandnpm testpass (9356 tests), including new tests for the caps and the MLX gate.gemma-4-E2B-itGGUF on Studio's llama.cpp build with two spoken clips (one wav, one m4a). Asked for the number in one and the colour in the other, it answered "The secret number is 42, and the favourite colour is purple.", which needs both clips. Prompt tokens went from 65 for one clip to 121 for two.UI before and after
Two WAV files picked at once in the chat composer (no model loaded), merge base
b8440ccvs headed8896d. Before: one chip and "Only one audio file can be attached per message.". After: both clips attach.