A true solution cannot come from such a routine, it’s always going to react and adjust after the fact rather than setting the color temperature correctly in the first place, right before or right after the On command.
That is unreachable for a user routine, so the SmartThings core logic would have to do something like:
If (command is “on”)
–if (device is in Circadian mode)
—-send SetColorTemperature with time-of-day accurate color temp
–send On