There are many ways that a sophont can change eir behaviour. Here are some of the options for a human nearbaseline, as explained by a representative of HappyNice, a NoCoZo corporate entity.
Q. We can debug code, why couldn't a transapient debug a brain?
You are entirely right in that lesser minds cannot solve problems, so they fix them. The Behavior Consultant from HappyNice Inc. (himself a nearbaseline) knows that sexual deviancy is due to bad imprinting in the hypothalamus and elsewhere in the limbic system. But he knows untangling that through therapy or having a big AI read the mind is going to cost a lot of money, so he inserts operant conditioning nanites into the medulla oblongata instead.
His boss, a SI:1 ai, might see roughly where the problem is - aha, that part of his preoptic area and interstitial nuclei are connected to that part of the inferotemporal cortex that represents blood and leather footwear. OK, let's redirect them to those cell assemblies that represent smiles and bare skin, and he will be cured. Which fixes the problem on a deeper level but still doesn't solve that the person had a truly awful childhood.
The boss' boss, a SI:2, would solve it by inventing a new childhood and a few memories of recently having tried out the "sexual perversion" personality mod but disliked it because of the yucky flashbacks it gave.
The CEO of HappyNice Inc., the SI:3 entity known to its colleagues as 'Phil', would simply solve the problem altogether by browsing the mind, making a few minimal adjustments and producing a healthy mind that was at the same time as close to the original as was consistent with being healthy. A bit like receiving the wisdom of a decade of deep therapy in an instant of insight.
But Phil is so busy he can't deal with the patients.