Yes this seems correct. self._agent needs to be the process of the agent. Of course the test needs to make the agent call with the ion-actor-id header set.

This code must be called within the same greenlet that executes the RPC. Otherwise the call may not error out but may not find the message headers.