def METHOD_NAME(self, agentName, maxCycles=1):
    """
    Set number of cycles to execute for a given agent (previously defined)
    """
    if agentName not in self.__agentModules:
        return S_ERROR(f"{agentName} has not been loaded")
    if maxCycles:
        try:
            maxCycles += self.__agentModules[agentName]["instanceObj"].am_getCyclesDone()
        except Exception as excp:
            error = "Can not determine number of cycles to execute"
            gLogger.exception(f"{error}: '{maxCycles}'", lException=excp)
            return S_ERROR(error)
    self.__agentModules[agentName]["instanceObj"].am_setOption("MaxCycles", maxCycles)
    self.__scheduler.setNumExecutionsForTask(self.__agentModules[agentName]["taskId"], maxCycles)
    return S_OK()