fix errors if agent was delete