Skip to main content

add_messages

Function add_messages 

Source
pub fn add_messages(existing: &mut Vec<Message>, new: Vec<Message>)
Expand description

Add messages to an existing list with smart merging.

This function implements the message reduction logic:

  • Appends new messages
  • Updates existing messages if they have the same ID
  • Handles tool calls and responses properly

This is used as the default reducer for MessagesState.