You might want to divide your world into segments/ a grid so that you only check collision for agents that are relevant. Agent A thats on the other side of the screen will NOT collide with B on te opposite side. So why check collision? Google for Spatial partitioning / quadtrees /spatial hashing.
I googled some for you:
Quadtrees
Grid
Also your second forloop should start at a1+1. Because all the previous agents were already checked And need no checking. This also eliminates the need of
if a1 == a2 : continue
Because it starts one index ahead of a1.