<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def find_agent(self, agent_id):
 """ Return the medium class of the agent with agent_id if the one is running in simulation. """

        try:
            recp = IRecipient(agent_id)
            agent_id = recp.key
        except TypeError:
            pass
        agency = self.find_agency(agent_id)
        if agency:
            agent = yield agency.find_agent(agent_id)
            defer.returnValue(agent)