After an agent leaves your team, you can reassign the tickets assigned to them, to another agent, before deleting their profile from your account. To do this, please go to the Tickets list page > use the Agent name filter to filter all tickets assigned to that agent > click on Bulk Actions > update Agent name field to another agent.
This can be done 30 tickets at a time as each page in the ticket list contains 30 tickets.
If there are a lot of tickets, set up a new automation rule under Admin > Workflows > Automations > Time triggers to do the above. This will reassign all the tickets that were updated in the past 30 days.
Note: Make sure to turn OFF the rule once all tickets have been re-assigned because it may clash with another rule with the same conditions later on.