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.

Manuel Rocha’s stunning fall from grace could culminate in a lengthy prison term after the 73-year-old said he would admit to federal counts of conspiring to act as an agent of a foreign government.

Prosecutors and Rocha’s attorney indicated the plea deal includes an agreed-upon sentence, but they did not disclose details at a hearing Thursday. He is due back in court April 12, when he is scheduled to formalize his guilty plea and be sentenced.

“I am in agreement,” said Rocha, shackled at the hands and ankles, when asked by U.S. District Court Judge Beth Bloom if he wished to change his plea to guilty. Prosecutors, in exchange, agreed to drop 13 counts including wire fraud and making false statements.

The brief hearing shed no new light on the question that has proved elusive since Rocha’s arrest in December: What exactly did he do to help Cuba while working at the State Department for two decades? That included stints as ambassador to Bolivia and top posts in Argentina, Mexico, the White House and the U.S. Interests Section in Havana.

“Ambassador Rocha,” as he preferred to be called, was well known among Miami’s elite for his aristocratic, almost regal, bearing befitting his Ivy League background. His post-government career included time as a special adviser to the commander of the U.S. Southern Command and more recently as a tough-talking Donald Trump supporter and Cuba hardliner, a persona friends and prosecutors say Rocha adopted to hide his true allegiances.

Peter Lapp, who oversaw FBI counterintelligence against Cuba between 1998 and 2005, said the fast resolution of the case benefits not only the elderly Rocha but also the government, which stands to learn a lot about Cuba’s penetration of U.S. foreign policy circles.

Typically in counterintelligence cases, the defendant is charged with espionage. But Rocha was accused of the lesser crimes of acting as a foreign agent, which carry maximum terms of between five and 10 years in prison, making it easier for prosecutors and Rocha to reach an agreement.

“It’s a win-win for both sides,” said Lapp, who led the investigation into Ana Montes, the highest-level U.S. official ever convicted of spying for Cuba. “He gets a significant payoff and the chance to see his family again, and the U.S. will be able to conduct a full damage assessment that it wouldn’t be able to do without his cooperation.”

But the abrupt deal drew criticism in the Cuban exile community, with some legal observers worrying it amounted to a slap on the wrist.

“Any sentence that allows him to see the light of day again would not be justice,” said Carlos Trujillo, a Miami attorney who served as U.S. Ambassador to the Organization of American States during the Trump administration. “He’s a spy for a foreign adversary who put American lives at risk.”

A Justice Department spokesperson declined to comment.