<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def _restart_on_cancel(logger, agent):
 """ Restarts an agent when it is cancelled """

    while True:
        try:
            await agent.run()
        except asyncio.CancelledError:
            logger.exception("Restarting agent")
            pass