|
| 1 | +# Plan Execution Framework Guide |
| 2 | + |
| 3 | +The Flo AI framework provides built-in support for plan-and-execute workflows, making it easy to create multi-step, coordinated agent workflows. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### 1. Basic Software Development Workflow |
| 8 | + |
| 9 | +```python |
| 10 | +import asyncio |
| 11 | +from flo_ai.llm import OpenAI |
| 12 | +from flo_ai.arium.memory import PlanAwareMemory |
| 13 | +from flo_ai.arium.llm_router import create_plan_execute_router |
| 14 | +from flo_ai.arium import AriumBuilder |
| 15 | +from flo_ai.models.plan_agents import create_software_development_agents |
| 16 | + |
| 17 | +async def main(): |
| 18 | + # Setup (3 lines!) |
| 19 | + llm = OpenAI(model='gpt-4o', api_key='your-key') |
| 20 | + memory = PlanAwareMemory() |
| 21 | + agents = create_software_development_agents(memory, llm) |
| 22 | + |
| 23 | + # Create router |
| 24 | + router = create_plan_execute_router( |
| 25 | + planner_agent='planner', |
| 26 | + executor_agent='developer', |
| 27 | + reviewer_agent='reviewer', |
| 28 | + additional_agents={'tester': 'Tests implementations'}, |
| 29 | + llm=llm, |
| 30 | + ) |
| 31 | + |
| 32 | + # Build workflow |
| 33 | + agent_list = list(agents.values()) |
| 34 | + arium = ( |
| 35 | + AriumBuilder() |
| 36 | + .with_memory(memory) |
| 37 | + .add_agents(agent_list) |
| 38 | + .start_with(agents['planner']) |
| 39 | + .add_edge(agents['planner'], agent_list, router) |
| 40 | + .add_edge(agents['developer'], agent_list, router) |
| 41 | + .add_edge(agents['tester'], agent_list, router) |
| 42 | + .add_edge(agents['reviewer'], agent_list, router) |
| 43 | + .end_with(agents['reviewer']) |
| 44 | + .build() |
| 45 | + ) |
| 46 | + |
| 47 | + # Execute |
| 48 | + result = await arium.run(['Create a user authentication API']) |
| 49 | + |
| 50 | +asyncio.run(main()) |
| 51 | +``` |
| 52 | + |
| 53 | +### 2. Custom Plan Workflow |
| 54 | + |
| 55 | +```python |
| 56 | +from flo_ai.models.plan_agents import PlannerAgent, ExecutorAgent |
| 57 | + |
| 58 | +# Create custom agents |
| 59 | +planner = PlannerAgent(memory, llm, name='planner') |
| 60 | +researcher = ExecutorAgent(memory, llm, name='researcher') |
| 61 | +analyst = ExecutorAgent(memory, llm, name='analyst') |
| 62 | +writer = ExecutorAgent(memory, llm, name='writer') |
| 63 | + |
| 64 | +# Use the same pattern as above with your custom agents |
| 65 | +``` |
| 66 | + |
| 67 | +## Key Components |
| 68 | + |
| 69 | +### Plan Agents |
| 70 | + |
| 71 | +- **`PlannerAgent`**: Creates execution plans automatically |
| 72 | +- **`ExecutorAgent`**: Executes plan steps and tracks progress |
| 73 | +- **`create_software_development_agents()`**: Pre-configured dev team |
| 74 | + |
| 75 | +### Plan Tools |
| 76 | + |
| 77 | +- **`PlanTool`**: Parses and stores execution plans (from `flo_ai.tool.plan_tool`) |
| 78 | +- **`StepTool`**: Marks steps as completed (from `flo_ai.tool.plan_tool`) |
| 79 | +- **`PlanStatusTool`**: Checks plan progress (from `flo_ai.tool.plan_tool`) |
| 80 | + |
| 81 | +### Memory |
| 82 | + |
| 83 | +- **`PlanAwareMemory`**: Stores both conversations and execution plans |
| 84 | + |
| 85 | +### Router |
| 86 | + |
| 87 | +- **`create_plan_execute_router()`**: Intelligent routing for plan workflows |
| 88 | + |
| 89 | +## How It Works |
| 90 | + |
| 91 | +1. **Planning Phase**: Router sends task to planner agent |
| 92 | +2. **Plan Storage**: Planner creates and stores ExecutionPlan in memory |
| 93 | +3. **Execution Phase**: Router routes to appropriate agents based on plan steps |
| 94 | +4. **Progress Tracking**: Agents mark steps as completed using tools |
| 95 | +5. **Completion**: Router detects when all steps are done |
| 96 | + |
| 97 | +## Plan Format |
| 98 | + |
| 99 | +Plans are created in this standard format: |
| 100 | + |
| 101 | +``` |
| 102 | +EXECUTION PLAN: [Title] |
| 103 | +DESCRIPTION: [Description] |
| 104 | +
|
| 105 | +STEPS: |
| 106 | +1. step_1: [Task description] → agent_name |
| 107 | +2. step_2: [Task description] → agent_name (depends on: step_1) |
| 108 | +3. step_3: [Task description] → agent_name (depends on: step_1, step_2) |
| 109 | +``` |
| 110 | + |
| 111 | +## Benefits |
| 112 | + |
| 113 | +- **Minimal Code**: Pre-built components handle all the complexity |
| 114 | +- **Automatic Plan Management**: Plans are created, stored, and tracked automatically |
| 115 | +- **Flexible**: Create custom agents for any domain |
| 116 | +- **Robust**: Built-in error handling and progress tracking |
| 117 | +- **Reusable**: Tools and agents work across different workflows |
| 118 | + |
| 119 | +## Examples |
| 120 | + |
| 121 | +See the `examples/` directory for: |
| 122 | +- `fixed_plan_execute_demo.py` - Basic software development workflow |
| 123 | +- `custom_plan_execute_demo.py` - Custom research workflow |
0 commit comments