Welcome to OrbitAI! This guide will walk you through building a complete multi-agent system using a practical recipe preparation workflow. You’ll create specialized AI agents that work together to plan meals, find recipes, and generate shopping lists.
Meal Planner
Analyzes dietary preferences and creates personalized meal plans
Define three specialized agents for your workflow:
Meal Planner Agent
Recipe Research Agent
Shopping List Agent
Copy
private func createMealPlannerAgent() -> Agent { return Agent( role: "Meal Planning Specialist", purpose: "Create personalized meal plans based on dietary preferences and constraints", context: """ You are an expert nutritionist and meal planning specialist with extensive knowledge of: - Dietary requirements and restrictions (vegetarian, vegan, gluten-free, keto, etc.) - Nutritional balance and meal composition - Seasonal ingredient availability - Budget-conscious meal planning - Family-friendly meal options Your goal is to create practical, healthy, and delicious meal plans that fit the user's lifestyle, preferences, and constraints. """, verbose: true, temperature: 0.7 )}
Temperature Settings: Use lower values (0.1-0.3) for structured tasks like list organization, and higher values (0.7-0.9) for creative tasks like meal planning.
private func createWorkflowTasks( mealPlannerAgent: Agent, recipeResearchAgent: Agent, shoppingListAgent: Agent) -> (ORTask, ORTask, ORTask) { // Task 1: Meal Planning let planningTask = ORTask( description: """ Create a 7-day meal plan for a family of 4 with the following requirements: - 2 adults, 2 children (ages 8 and 12) - Budget: $150 per week - Dietary preferences: Reduce processed foods, include more vegetables - Allergies: One child has a mild nut allergy - Cooking time: Maximum 45 minutes per meal on weekdays, unlimited on weekends - Must include: 7 breakfasts, 7 lunches, 7 dinners Consider seasonal ingredients (current season), nutritional balance, and variety in cuisines and flavors. """, expectedOutput: """ A detailed 7-day meal plan formatted as follows: - Day-by-day breakdown (Monday through Sunday) - Each day should include breakfast, lunch, and dinner - Estimated prep time for each meal - Nutritional highlights - Special notes for dietary considerations - Total estimated weekly cost """, agent: await mealPlannerAgent.id, outputFormat: .markdown, maxExecutionTime: 120, guardrails: [.noHarmfulContent] ) // Task 2: Recipe Research (depends on meal planning) let researchTask = ORTask( description: """ Based on the meal plan from the previous task, research and provide detailed recipes for each meal. Previous meal plan: {task_0_output} Research priority should be given to meals that are: - Family-friendly and kid-approved - Use common, easily-found ingredients - Have good nutritional balance - Fit within the time constraints specified """, expectedOutput: """ A comprehensive recipe collection with step-by-step instructions, ingredient lists, and cooking tips for each meal. """, agent: await recipeResearchAgent.id, context: [planningTask.id], // Depends on meal planning task outputFormat: .markdown, maxExecutionTime: 180, guardrails: [.noHarmfulContent] ) // Task 3: Shopping List Generation (depends on recipe research) let shoppingTask = ORTask( description: """ Create an organized shopping list based on all the recipes from the previous task. Recipe collection: {task_1_output} Requirements: 1. Consolidate duplicate ingredients across all recipes 2. Calculate total quantities needed for the week 3. Organize by grocery store sections 4. Include estimated prices and total budget """, expectedOutput: """ A comprehensive shopping list organized by store sections with quantities, estimated prices, and shopping tips. """, agent: await shoppingListAgent.id, context: [researchTask.id], // Depends on recipe research task outputFormat: .markdown, maxExecutionTime: 90, guardrails: [.noHarmfulContent] ) return (planningTask, researchTask, shoppingTask)}
Tasks can reference previous task outputs using {task_N_output} syntax in their descriptions. This enables powerful chaining of agent workflows.
let handler = ToolsHandler.sharedlet isAvailable = await handler.isToolAvailable(named: "webSearch")if !isAvailable { print("Tool not available, using alternative approach")}