1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! `MessagesState`: a simple state type for message-based agent workflows.
//!
//! This module provides [`MessagesState`], a state type with a single `messages`
//! field that uses the `messages_reducer` merge semantics. This is the standard
//! state type used by prebuilt agents like `create_react_agent`.
//!
//! # Example
//!
//! ```ignore
//! use juncture::prebuilt::MessagesState;
//! use juncture::Message;
//!
//! let state = MessagesState {
//! messages: vec![Message::human("Hello")],
//! };
//! ```
use Message;
use messages_reducer;
use State;
use ;
/// State type for message-based agent workflows.
///
/// Contains a single `messages` field with reducer-based merge semantics.
/// When updates are applied, new messages are appended or merged according
/// to [`messages_reducer`]: matching IDs update existing messages, remove
/// sentinels delete messages, and new IDs are appended.
///
/// This is the default state type used by [`create_react_agent`](super::create_react_agent).
///
/// # Generated Types
///
/// The `#[derive(State)]` macro generates:
/// - `MessagesStateUpdate`: update struct with `messages: Option<Vec<Message>>`
///
/// # Example
///
/// ```ignore
/// use juncture::prebuilt::MessagesState;
/// use juncture::Message;
///
/// let state = MessagesState {
/// messages: vec![Message::human("What is the weather?")],
/// };
///
/// // Apply an update
/// let update = MessagesStateUpdate {
/// messages: Some(vec![Message::ai("Let me check.")]),
/// };
/// let changed = state.apply(update);
/// ```
// Rust guideline compliant 2026-05-19