Skip to main content

sanitize_audio_markers

Function sanitize_audio_markers 

pub fn sanitize_audio_markers(
    messages: &[ChatMessage],
) -> Cow<'_, [ChatMessage]>
Expand description

Strip loadable audio markers (see strip_unplayable_audio_markers) across every message in messages, logging one degradation warning when any are removed. Returns the input borrowed when no candidate marker is present (the common, allocation-free path) or an owned rebuilt vector otherwise.

This is the shared seam keeping a raw audio path out of provider payloads, whichever route the history takes:

  • the main iteration prep (prepare_messages_for_provider, via prepare_messages_inner), and
  • one-shot queries that dispatch history directly without full prep (the max-iteration graceful summary and the other run_model_query callers).

Non-audio media markers pass through untouched; see AUDIO_MARKER_KINDS for why the split falls where it does.