weavegraph 0.6.0

Graph-driven, concurrent agent workflow framework with versioned state, deterministic barrier merges, and rich diagnostics.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Reducer that appends incoming messages to the messages channel.
use super::Reducer;
use crate::{channels::Channel, node::NodePartial, state::VersionedState};

/// Reducer that appends messages from a [`NodePartial`](crate::node::NodePartial) to the state messages channel.
#[derive(Debug, PartialEq, Clone, Hash, Eq)]
pub struct AddMessages;

impl Reducer for AddMessages {
    fn apply(&self, state: &mut VersionedState, update: &NodePartial) {
        if let Some(msgs) = &update.messages {
            // Append new messages without cloning the entire vector
            state.messages.get_mut().extend_from_slice(msgs);
        }
    }
}