Bit of Neither
Probably it was both trial-and-error and observation of other amniles. When in the woods in USSA, one is advised to find and observe a racoon, as what it eats will be good for you to eat, too.
In the mad scramble to survive, back when we were fledgeling beasts who might well lose the race entirely with one mis-placed foot, or paw, we most likely pilfered and stole and grabbed and scavenged from nature and other animals, too. Ever seen dogs lapping at spilled cow's milk? Dogs are somewhat notorious for gakking down anything they find, then horking it back up if it disagrees. Often they'll give it a second chance, too.
In this way, we probably learned to exploit all manner of food sources. Also, being primates, we tend to fiddle. So we notice that the grain that got ground up by being under the alpha male's butt for a week, when mixed with water spilled by clumsy Tom, then heated on a rock, made a pasty substance that one could chew on, and it tasted Not Puke. So we fiddled, and discovered bread, etc.
A series of accidents and brilliant observations and leaps of imagination, all irreproducible, each step a whole episode for James Burke to explicate on a new set of CONNECTIONS.