auto_forest_demo/
auto_forest_demo.rs1use helios_engine::{AutoForest, CalculatorTool, Config};
13
14#[tokio::main]
15async fn main() -> helios_engine::Result<()> {
16 println!("š² AutoForest - Intelligent Agent Orchestration Demo\n");
17 println!("====================================================\n");
18
19 println!("š Creating configuration...");
21 let config = Config::builder().temperature(0.7).max_tokens(2048).build();
22 println!("ā Configuration ready\n");
23
24 println!("š§ Initializing AutoForest with tools...");
26 let mut auto_forest = AutoForest::new(config)
27 .with_tools(vec![
28 Box::new(CalculatorTool),
29 ])
31 .build()
32 .await?;
33 println!("ā AutoForest initialized\n");
34
35 let task = r#"
37 I need to analyze a business problem:
38 1. A company has Q3 revenue data showing mixed results across 5 product categories
39 2. I need to understand which categories are underperforming
40 3. Calculate the performance metrics for each category
41 4. Identify trends and predict Q4 performance
42 5. Recommend which categories need attention
43 "#;
44
45 println!("š Submitting task to AutoForest...");
46 println!("Task: {}\n", task.trim());
47
48 println!("š AutoForest is orchestrating agent deployment...\n");
50 let result = auto_forest.execute_task(task).await?;
51
52 println!("š Orchestration Plan Generated:");
54 println!("================================\n");
55
56 if let Some(plan) = auto_forest.orchestration_plan() {
57 println!("Task: {}", plan.task.trim());
58 println!("Number of Agents Spawned: {}", plan.num_agents);
59 println!("Planning Reasoning: {}\n", plan.reasoning);
60
61 println!("Agent Configurations:");
62 println!("-----------------");
63 for (i, agent_config) in plan.agents.iter().enumerate() {
64 println!(
65 "Agent {}: {} ({})",
66 i + 1,
67 agent_config.name,
68 agent_config.role
69 );
70 println!(" Prompt: {}", agent_config.system_prompt);
71 if !agent_config.tool_indices.is_empty() {
72 println!(" Tools: {:?}", agent_config.tool_indices);
73 }
74 println!();
75 }
76
77 println!("Task Breakdown:");
78 println!("--------------");
79 for (agent_name, subtask) in &plan.task_breakdown {
80 println!("⢠{} ā {}", agent_name, subtask);
81 }
82 println!();
83 }
84
85 println!("š¤ Spawned Agents:");
87 println!("-----------------");
88 let spawned = auto_forest.spawned_agents();
89 println!("Total agents created: {}\n", spawned.len());
90
91 for (i, spawned_agent) in spawned.iter().enumerate() {
92 println!("Agent {}: {}", i + 1, spawned_agent.config.name);
93 println!(" Role: {}", spawned_agent.config.role);
94 if let Some(result) = &spawned_agent.result {
95 println!(" Result available: Yes ({} chars)", result.len());
96 } else {
97 println!(" Result: Pending");
98 }
99 println!();
100 }
101
102 println!("š Final Synthesized Result:");
104 println!("==========================\n");
105 println!("{}\n", result);
106
107 println!("\nš Executing a second task with different complexity...\n");
109
110 let simple_task = "Calculate the average of these numbers: 100, 200, 300, 400, 500. Then tell me what percentage each is of the total.";
111
112 println!("Task: {}\n", simple_task);
113 println!("š Processing...\n");
114
115 let result2 = auto_forest.execute_task(simple_task).await?;
116
117 println!("Result:\n{}\n", result2);
118
119 if let Some(plan) = auto_forest.orchestration_plan() {
120 println!(
121 "This task resulted in {} agent(s) - a simpler orchestration plan.",
122 plan.num_agents
123 );
124 println!("Reasoning: {}\n", plan.reasoning);
125 }
126
127 println!("ā
AutoForest demo completed!");
128 println!("=============================");
129 println!("\nš” Key Features Demonstrated:");
130 println!(" ⢠Automatic agent spawning based on task complexity");
131 println!(" ⢠Specialized agent prompt generation");
132 println!(" ⢠Task breakdown across agents");
133 println!(" ⢠Result aggregation and synthesis");
134 println!(" ⢠Flexible orchestration for varying task complexity");
135
136 Ok(())
137}