Oof, reading Wikipedia entry I think I see how one could spy for 20 years. Sounds like the CIA/FBI can be pretty stupid:
When the USSR disbanded in December 1991, Hanssen, possibly worried that he could be exposed during the ensuing political upheaval, ended communications with his handlers for a time.[31] The following year, after the Russian Federation assumed control of the defunct Soviet spy agencies, Hanssen made a risky approach to the GRU, with whom he had not been in contact in ten months. He went to the Russian embassy in person and physically approached a GRU officer in the parking garage. Hanssen, carrying a package of documents, identified himself by his Soviet code name, "Ramon Garcia", and described himself as a "disaffected FBI agent" who was offering his services as a spy. The Russian officer, who evidently did not recognize the code name, drove away. The Russians then filed an official protest with the State Department, believing Hanssen to be a triple agent. Despite having shown his face, disclosed his code name, and revealed his FBI affiliation, Hanssen escaped arrest when the FBI's investigation into the incident did not advance