Using GKAgents with Physics bodies

I have a SKSpriteNode with a GKAgent with behaviour of wandering. How to restrict the node from getting out of the edges of the screen or avoid a wall or something like that. Should I use GKRules or something? Can someone please help me in this.

😃
Thanks!
Using GKAgents with Physics bodies
 
 
Q