pub fn transform_for_provider(
messages: &[Message],
_from_api: &Api,
to_api: &Api,
) -> Vec<Message>Expand description
Stable since 0.63.0
Message types for constructing conversations.
Transform messages for cross-provider compatibility.
When switching models mid-conversation, message history may contain provider-specific content (e.g. thinking blocks from Anthropic) that the new provider cannot handle. This function converts messages so they are compatible with the target provider’s API.
Key transformations:
- Thinking blocks → wrapped in
<thinking>tags as plain text - Tool calls and tool results are preserved unchanged
- User/assistant message structure is preserved