I don't think you can address this from a Utilitarian point of view, because utility is not well-defined for those who do not have a consistent view of the world, and whose world-view is continually evolving or shifting to a great degree, such as children and the mentally ill. You need to be more conservative, and work from the 'limited interchangeability of individuals'. The clearest picture of that is from Kant.
From a Kantian perspective, the deduction that renders the "Universalizable" version of the Categorical Imperative to the "Ends-Means" version gives us the clue. We cannot universally approved of manipulation based on superior agency, or we all become puppets of the brightest sociopath among us. Instead, we need to find a way of negotiating that respects limited agency.
To me, that question has to come down to the possibility of reciprocal agreement. An unconscious person cannot agree, and someone like a child cannot agree with an adult in a way that is truly reciprocal: the child's stated agreement is based on a more limited understanding of consequences, and what they are agreeing to is not really the same thing as what the adult is agreeing to.
So the question is whether continuous working memory is necessary for reciprocal agreement, or whether agreement can be based on the facts present in the moment. I think that the answer is not the same in all cases, but I would argue it depends upon the nature of the facts, and that the unimpaired individual is competent to know the difference.
We are ourselves both in the moment, in that we have a personality of a certain character, and across time, in that our decisions reflect what is going on around us, and we can change that character. Agreement that is in accord with the stable character of the person making it can be accepted even when that person is impaired.
If you do not have adequate exposure to the individual when lucid, you may not be competent to make that judgement, and in that case, expecting consent is out of order. Also, if recent changes which the disabled person may not have processed correctly have taken place that might have real bearing to bias the decision in a negative direction, it is not safe to accept positive consent that has significant potential negative consequences that the individual has not already faced.
But uniformly deciding that someone who was once competent to initiate sexual relationships no longer is, is insulting and punitive. So it is not a good idea to assume the impossibility of consent without analysis of the individual case.