Skip to main content

new_message_id

Function new_message_id 

Source
pub fn new_message_id() -> MessageId
Expand description

A new message id: a random UUID (version 4), as a MessageId.

Every message a client sends needs one that has not been used before (spec ยง4.1.4), and nothing in the SDK made one, so the docs hard-coded "m1" or told the reader to add uuid (audit G-13). A fixed id is wrong the second time it is sent: a server that deduplicates on it answers the first message again.

use a2a_protocol_client::new_message_id;
use a2a_protocol_types::{Message, MessageSendParams};

let params = MessageSendParams::new(Message::user_text(new_message_id(), "hello"));
assert!(!params.message.id.as_ref().is_empty());
assert_ne!(new_message_id(), new_message_id());