Skip to main content

degrade_media_in_messages

Function degrade_media_in_messages 

pub fn degrade_media_in_messages(messages: &mut [ConversationMessage]) -> usize
Expand description

Replace image references in this message span with an omission note.

A turn that ended in a non-retryable failure may have had its attachments rejected by the provider. That rejection is durable knowledge about those attachments: resending them on the next request reproduces the same rejection, so one bad attachment would poison every later prompt on the session. The marker is replaced with a note rather than deleted so the model still sees that something was attached; surrounding text survives.

Returns the number of image references degraded. Callers own the span policy (which messages belong to the failed turn); this helper only performs the projection.