When you stockpile food into your settlement, there should be an option to determine the minimum amount of food needed in that settlement before exporting a surplus is allowed. AI settlements would also need this option and change their settings based on their prosperity/food income, as they are...