It is called “secret profit” and it is extremely unethical. On the other hand, if the agent discloses everything to all parties in the transaction (I negotiated for X+Y and my contract with the principal says I can keep Y, for example), it isn’t unethical.