cerebro 1.1.7

A blazing-fast AI memory layer that enables teams of specialized agents to collaborate through a shared cognitive architecture.
Documentation
//! # Pre-Built Swarm Templates
//!
//! Provides factory functions for initializing common multi-agent design patterns.

use crate::swarm::agent::{AgentConfig, LlmProvider};
use crate::swarm::orchestrator::SwarmPattern;

/// An out-of-the-box swarm for performing a multi-layered code review.
pub struct ReviewSwarmTemplate;

impl ReviewSwarmTemplate {
    /// Get the agents needed for the review swarm.
    pub fn agents(model: LlmProvider) -> Vec<AgentConfig> {
        vec![
            AgentConfig {
                id: "sec-reviewer".into(),
                name: "Security Reviewer".into(),
                system_prompt: "You are a code security expert. Analyze the provided code for OWASP vulnerabilities and logic flaws.".into(),
                model: model.clone(),
                tools: vec![],
                handoff_targets: vec![],
                max_steps: 10,
            },
            AgentConfig {
                id: "perf-reviewer".into(),
                name: "Performance Engineer".into(),
                system_prompt: "You are a deep-systems performance optimization engineer. Analyze the code for zero-cost abstraction failures and bottlenecks.".into(),
                model: model.clone(),
                tools: vec![],
                handoff_targets: vec![],
                max_steps: 10,
            },
            AgentConfig {
                id: "tech-lead".into(),
                name: "Staff Engineer Synthesizer".into(),
                system_prompt: "You are a pragmatic, senior technical lead. Synthesize the reports from the security and performance engineers into a concise, actionable final PR review.".into(),
                model,
                tools: vec![],
                handoff_targets: vec![],
                max_steps: 10,
            }
        ]
    }

    /// Get the swarm pattern.
    pub fn pattern() -> SwarmPattern {
        SwarmPattern::Parallel {
            agents: vec!["sec-reviewer".into(), "perf-reviewer".into()],
            merger: "tech-lead".into(),
        }
    }
}