Order 66 was clear: Execute Jedi for their treason against the Republic. This is what clones were programmed to do, but when Rex received Order 66, Ahsoka was no longer a Jedi. So, why couldn't Rex resist the temptation to kill her?
From tactical point of view, Ahsoka could be threat to the Republic because she was an ally of the Jedi, but Order 66 doesn't say anything about terminating the allies of the Jedi.
Talking about following any orders of Darth Sidious, Darth Sidious didn't say anything about executing Ahsoka.