In the development of unmanned agricultural machinery, efficiently and accurately detecting field obstacles is crucial for ensuring both operational safety and efficiency. However, due to the complex agricultural environments, existing obstacle detection methods still suffer from low detection accuracy and large model parameters. To address these issues, this study presents CFD-YOLOv8, an application-oriented adaptation of YOLOv8 tailored to complex farmland environments that integrates complementary architectural modules and a practical IoU-based loss to improve detection performance. First, we design a Task-Aligned Dynamic Detection Head to improve the model’s adaptability to challenging environments while achieving lightweight optimization. Second, we incorporate RFCAConv into the C2f module to expand the receptive field and strengthen the model’s focus on crucial target regions. Finally, we introduce the Powerful-IoU loss function to optimize bounding box handling, thereby accelerating convergence and enhancing localization accuracy. Experiments conducted on our custom-built field obstacle dataset demonstrated that CFD-YOLOv8 improves average detection precision by 1.9%, with precision and recall rates increasing by 3% and 0.2%, respectively, while reducing model parameters by 18.9%. These results significantly outperform current mainstream obstacle detection methods. The findings of this study offer robust technical support for autonomous obstacle avoidance and path planning in unmanned agricultural machinery operating in complex environments, laying a foundation for the further advancement of agricultural mechanization and intelligence.