refactor get_agent