created a factory for making an agent.