All jobs

Fix "AttributeError: module 'streamlit' has no attribute 'experimental_rerun'"

Yes. An agent finds each st.experimental_rerun and other removed Streamlit calls, ports them to st.rerun, and drives the page through the button that crashed.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

Streamlit 1.37.0 removed st.experimental_rerun. On the current 1.67.0 the call raises AttributeError: module 'streamlit' has no attribute 'experimental_rerun'. st.experimental_rerun has been removed. Use st.rerun instead. The replacement arrived in 1.27.0, where both names exist, and 1.26.0 has only the old one; 1.36.0 is the last release with both. st.cache went the same way: on 1.67.0 it raises st.cache has been removed. Use st.cache_data or st.cache_resource instead. An app with streamlit unpinned in its requirements gets the current release on every fresh install, so the first click on a button that calls the old name takes the page down.

dwillowtree/diana is a Streamlit app that turns threat intelligence into detection rules with a chosen LLM. requirements.txt lists streamlit with no version, and .devcontainer/devcontainer.json runs pip3 install --user streamlit on top of it. app.py sets up cost tracking and hands rendering to render_ui in ui.py. The removed call is on line 594 of ui.py: after the five processing steps finish, a Start Over button on line 591 resets st.session_state.step to 0, calls update_progress() and then st.experimental_rerun(). Everything before it works on the current release, so the error appears only at the end of a full run, when the user asks to start again. The file uses st.session_state throughout, lines 277 to 585, to carry the step counter and results across reruns, which is the mechanism st.rerun relies on.

The agent reproduces it without a model key. It installs the requirements in a virtual environment, reports the Streamlit version, and runs a one-line check that st.experimental_rerun is absent and st.rerun present. Then it searches the whole app for every st.experimental_* and st.cache call, since a file that has one removed name usually has others, and finds the single call on line 594. The fix is st.rerun() on that line, which 1.27.0 and later accept, plus a lower bound of streamlit>=1.27 in requirements.txt so the install cannot land on a release without st.rerun. app.py is untouched.

The proof is the button. The agent starts the app in the sandbox with streamlit run app.py and placeholder environment variables from .env.example, which the LLM call reads only when a step runs, and uses Streamlit's AppTest from streamlit.testing.v1 to drive ui.py: it sets st.session_state.step to 6 the way a completed run would, which renders the Start Over button, clicks it, and asserts the script reran with step back at 0 and no exception. That covers the one path that crashed, without a model call. It adds the AppTest script as a test so the next removed name is caught before a user finds it.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "This Streamlit app fails with AttributeError: module 'streamlit' has no attribute 'experimental_rerun'. Read requirements.txt and any devcontainer or Dockerfile and report how streamlit is installed. In a clean virtual environment install the requirements, report the installed streamlit version, and confirm which of st.experimental_rerun and st.rerun exist. Find every st.experimental_* and st.cache call in the app with file and line, and port each to its current name as given by the installed package's error message; change nothing else. Add a lower bound on streamlit in requirements.txt that guarantees the new names exist. Write a test with streamlit.testing.v1.AppTest that sets the session state to the point where the failing button renders, clicks it, and asserts the app reran without an exception. Do not call any LLM API; use placeholder values from .env.example for required environment variables. Open a pull request with the list of changed calls, the installed version, and the test output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

A pull request with a one-line change on line 594 of ui.py, a bound in requirements.txt, and a new test. The description starts with the installed Streamlit version and the one-line check showing the old name absent and the new one present, then the search output, so the reviewer sees that this was the only removed call in the app and not just the one that crashed first.

The record of the run holds the AppTest run: the session state set to the finished step, the button click, and the rerun ending with step at 0. Because the test drives the page without a browser or a model, the transcript is short and the evidence is the test's own assertions.

Before merging, a reviewer runs the app once with a real key and clicks Start Over after a complete pass, since AppTest does not render the custom CSS in ui.py or exercise the LLM steps. The pull request names that as the one check it did not make.

Run it on every app rebuild or redeploy

An unpinned Streamlit app picks up a new release every time its container or Codespace is rebuilt, and the removed name shows up as a traceback in the page. An automation on the Project with a schedule trigger set to a weekly cron and the prompt "install the requirements fresh, list every st.experimental_* and st.cache call, check each against the installed streamlit, and open a pull request only if one is gone" catches the next removal before a user does. A run the automation starts has its own max_runs_per_hour cap.

When the crash has already happened and an error tracker caught it, a handler on your server forwards the tracker's webhook to the Rush webhook trigger's URL with Authorization: Bearer <its secret>, since Sentry signs its own requests and cannot add that header. The payload reaches the agent after the prompt, as data, and the pull request is read from the session.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

The port is one word; the confidence comes from driving the page. AppTest lets the agent click the button that crashed and assert the rerun, and doing that in a sandbox means installing the app's model libraries and starting Streamlit without any of it on a laptop. The transcript keeps the version check, the search and the test output together.

A team with several Streamlit tools, each unpinned and each with a Start Over or a Refresh button, sends the same request once per repository. Each run is its own sandbox and its own pull request, up to the key's max_concurrent limit at a time, and the key's webhook reports each run.completed with its session URL.

Frequently asked questions

Which Streamlit release removed experimental_rerun?

1.37.0. On 1.36.0 both st.experimental_rerun and st.rerun exist, on 1.37.0 only st.rerun does, and the current 1.67.0 raises an AttributeError whose message names the replacement. st.rerun first appeared in 1.27.0, which is why the pull request sets that as the lower bound.

Is st.rerun a drop-in replacement?

For this app, yes: it stops the script and runs it again from the top, and the step counter and results live in st.session_state, which survives the rerun. The test sets the state, clicks the button, and asserts the counter reset, which is the behaviour the old call provided.

Does the app use st.cache anywhere?

The search in this repository finds no st.cache call, only the one st.experimental_rerun on line 594 of ui.py. The request asks for both so an app that has them gets each ported in the same pull request; on 1.67.0 st.cache raises the same kind of error and names st.cache_data and st.cache_resource.

Does the agent need an OpenAI or Anthropic key?

No. The LLM is called only inside a processing step, and the test sets st.session_state.step past those steps before clicking Start Over. Environment variables come from .env.example with placeholder values, and no request leaves the sandbox.

Why pin streamlit at all when the fix is one line?

Because st.rerun does not exist before 1.27.0, so an install that lands on an older release would fail on the new name instead. A lower bound keeps every fresh install, including the devcontainer's extra pip3 install --user streamlit, on a release where the ported call exists.

More Streamlit jobs

More jobs like this: Fix a bug from an alert

Keep reading