Can the gerund be used after a form of "agree to" (e.g. "agrees to doing", "agree to going" and "agreed to leaving")?
It's not a mortal sin, but the simple infinitive is more usual.
If you want to over-analyse a bit, when you use the gerund, you're agreeing to that action / activity “in general”, as acceptable, rather than specifically to take that action. For example:
I agree to go home - I will go home (now, or at a particular time that's been suggested)
I agree to going home - I agree that going home would be a good idea. I'm not saying I will do it now or at any particular time
I agree to hunting foxes - I'm a posh twit who thinks chasing animals until they're terrified and watching as they are horribly mangled by a group of ferocious hungry dogs is ok
I agree to hunt foxes - I'm a posh twit who is going to go do those horrible things now
... honestly just trying to find a good example, though I'm not keen on hunting :o)