The intensifi cation of agricultural production has led to the disruption of nutrient cycles in agroecosystems. In livestock farming, one of the key problems is the low degree of using secondary resources (organic fertilizers based on manure and manure). (Research purpose) To substantiate the basic principles of assessing the agroecosystem environmental sustainability and to develop engineering methods for ensuring environmental safety in livestock farming. (Materials and methods) To solve the problems of agroecological assessment, eff ective technology choice and intelligent system creation, the following indicators were used: 1. specifi c density of animals (mainly for macro-assessment); 2. nutrient balance (the diff erence in the amount of nitrogen available in the formed organic fertilizers with environmentally safe consumption); 3. nitrogen losses during the disposal of organic waste from livestock farming; 4.the eff ectiveness of implementing the best available techniques (BAT). (Results and discussion) Using the assessment of indicators 1 and 2 in the case of the Leningrad region, it was revealed that 3 districts are classifi ed as territories with an excessive risk to the environment, 1 district is classifi ed as a territory with a high risk, 5 districts – with an acceptable risk, and 8 districts – with a low risk to the environment. To solve problems in areas with excessive and high load, we conducted an assessment on indicators 3 and 4, which allowed us to explore technical solutions and select the BAT to reduce the environmental burden. The obtained results showed that among the main technical solutions in the fi eld of organic waste management of livestock farming are biofermentation and the introduction of liquid organic fertilizers. Biofermentation in special chambers can reduce emissions of polluting gases by more than 2 times, and speed up the processing process by more than 60 times. To work with liquid organic fertilizers, intelligent machines with low-emission working bodies have been developed to reduce nitrogen losses during application by up to 50 percent. To solve the problems of agricultural monitoring and engineering solution management, a digital system has been developed that allows to model scenarios of technological development and their impact on the agroecosystem environmental sustainability. (Conclusions) The results obtained allow us to systematically analyze the problems of agroecosystem environmental sustainability and propose specifi c technical and optimization solutions for livestock farming.