Skip to main content

transform_messages

Function transform_messages 

Source
pub fn transform_messages(
    messages: &[Message],
    model: &Model,
    normalize_tool_call_id: Option<&NormalizeToolCallId<'_>>,
    now_ms: u64,
) -> Vec<Message>
Expand description

Rewrites a transcript for model:

  • images become placeholders when the model is text-only
  • thinking from other models becomes text, or is dropped when empty or redacted
  • tool-call ids from other models are normalized for the target API, given the id and its source message, and tool results follow
  • failed and aborted assistant messages are dropped
  • tool calls without a result get an error result before the next turn, and system messages between a call and its results move after the results