The article examines the problems and challenges of the production and sale of agricultural products that Ukrainian farmers faced during the martial law. The need for agricultural enterprises to respond to unforeseen actions, while avoiding a complete structural restructuring or destruction of the system, has been determined. What exactly is determined by the flexibility of such enterprises? The priority ways of responding to problems with exports are outlined: increasing the volume of domestic consumption, attracting investments, expanding sales markets, using state support. Import problems that appeared with the outbreak of the war in Ukraine were identified. The main ones are the decrease in the number of countries that are ready to export their vegetable products to Ukraine due to the deterioration of the political and economic situation; an increase in the cost of transporting vegetable products due to an increase in the risks and costs of transportation through the conflict zone; deterioration of the quality of vegetable products due to difficult storage and transportation conditions; an increase in the cost of vegetable products due to an increase in the costs of its cultivation and processing in exporting countries; a decrease in the volume of imports due to a decrease in the demand for vegetable products in Ukraine. The indicated areas of the flexibility of agricultural production in the conditions of martial law: the ability to quickly change the types and volumes of cultivated crops in accordance with market conditions and changes in consumer preferences; the ability to quickly change the volume and range of products produced, the ability to effectively use resources such as water, fertilizers, energy and labor through the introduction of resource-saving technologies; the ability of enterprises to adapt their workforce to changing production requirements and conditions; ability to effectively manage finances, including budgeting, financial analysis and risk management to ensure financial sustainability and flexibility in production. Therefore, the flexibility of production in combination with the principles of universality, adaptability and adaptability is a key aspect in overcoming food security in modern conditions.