How to completely stop automatic reruns?

I know this has probably been asked many times but I’d like to know if its possible to COMPLETELY stop automatic reruns, even if there is no built in method to do this currently. And no, I am not talking about monkey-patching with st.cache, session states, forms etc.

I am willing to change the settings, monkey-patching the source code, or even change the source code entirely (of course, on my local system).

Has anyone been able to do this? Because building custom perplexity-style applications is extremely difficult to do without this, which is what I am trying to build. And I really don’t want to build a custom react frontend as I am not a frontend developer.

Please help!

If st.stop() won’t help you then you really ought to use another framework.

The reruns form the backbone of how Streamlit works. The rerun is the method by which information from the front end updates values on the backend. So by design, caching should be used to prevent “redoing” things that only need to be done once and Session State should be used to store information that should persist. Beyond that, there are tools to limit the scope of reruns like forms and fragments, but preventing reruns altogether would be contrary to the fundamental way Streamlit works.

Generally, think of a script rerun as “doing one incremental thing.” After initialization, the rerun shouldn’t be redoing unnecessary heavy lifting.