short answer is, the agent doesn't need to know the "username", it's the server who checks it, and a key id is picked by the server if multiple keys are available.
here's an (over-simplified) description of the ssh authentication process using public keys:
first, the ssh client send the login user name to the server, and the server should send back allowed authentication methods, e.g. password, and/or certain public key algorithms such as RSA2048.
then, the client send a "list identities" request to ssh-agent, which will provide all the public keys that are loaded into the agent, and this list is then sent to the server.
then, the ssh server will check the provided public keys, and if one of the key is recognized (e.g. listed in user's ~/.ssh/authorized_keys), it will send some challenge data to the client, along with the picked public key.
then, the client request the agent to sign the challenge using the corresponding private key, and send the signed data back to the server.
finally, the server checks the signature and establish the requested communication tunnels, which are used as redirected pipes of the remote program to be executed (e.g. user's shell or git)