In Transformers:Dark of the Moon where the US government decides that the Autobots should leave Planet Earth, Sam - driven by his weak human feelings - has a small bad robot hidden in his hand and asks Optimus Prime what the secret plan is to actually stay on Earth and fight the bad robots.
Optimus Prime actually has a plan (the Autobots hide in a rocket of the spaceship and eventually fall into the ocean before the spaceship leaves the atmosphere) for that and says that Sam is his friend, but he says to Sam that no, there is no such plan!
How did Optimus know that Sam was a spy?