Agent get stuck outside of graph

Hi,
I’m using the aipath. My goal is to try to get an animal ai to wander, but the problem I’m running into is quite often the animal accidentally moves to close to the edge of the grid graph so that it gets pushed outside of the grid graph. Then it just gets stuck and can’t move anymore. Is there some way to prevent this from happening? Or to force the animal to go back to the grid?