The verb agree accepts infinitive complements after a for ... to complementiser:
(a1) I agreed for Jill to go.
When the subject of the infinitive is the same as that of the main verb, there is obligatory deletion of the second [mention of the] subject:
(a2) I / they agreed to work / go. // I / they agreed to do this work.
[see Analyzing Syntax and Semantics ... Virginia A. Heidinger]
On the other hand, agree to may be used as a transitive multi-word verb taking a regular noun phrase
(b) The store owner agreed to the supplier's new proposal for a weekly
an obvious gerund
(c) If you don't agree to my leaving early, I'll just do it anyway.
or a less obviously identifiable ing-form fairly near the nounal end of the continuum
(d) I cannot agree to going with you on such a dangerous adventure!
[(b) and (c) from the McGraw-Hill Dictionary of American Idioms and Phrasal Verbs and (d) from The American Heritage® Dictionary of Phrasal Verbs.]