Hmm. I think of it this way. The Machines has belittled the humans ever since they defeated them. So they kinda think of themselves as gods. Now in religion and in mythology gods often times intervene in human history and individuals. they would cloth themselves like mortals or send messengers to prophesy and/or guide people. They would also send tests and problems to see if people are worthy and all. And, at times, gods bicker upon one another and would be against each other and when one god would send a person to do something, often times another would send his/her minions to be hurdles.
Agents are there to perhaps test the resolve of the One. also, as i see it, some machines have evolved into their own personality outside their programming (hence the rouges). And, what more, it seems as if the machines have fell victim (like the humans) to slavery. Before the Matrix was setup (in The Second Renaissance) the machines were afraid to be deleted so they created their own nation. separated themselves from the ones that destroys their individuality. in the matrix, the rouges remain hidden because their very existence is threatened by the higher up.
Perhaps Neo is the one to save them, both machines and human, from the slavery of programming and to the freedom of individuality and a choice to live. Even Smith himself, before his 'death', has evolved out of his Agent program and perhaps taking the baby steps into being a rogue.
Perhaps in the end we will see a much higher consciousness of the Machines. The original A.I. Him/Herself. Outside the Matrix. Remember, the matrix is there to keep us. There could be other programs running outside the Matrix that lives in the 'real' Machines themselves.
hope u guys understand my post hehe...