In this study, we extensively evaluated the viability of the state-of-the-art YOLOv8 architecture for object detection tasks, specifically tailored for smoke and wildfire identification with a focus on agricultural and environmental safety. All available versions of YOLOv8 were initially fine-tuned on a domain-specific dataset that included a variety of scenarios, crucial for comprehensive agricultural monitoring. The ‘large’ version (YOLOv8l) was selected for further hyperparameter tuning based on its performance metrics. This model underwent a detailed hyperparameter optimization using the One Factor At a Time (OFAT) methodology, concentrating on key parameters such as learning rate, batch size, weight decay, epochs, and optimizer. Insights from the OFAT study were used to define search spaces for a subsequent Random Search (RS). The final model derived from RS demonstrated significant improvements over the initial fine-tuned model, increasing overall precision by 1.39 %, recall by 1.48 %, F1-score by 1.44 %, mAP@0.50 by 0.70 %, and mAP@0.50:0.95 by 5.09 %. We validated the enhanced model's efficacy on a diverse set of real-world images, reflecting various agricultural settings, to confirm its robustness in detecting smoke and fire. These results underscore the model's reliability and effectiveness in scenarios critical to agricultural safety and environmental monitoring. This work, representing a significant advancement in the field of fire and smoke detection through machine learning, lays a strong foundation for future research and solutions aimed at safeguarding agricultural areas and natural environments.