I suspect with more, smaller artisan roasters out there that the chances of this happening will increase. They probably don't have the equipment that the large commercial concerns do to sort and cull foreign objects and even off-colored beans.
I use two aluminum pans to cull and weigh my beans before and after roast, and sometimes hit them with a UV LED flashlight to look for mold and also other defects as the blacklight seems to provide more contrast making it easier to spot them. Luckily, I only buy commercial beans on occasion and only for espresso generally and since I single dose and hand grind, I see each bean in the tray of my jewelry scale before I grind them up. You could use a magnet to catch any ferrous items, but this is probably a corner case and not all that useful anyway. Certain origins are more likely to have rocks and sticks in them (Tom at Sweet Maria's has posted in his reviews on some coffees to specifically check for these for some beans) but for coffees that have been roasted and stored in bins, it may no longer be origin specific.
I could see if your buying commercially roasted beans taking them out of the bags and pouring them into pans for inspection (I've heard that blue pans are good for culling green beans, not sure if it holds up for roasted beans) and then putting the roasted beans into your storage containers, especially if you put them in jars and store them in the freezer, this would work pretty well as an incoming inspection.
This page talks off all the different foreign objects found post-roast at Caffe Calabria and Bird Rock Roasters:
...after the beans cool, when they pass through the "de-stoner" pan, where staffers pluck out debris that was packed in the raw beans' burlap sacks. Caffe Calabria has found stones, nails, wires, a light bulb's metal base. Once they found a cell phone. Everyone plucks out shriveled or rotten beans, and brass shell casings are common. At La Jolla's Bird Rock Roasters, proprietor Chuck Patton once fished from his
de-stoner one well-done reptile.
You must be doing a heck of a volume not to catch a cell phone pre-roast.