You train 'em up as best as you can, test their logic again and again, grill them on security and data integrity and then you send your little robots out into the world, hoping for the best.
No matter how hard you try however, they can fall in with the wrong type. Some roguebot takes advantage of 'em, transfers a quick-fame-and-easy-success virus into their input ports and the next thing you know, they're involved in seedy enterprises in the dark back-alleys of internet.
The world can be a tough place for a young bot.