The Afghan government has agreed to release 400 Taliban prisoners, paving the way for direct peace talks with the insurgent group to end nearly two decades of war.