To be honest I'm not 100% sure why garlic & onions would be so dangerous to small animals - but I've posted the question on the veterinary information network, so hopefully an expert may give us an answer soon
I had a quick flick through my notes on anti-nutrional factors and couldn't find anything relavent there.....something sticks in my mind about something contained in onions that can lead to IMHA (Immune Mediated Haemolytic Anaemia - stimulate the immune system to start destroying red blood cells) but that was in dogs that consumed vast amounts, I doubt similar information would be known about hamsters/rodents so it's probably not that.
I wouldn't have thought most hamsters would want to eat onion or garlic anyway due to the strong taste, maybe it's simply that it's unpalatable. The only decent information I came across on a quick search was studies using allium extracts as herbal remedies for various things, and the rats/mice in those studies weren't dying from the treatments!
I'll report what replies I get on the vet message board (if I get any!)