SAN FRANCISCO — Prosecutors admitted in legal memos they were taking “a gamble” in April when they agreed to a probation sentence for a man accused of stealing an FBI agent’s gun and selling cocaine.

A losing gamble, it turns out; now the city resident is facing new gun possession charges.

Michael Delfon Gregory Jr. was charged in federal court this week with being a felon in possession of a firearm, a potential 10-year prison offense. The charge comes two months after he was found asleep behind the wheel of his running car next to a bottle of codeine syrup, according to court records. Police found a gun, marijuana and thousands of dollars in cash in the car, too.

Gregory made headlines back in 2016, when in the midst of growing concern over the theft of law enforcement guns, he broke into an FBI agent’s parked car in San Francisco and stole two backpacks, one of which contained the agent’s service pistol.

The agent’s gun was one of nearly 1,000 unaccounted-for law enforcement firearms that went missing between 2010 and July 2016, according to a Bay Area News Group report. One of those missing guns was used to kill Antonio Ramos, a popular Oakland muralist gunned down in Sept. 2015, and another stolen from a federal ranger was used to kill Kate Steinle in July of that year.

Gregory was caught on camera, and agents later raided his home, where they found the gun tucked beneath his mattress. He was also found to possess cocaine, according to court records.

But last April, after noting that Gregory had failed several drug tests, never been gainfully employed, and had been arrested but never convicted of a crime on six prior occasions, U.S. attorneys agreed to a sentence of five years probation with no jail time. Gregory pleaded guilty to possessing cocaine with intent to distribute, and the more serious gun theft charge was dropped.

Assistant U.S. Attorney Kevin Barry wrote in a sentencing memo last April that Gregory had agreed to a drug treatment program, and after being arrested, helped authorities recover the FBI agent’s badge and identification card, which he had discarded somewhere in Golden Gate Park.

“Without (Gregory) telling agents where he had discarded these items, agents would not have found them… While these steps are modest, they nevertheless represent progress,” Barry wrote.

But less than seven months later, at around 1:30 a.m. on Nov. 7, a San Francisco officer found Gregory asleep inside his car with expired tags, parked at a McDonald’s with the motor running. When police searched the car they found a pistol with an extended magazine, as well as codeine syrup and marijuana. They also seized around $6,200 in cash.

Available court records indicate Gregory hasn’t yet had a court appearance, and that he remains in federal custody.