A former career U.S. diplomat told a federal judge Thursday he will plead guilty to charges of working for decades as a secret agent for communist Cuba, an unexpectedly swift resolution to a case prosecutors called one of the most brazen betrayals in the history of the U.S. foreign service.