def METHOD_NAME(mode_name):
    if mode_name == '':
        self.chat_memory.set_mode(None)
        switched_to_mode.append(None)
        return 'success'
    avail_modes = list(self._modes.keys())
    if mode_name not in avail_modes:
        return f'Error: task is not found. Available tasks: {", ".join(avail_modes)}'
    self.chat_memory.set_mode(mode_name)
    switched_to_mode.append(mode_name)
    return 'success'