Fixed flakey integration test at head.
Broken test in
https://github.com/agent-substrate/substrate/actions/runs/29795626928/job/88526261507
was because, once a old version of worker has been picked and saved in
state.worker, retrying no longer picked a new, usable worker.
Updated the implementation to only update state.worker after having
successfully picked and persisted the worker.