There is no reliable way to identify undercover agents or informants. The good ones act entirely in keeping with their roles. An experienced undercover officer is not going to seem unduly nervous, wear inappropriate clothing, or fumble with the drugs he’s handling.
Undercover officers are legally allowed to lie when you inquire whether they’re law enforcement personnel. It does no good to ask, “Are you a cop?” Undercover cops can just reply, “Of course not.” After all, if they couldn’t lie, it would be a waste of effort for law enforcement agencies to train and disguise all those officers for undercover roles—they’d be exposed early on, every time they tried to pass.1
It’s perfectly legal for undercover officers and informants to engage in criminal activity to protect their cover. Narcs are allowed to buy, sell and do drugs of every kind. Forget any urban myths you may have heard to the contrary: narcs are entitled to smoke/snort/swallow/inject controlled substances. Similarly, vice officers investigating prostitution are allowed to get naked and receive “massage.” (It’s good to know that your tax dollars are being well-spent.)2
Although many undercover officers and informants come equipped with transmitting or recording devices, this type of electronic equipment is miniaturized. A police agent who’s “wearing a wire” is unlikely to be uncovered by mere patting. The equipment can easily be hidden in hard articles of clothing, such as belt buckles, boots, etc. Of course, undercover officers and informants don’t have to be wired for sound, they can just report from memory (accurately or not) about whatever they’ve seen and heard.