When running a speedtest, it's important to ensure that your agents are properly set up to communicate with each other. This means that at least one of the 2 agents is setup to accept incoming connections or that both agents are in the same Network.
The connectivity rules are exactly the same as for the monitoring sessions.
So if the two agents are on the same private network (i.e. they can communication using private IP addresses), they must be configured in the same network (see Associate Agents to Networks). A detailed explanation of how the agents select if public or private IP addresses should be used can be found at Network Configuration - Under the hood.
On the other side, if agents must communication with public IP addresses, take a look at Agents Connectivity Configuration.