The gravitational potential energy of a mass at a point in a field is defined as the work done by an external agent in bringing that mass from infinity to that point, without a change in kinetic energy.
I don't understand why it's "the work done by an external agent in bringing a mass from infinity to the point", because work done from infinity to the point is in the direction of the gravitational field, so why isn't the work done by the conservative force, aka gravitational force? Shouldnt the work done by an external agent separate the masses further and further, which is from a point towards infinity?
To answer my own question, I thought that I may be misinterpreting the statement,"work done by an external agent in bringing that mass from infinity to that point, without a change in kinetic energy". Instead of placing emphasis on "work done by an external agent in bringing that mass from infinity to that point", which I think happens due to the gravitational force, the "work done by external agent" is not responsible for bringing the test mass from "infinity to a point", but is instead responsible for ensuring the velocity doesn't change during the process (KE kept constant).
Based on the reasoning above, the force exerted by the external agent must be equal in magnitude to gravitational force to ensure velocity is constant and thus, increases as the test mass approaches the central mass since r decreases and $F=GMm/r^2$. Thus, the work done by the external agent, which is GPE is given F×displacement. Displacement is away from the central mass,since external agent has to act opposite to gravitational force to ensure net force is zero, so it is $-r$, where $r$ is towards the central mass. Thus $gpe = - GMm/r$.
This implies that when radius decreases, gpe because more negative and since gpe is a scalar, gpe decreases.
So to summarise my reasoning, I would like to confirm if the following is true:
The work done by the external agent does not bring the test mass from infinity to a central mass. Instead it acts in the direction away from the central mass, towards infinity.
The test mass is brought from infinity to the point due to work done by gravitational force, but although potential energy will be negative when work is done by conservative force, this is not the reason why gpe is negative since the definition of gpe says nothing about the work done by the conservative force and is instead about the work done by an external agent.
The reason why gpe is negative is because the external agent acts opposite to r, and using formula for work done by external agent displacement is negative so gpe is a negative. Alternatively, we can integrate F with respect to r to get -GMm/r.