cerebro 1.1.3

A high-performance semantic memory engine for AI Agents, now featuring SwarmForge for built-in multi-agent orchestration.
Documentation
//! # Swarm Orchestration Patterns
//!
//! Defines the trait and built-in patterns for multi-agent coordination.

pub mod sequential;
pub mod parallel;
pub mod hierarchical;

use async_trait::async_trait;
use std::collections::HashMap;

use crate::traits::Result;
use super::agent::AgentConfig;
use super::memory_bus::CerebroMemoryBus;
use super::trace::ExecutionTracer;
use super::llm::LlmClient;

/// The result of a completed swarm execution.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct SwarmResult {
    /// The final consolidated output from the swarm.
    pub final_output: String,
    /// The full execution trace.
    pub trace: super::trace::ExecutionTrace,
    /// Total tokens consumed across all agents.
    pub total_tokens: usize,
    /// Total wall-clock duration in milliseconds.
    pub total_duration_ms: u64,
}

/// Trait that all swarm orchestration patterns must implement.
#[async_trait]
pub trait SwarmPatternExecutor: Send + Sync {
    /// Execute the swarm pattern with the given agents, input, and shared resources.
    async fn execute(
        &self,
        agents: &HashMap<String, AgentConfig>,
        memory: &CerebroMemoryBus,
        tracer: &ExecutionTracer,
        llm: &LlmClient,
        input: &str,
    ) -> Result<SwarmResult>;
}