Execute discovery research task using the DR workflow. Args: context: Dictionary containing: - task: The research task description - file_path: Optional file path for additional context - goal: Research goal inform
(self, context: Dict[str, Any], params: Dict[str, Any])
| 140 | return workflow_config |
| 141 | |
| 142 | async def execute(self, context: Dict[str, Any], params: Dict[str, Any]) -> Dict[str, Any]: |
| 143 | """ |
| 144 | Execute discovery research task using the DR workflow. |
| 145 | |
| 146 | Args: |
| 147 | context: Dictionary containing: |
| 148 | - task: The research task description |
| 149 | - file_path: Optional file path for additional context |
| 150 | - goal: Research goal information (optional) |
| 151 | - iteration: Current iteration number (optional) |
| 152 | params: Dictionary containing optional configuration overrides |
| 153 | |
| 154 | Returns: |
| 155 | The workflow execution result (format depends on the workflow) |
| 156 | """ |
| 157 | # Extract task information from context |
| 158 | task = context.get("task", "") |
| 159 | if not task: |
| 160 | # Try alternative keys |
| 161 | task = context.get("description", "") or context.get("goal", {}).get("description", "") |
| 162 | |
| 163 | if not task: |
| 164 | raise AgentExecutionError("Task description is required for DR agent execution") |
| 165 | |
| 166 | # Extract optional file path |
| 167 | file_path = context.get("file_path", None) |
| 168 | |
| 169 | # Check if workflow is initialized |
| 170 | if self.workflow is None: |
| 171 | logger.error("DR workflow is not initialized - cannot execute task") |
| 172 | # Return a simple fallback response |
| 173 | return f"Background research needed for: {task}\n\nNote: DR workflow is not available. Please provide background context manually." |
| 174 | |
| 175 | try: |
| 176 | logger.info(f"DR Agent executing task: {task}") |
| 177 | |
| 178 | # Execute the DR workflow |
| 179 | result = self.workflow.execute(task=task, file_path=file_path) |
| 180 | |
| 181 | logger.info("DR workflow execution completed successfully") |
| 182 | |
| 183 | # Return the result directly (user has modified return format) |
| 184 | return result |
| 185 | |
| 186 | except Exception as e: |
| 187 | logger.error(f"Error during DR workflow execution: {str(e)}") |
| 188 | # Return a fallback response instead of raising error |
| 189 | return f"Background research for: {task}\n\nNote: DR workflow execution failed. Please provide background context manually." |
| 190 |
no test coverage detected