Yes, he should have gotten the agreement to not prosecute in writing, but a deal is a deal. Epstein made a similar deal.
The decision overturning his conviction is correct IMHO. He actually could sue for wrongful or malicious prosecution (whatever the local term of art is) and make some $$$$ and perhaps recoup his attorney fees. Plus, now comes the Book Deal and Movie Rights.