I think when hunter-gatherer societies discovered cooking, they could have tried to cook unpalatable plants to make them easier to digest. Then they could've used cooking on poisonous food stuffs to see if it made them edible.
As new cooking techniques were unlocked, they could've combined them to make things even less poisonous.
As new cooking techniques were unlocked, they could've combined them to make things even less poisonous.