A wartime agreement that unblocked grain shipments from Ukraine and helped temper rising global food prices will be extended by four months, the United Nations and other parties to the deal said on Thursday, preventing a price shock to some of the world’s most vulnerable countries where many are struggling with hunger.