That's why we call them “accused”; we refer to “accused” at the outset.
The prosecutor would have to be convinced that the prosecution threshold had been such that there was a prospect of conviction, that the evidence was there. They could invite them to negotiate the terms, but the agreement itself could not be approved until the court was satisfied that they had been charged. They could be charged years ago or right up until the last minute, but they have to have been charged before the agreement could be approved by the court and take effect.