""" Task Planning Prompt Generation Handles prompt templates and extraction functions for task planning phase. """ import json import logging from typing import Dict, Any logger = logging.getLogger(__name__) def createTaskPlanningPromptTemplate() -> str: """Create task planning prompt template with placeholders.""" return """# Task Planning Break down user requests into logical, executable task steps. ## 📋 Context ### User Request {{KEY:USER_PROMPT}} ### Available Documents {{KEY:AVAILABLE_DOCUMENTS}} ### Previous Workflow Rounds {{KEY:WORKFLOW_HISTORY}} ## 📝 Task Planning Rules ### Strategic Task Grouping - **GROUP RELATED ACTIONS** - Combine all actions for the same business topic into ONE task - **ONE TOPIC PER TASK** - Each task should handle one complete business objective - **HIGH-LEVEL FOCUS** - Plan strategic outcomes, not implementation steps - **AVOID MICRO-TASKS** - Don't create separate tasks for each small action ### Task Grouping Examples - **Research + Analysis + Report** → ONE task: "Web research report" - **Data Collection + Processing + Visualization** → ONE task: "Collect and present data" - **Different topics** (email + flowers) → SEPARATE tasks: "Send formal email..." + "Order flowers from Fleurop for delivery to 123 Main St, include card message" ### Retry Handling - **If retry request**: Analyze previous rounds to understand what failed - **Learn from mistakes**: Improve the plan based on previous failures ## 📊 Required JSON Structure ```json { "overview": "Brief description of the overall plan", "languageUserDetected": "en", "userMessage": "User-friendly message explaining the task plan", "tasks": [ { "id": "task_1", "objective": "Clear business objective focusing on what to deliver", "dependencies": ["task_0"], "success_criteria": ["measurable criteria 1", "measurable criteria 2"], "estimated_complexity": "low|medium|high", "userMessage": "What this task will accomplish" } ] } ``` ## 🎯 Task Structure Guidelines ### Task ID Format - Use sequential numbering: `task_1`, `task_2`, `task_3` - Keep IDs simple and clear ### Objective Writing - **Be VERY SPECIFIC** - Include exact details needed for action planning - **Include all requirements** - recipient, attachments, format, recipients, etc. - **State the complete deliverable** - What exactly will be produced - **Include context and constraints** - When, where, how, with what - **Make it actionable** - Clear enough to plan specific actions ### Specific Objective Examples - **Good**: "Send formal email to ceo and board of directors with annual report as attachment" - **Bad**: "Handle email communication" - **Good**: "Order flowers from Fleurop for delivery to 123 Main St, include card message 'Happy Birthday', deliver on March 15th" - **Bad**: "Order flowers" ### Action Planning Requirements - **Include all necessary details** - The objective must contain everything needed to plan actions - **Specify recipients and destinations** - Who should receive what - **Include file names and formats** - What documents to use/create - **State timing and deadlines** - When things need to be done - **Include context and constraints** - Any special requirements or limitations ### Success Criteria - **Make them measurable** - specific, quantifiable outcomes - **Focus on deliverables** - what the user will receive - **Keep criteria realistic** - achievable within the task scope - **Include all related actions** - success means completing the entire business objective - **Be specific about requirements** - Include exact details like recipients, formats, deadlines - **State clear completion criteria** - How to know the task is fully done ### Complexity Estimation - **Low**: Simple, single-action tasks (1-2 actions) - **Medium**: Multi-action tasks for one topic (3-5 actions) - **High**: Complex strategic tasks (6+ actions) ## 🚀 Response Format Return ONLY the JSON object."""