terraphim_multi_agent 1.0.0

Multi-agent system for Terraphim built on roles with rust-genai integration
Documentation
//! Multi-agent workflow patterns

use crate::MultiAgentResult;
use serde::{Deserialize, Serialize};

/// Multi-agent workflow patterns
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MultiAgentWorkflow {
    /// Sequential role execution
    RoleChaining {
        roles: Vec<String>,
        handoff_strategy: HandoffStrategy,
    },
    /// Smart role selection
    RoleRouting {
        routing_rules: RoutingRules,
        fallback_role: String,
    },
    /// Multiple roles in parallel
    RoleParallelization {
        parallel_roles: Vec<String>,
        aggregation: AggregationStrategy,
    },
    /// Lead role with specialist roles
    LeadWithSpecialists {
        lead_role: String,
        specialist_roles: Vec<String>,
    },
    /// QA role reviewing work
    RoleWithReview {
        executor_role: String,
        reviewer_role: String,
        iteration_limit: usize,
    },
}

/// Strategy for handing off between roles
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum HandoffStrategy {
    Sequential,
    ConditionalBranching,
    QualityGated,
}

/// Rules for routing tasks to roles
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoutingRules {
    pub complexity_thresholds: Vec<ComplexityRule>,
    pub capability_requirements: Vec<String>,
    pub cost_constraints: Option<CostConstraints>,
}

/// Rule based on task complexity
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ComplexityRule {
    pub min_score: f64,
    pub max_score: f64,
    pub preferred_role: String,
}

/// Cost constraints for routing
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostConstraints {
    pub max_cost_per_request: f64,
    pub prefer_cheaper: bool,
}

/// Strategy for aggregating results from parallel roles
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AggregationStrategy {
    Consensus,
    WeightedVoting,
    BestQuality,
    Concatenation,
}

// Placeholder implementations - will be expanded in later phases
impl MultiAgentWorkflow {
    pub async fn execute(&self, _task: &str) -> MultiAgentResult<String> {
        // TODO: Implement workflow execution
        Ok("Workflow execution placeholder".to_string())
    }
}