I still dont see how starting an agent creates a clean image. Expanding on your setup would help us provide better answer.
That said, from what I can gather here the following assumption comes to mind :
- You have agents pre-populated on a VM image. Starting this image will in turn start the agent in which you wish to start the build.
So you now have a chicken vs egg problem where you need the agent running to start the job but you need to start the agent as the job starts.
Why not have another agent who's job is to start the image. This new agent is no longer sensitive to the image cleanliness and can run indefinitely.
My approach here would take this a step further and not have the agent as part of the image altogether, but rather have the agent first start the image, provision it with whatever is needed for the build in some way, and then run the build.
A simple shared folder on the image with the host could do the work. Tools like Vagrant could also be of use. But without more information it's really difficult to go further.
This answer on stack overflow could also contain some help in this regard. Basically spins-up a new docker image on demand.
Another possible way with your current setup, make sure the build always ends with a shutdown of the image. This way the next job will be sure to use a fresh image as it should never survive the build. You could even test fort his situation and fail the build outright if you detect the image was re-cycled between builds rather than re-launched.