def add_plugins_to_uninstall(ctx, plugins_to_uninstall, sequence):
    """Adds a task to the sequence that uninstalls the plugins.
    """
    if not sequence or not ctx or not plugins_to_uninstall:
        return
    sequence.add(ctx.send_event(
        'Uninstalling deployment and workflow plugins'), ctx.execute_task(
        task_name='cloudify_agent.operations.uninstall_plugins', kwargs={
        'plugins': plugins_to_uninstall, 'delete_managed_plugins': False}))
