What the agent does
sklearn on PyPI was never the library. It was a placeholder package that depended on scikit-learn, and its maintainers turned it into a deliberate error: installing it now stops with The 'sklearn' PyPI package is deprecated, use 'scikit-learn' rather than 'sklearn' for pip commands. Any project that listed the import name as a requirement fails at pip install, usually in a Docker build nobody had touched. The agent finds every place the name is declared. In a pipeline like shreyashankar/toy-ml-pipeline there are two: the bare line sklearn in requirements.txt, and 'sklearn' in the install_requires list in setup.py. The Dockerfile runs pip install -r on the first and pip install -e on the second, so fixing one of them leaves the image build broken at the next step.
It reproduces the error in a clean virtualenv, changes both entries to scikit-learn, and leaves the code alone. The import name is still sklearn, so from sklearn.ensemble import RandomForestClassifier and from sklearn.metrics import f1_score in utils/models.py are correct as written. The README's prose mentions of sklearn also stay. The agent says this explicitly in the pull request, because a search and replace across the repository for the word would break both imports.
The rename is the easy half. Neither manifest pins a version, and the placeholder used to pull in whatever scikit-learn was current at the time, so an environment rebuilt today gets a release that is years newer than the one the project last ran on. The agent checks what that does to this code. It installs the fixed requirements, imports utils.models, and exercises RandomForestModelWrapper on a small synthetic frame: train, score, predict and a pickle round trip. On the newest scikit-learn all of it runs.
Then it reads how models reach production, since that is where a version jump hurts. ModelWrapper.save pickles the whole wrapper to an S3 bucket through save_output_pkl in utils/io.py, and inference/app.py calls RandomForestModelWrapper.load('training/models') at import time. A pickle written by one scikit-learn version is not guaranteed to load, or to predict the same, under another. The agent has no credentials for the bucket and does not ask for any. It reports the risk with the two lines of code involved and gives the maintainer the choice: pin scikit-learn to the version the stored model was trained with, or rebuild and retrain. It also notes that the Dockerfile starts from python:3.8, which caps how new a scikit-learn that image can install at all.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Installing this project fails with: The 'sklearn' PyPI package is deprecated, use 'scikit-learn' rather than 'sklearn' for pip commands. Fix it. Find every place a dependency named sklearn is declared: requirements files, setup.py, setup.cfg, pyproject.toml, Pipfile, conda environment files, Dockerfiles, CI workflows and notebooks that run pip. Replace each with scikit-learn. Do not change any import statement: the import name stays sklearn, and you should say so. Do not set SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL. If sklearn arrives only through a third-party package, name that package and stop. In a clean virtualenv, reproduce the error, apply the fix, and install again following the same steps the Dockerfile or CI uses. Report which scikit-learn version now resolves and whether anything pins it. Import every module that uses sklearn and run the tests; if tests need cloud credentials, do not fake them, and exercise the model code on a small synthetic dataset instead. Find where trained models are saved and loaded (pickle, joblib, a bucket, a registry) and explain what a scikit-learn version change means for artifacts that already exist. Do not access any bucket. Recommend a pin only with the reason for the specific version, and leave the decision in the pull request description. Do not start Docker. Open a pull request with the error before and the install and test output after.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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 two-line diff, one in requirements.txt and one in setup.py. The description quotes the install error, shows the two install steps from the Dockerfile run again in a virtualenv, names the scikit-learn version that resolved, and lists the imports it deliberately left unchanged.
Most of the description is about what the two lines set in motion. It points to save_output_pkl and to the load call in inference/app.py, states that the model in the bucket was not loaded during the run, and lays out the two safe paths. If you know the version the model was trained with, reply to the session with it and the agent adds the pin to both manifests in the same pull request.
It also states plainly what the smoke test does and does not show. A random forest trained on two hundred synthetic rows proves the wrapper's code runs on the new library. It is not evidence about your model's metrics, and the pipeline's own tests in utils/tests.py write to S3, so they are not run.
Run it on every failed image build
The error shows up in CI, so let CI report it. Add an automation with a webhook trigger and this prompt to the repository's Project, and a step in your build workflow that runs when the install step fails and posts the tail of the log to the trigger's URL with Authorization: Bearer and the trigger's secret. A CI job can set that header itself, so no relay is needed. Send the trigger an Idempotency-Key header made from the commit SHA so a rerun of the same failed job does not start a second run.
The log text arrives after the saved prompt as event data. Keep the prompt narrow, as above, so a build that failed for an unrelated reason ends with a short report and no pull request.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
Everyone who meets this error finds the rename within a minute. What gets skipped is the question behind it: the environment is about to be rebuilt with a much newer library than the one the project last ran on, and in a machine learning project that touches saved models. The agent rebuilds from nothing in its sandbox, following the Dockerfile's own install steps, so it sees the version that will actually resolve and can run the model code on it before your image does.
The run's record is the other reason. The install output, the resolved version and the smoke test are all in the transcript, and so is the statement that the bucket was not read. A reviewer can tell at a glance which claims were checked and which are warnings to act on.
Frequently asked questions
Do I need to change "import sklearn" in my code?
No. Only the name you give pip changes. The package is installed as scikit-learn and imported as sklearn, and that has always been the case. The agent changes manifests and leaves every import statement as it is.
Can I set SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True instead?
The error message offers it as a last resort, for cases where a dependency you do not control asks for sklearn. In your own manifests the rename is a one-word fix and removes the problem for everyone who installs the project. The agent is told not to use the variable.
Will my saved model still load after the fix?
That depends on which scikit-learn version the rebuilt environment gets, not on the rename itself. Pickled estimators are tied to the version that wrote them. If the manifest was unpinned, pin scikit-learn to the version the model was trained with, or retrain after rebuilding. The agent explains this in the pull request and does not pick a version without a reason.
A package I depend on requires sklearn. Can the agent fix that?
Not in your repository. It identifies which package declares the dependency, reports it, and stops, since the fix belongs upstream. In the meantime the environment variable from the error message is the documented workaround, and the agent says where to set it.
More jobs like this: Fix a bug from an alert
- Fix "Source option 5 is no longer supported. Use 7 or later." in Maven (Maven)
- Fix "OSError: [E941] Can't find model 'en'" in spacy.load (spaCy)
- Fix "AttributeError: module 'ssl' has no attribute 'wrap_socket'" on Python 3.12 (ssl)
- Fix "AttributeError: module 'streamlit' has no attribute 'beta_columns'" and the beta_expander Rename (Streamlit)
- Fix "AttributeError: module 'streamlit' has no attribute 'experimental_rerun'" (Streamlit)
- Fix "strings.Title Has Been Deprecated" (SA1019) in a Go CLI (Go strings)