There are a number of ways you can go about this, all depending on your design intent.
You can set up the thickness as a ratio of the radius which solves the overlap problem and always works.
If you want to give users control over thickness in millimeters (or any units), you need to set up a cutoff value which overrides the thickness slider with default minimum to avoid overlap as you tried with the Python script.
You may also consider leaving the control over thickness to the script and have a list of predefined optimal values. This way users control only the radius of the pipe and the thickness is adaptive.
Attached Grasshopper definition covers all mentioned cases.
thickness_radius.gh (48.7 KB)