GHPython script suddenly auto-baking?

I have a rather involved python script that takes 3D curves and “decomposes” them into a series of simple arcs with short straight sections at the end. The point to make here is that there is much geometry manipulation going on, and that I liberally use the Rhinoscript “AddXXX” functions throughout, to generate geometry that is then exported from the script for further processing. But I never change the script context in my Python code, so no new geometry should appear in the Rhino doc. That was true until just recently…now suddenly this Python component is “auto-baking” all the geometry that I add!!! I’m completely flummoxed.

The only thing I can think of is that some other script (for instance my Baking script?) is forgetting to change the script context back. Is script context persistent that way? In any case, I looked at those scripts and all seems fine, the context is restored at the end.

Does anyone have any insight/suggestions? Thanks.

I found the issue: it was indeed a different script that set the scriptcontext to the Rhino doc and didn’t set it back.

I had no idea the script context was persistent like that. Lesson learned, and hopefully this can help someone else along the way…