Planning

Let agents think and plan before acting

Planning mode lets agents break complex tasks into steps before executing.

Diagram

Planning Flow

📋 Task

🧠 Plan

Step 1

Step 2

Step 3

✅ Result

Quick Start

  1. Create a Plan
    rust
    use praisonai::{Plan, PlanStep};
    
    // Create a plan with steps
    let mut plan = Plan::new("Write Blog Post")
        .description("Write a blog post about AI safety");
    
    plan.add_step(PlanStep::new("Research topic"));
    plan.add_step(PlanStep::new("Create outline"));
    plan.add_step(PlanStep::new("Write draft"));
    plan.add_step(PlanStep::new("Review and edit"));
    
    println!("Plan has {} steps", plan.step_count());
  2. Execute Plan Steps
    rust
    use praisonai::{Plan, PlanStep};
    
    let mut plan = Plan::new("Project");
    plan.add_step(PlanStep::new("Step 1"));
    plan.add_step(PlanStep::new("Step 2"));
    
    // Get next ready step
    while let Some(step) = plan.next_step() {
        println!("Executing: {}", step.description);
        // Execute the step...
        if let Some(s) = plan.get_step_mut(&step.id) {
            s.complete(Some("Done".to_string()));
        }
    }
    
    println!("Progress: {}%", plan.progress());
  3. Step Dependencies
    rust
    use praisonai::PlanStep;
    
    // Step 2 depends on Step 1
    let step1 = PlanStep::new("Research")
        .estimated(60);  // 60 seconds
    
    let step2 = PlanStep::new("Write")
        .depends_on("research")  // Wait for research
        .estimated(120);

How It Works

Diagram
StepsPlanAppStepsPlanApploop[For each step]Create planAdd stepsnext_step()Ready stepExecuteResultcomplete()progress()

Plan Methods

MethodSignatureDescription
new(name)`fn new(impl Into

) -> Self | Create plan | | description(desc) | fn description(impl Into

) -> Self | Set description | | add_step(step) | fn add_step(&mut self, PlanStep) | Add a step | | get_step(id) | fn get_step(&self, &str) -> Option<&PlanStep> | Get step | | next_step() | fn next_step(&self) -> Option<&PlanStep> | Get next ready step | | progress() | fn progress(&self) -> f64 | Get progress % | | is_complete() | fn is_complete(&self) -> bool | Check if done | | has_failed() | fn has_failed(&self) -> bool | Check for failures | | step_count() | fn step_count(&self) -> usize` | Number of steps |

PlanStep Methods

MethodSignatureDescription
new(description)`fn new(impl Into

) -> Self | Create step | | depends_on(step_id) | fn depends_on(impl Into

) -> Self | Add dependency | | estimated(seconds) | fn estimated(u64) -> Self | Set estimated time | | start() | fn start(&mut self) | Mark in progress | | complete(output) | fn complete(&mut self, Option

) | Mark done | | fail(error) | fn fail(&mut self, impl Into

) | Mark failed | | skip() | fn skip(&mut self) | Mark skipped | | is_ready(completed) | fn is_ready(&self, &[String]) -> bool` | Check if ready |


When to Use Planning

Diagram

Use Planning When

Complex tasks

✅ Use Planning

Multi-step work

Simple questions

❌ Skip Planning

Task TypeUse Planning?
“What’s 2+2?”❌ No
“Summarize this doc”❌ No
“Write a business plan”✅ Yes
“Build a website”✅ Yes

Best Practices

Use for complex multi-step tasks

Planning helps with research papers, code projects, business plans.

Skip for simple queries

Don’t enable planning for quick questions – adds unnecessary overhead.

Enable reasoning for debugging

Turn on reasoning to see the agent’s thought process.


Related