# Upgrade Python Dependencies Weekly for a LangGraph Agent

Yes. Each week the agent upgrades LangGraph, LangChain and the provider packages together, executes the graph with a fake model, and opens a PR with what it held.

[Run this on Rush](https://cloud.getrush.ai/run/upgrade-python-dependencies/langgraph/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

An agent project depends on a family of packages that release often and have to agree with each other, and the agent begins by reading how this one keeps them in step. In a LangGraph project like langchain-ai/react-agent, `pyproject.toml` declares floors and no ceilings: `langgraph>=1.2.11`, `langchain>=1.3.17`, the three provider packages `langchain-openai`, `langchain-anthropic` and `langchain-fireworks`, and `langchain-tavily`, on Python `>=3.11,<4.0`. `uv.lock` records what that resolved to, including `langchain-core`, which `pyproject.toml` does not list but every one of those packages constrains. `.github/dependabot.yml` updates the `uv` ecosystem weekly with `versioning-strategy: increase`, so each bump raises a floor as well as the lock.

Next it looks at what a bump is tested against today, and the answer is: not much. `.github/workflows/unit-tests.yml` installs with `uv pip install -r pyproject.toml`, which resolves from the floors and does not read `uv.lock`, then runs `ruff check .`, `mypy --strict src/`, a spelling check and `pytest tests/unit_tests`, which is three tests of a settings dataclass. Nothing on a pull request executes the graph. The one test that does, in `tests/integration_tests`, calls a real model and a real search API and runs from a separate workflow on a daily cron. A LangGraph release that changes something this code imports, `Runtime` and `get_runtime` from `langgraph.runtime`, `IsLastStep` from `langgraph.managed`, `ToolNode` from `langgraph.prebuilt` or `init_chat_model` from `langchain.chat_models`, can therefore merge green and fail the next day.

The agent's run closes that gap without a key. It runs `uv lock --upgrade` and `uv sync`, then the workflow's own checks on Python 3.11 and 3.12. Strict mypy matters more than usual here: `graph.py` carries a `# type: ignore[redundant-cast]` on the model call, and strict mode reports an ignore that a new release has made unnecessary, so a typing change upstream shows up as a failure to fix, not as silence. Then it executes the graph. Importing `react_agent.graph` compiles it, which already catches a renamed class or argument. A short script replaces `load_chat_model` with a scripted fake model and `TavilySearch` with a stub, awaits `graph.ainvoke` through one tool call and one answer, and checks the message sequence. Last, with `.env` copied from `.env.example`, it starts the local server with `langgraph dev --no-browser` from the `langgraph-cli[inmem]` dev dependency and confirms it loads the `agent` graph that `langgraph.json` points at.

When a check fails, the agent finds the package responsible by upgrading in two steps, the `langgraph` packages first and the `langchain` family second, and then one package at a time within the step that broke. A break with a documented replacement is fixed in `src/`, in the same pull request, with the changelog entry quoted. A break without one is held: the package stays at its locked version and the table says why. If one provider package has not yet released for the newest `langchain-core`, the resolver keeps core back for all of them, and the agent reports which package is holding it, from `uv tree --invert --package langchain-core`. Floors in `pyproject.toml` are raised to the versions tested, matching the repository's Dependabot strategy.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Upgrade the Python dependencies of this LangGraph agent. Read pyproject.toml, uv.lock, .github/dependabot.yml, both workflows under .github/workflows, the Makefile, langgraph.json and every file under src/ first, and list each import the code takes from langgraph, langchain, langchain_core and the provider packages. Run uv lock --upgrade and uv sync. On Python 3.11 and 3.12 run ruff check ., mypy --strict src/ and pytest tests/unit_tests. Then execute the graph without API keys: import react_agent.graph, and run a script that patches load_chat_model in the graph module with a scripted fake chat model and TavilySearch in the tools module with a stub, awaits graph.ainvoke through one tool call and a final answer, and asserts the message sequence. Copy .env.example to .env, start langgraph dev --no-browser and confirm it loads the graph named in langgraph.json, then stop it. If anything fails, upgrade the langgraph packages and the langchain packages separately, then one package at a time, to find the cause. Fix a break in src/ only when the release notes document the replacement, and quote them; otherwise hold that package at its locked version. If langchain-core is kept back, name the package that constrains it. Raise the floors in pyproject.toml to the versions you tested. Do not run tests/integration_tests, do not change the default model, and do not commit the script or .env. Open one pull request with a table of every package: before, after or held, and why, and the output of each check.",
  "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

One pull request that changes `uv.lock`, the floors in `pyproject.toml` and, when a release required it, a few lines in `src/`. The description has a table with a row per package, direct and transitive where it matters: version before, version after or `held`, and the reason. Source changes are listed separately, each beside the changelog line that called for it.

Below the table is the output of the checks on both Python versions and the result of the keyless graph execution: the message sequence the scripted run produced and the line from the local server showing the graph loaded. The description states that the integration test was not run, because it needs provider keys the sandbox does not have. A maintainer can run that workflow on the branch through its `workflow_dispatch` trigger before merging.

A reviewer reads the held rows and any change in `src/` first. A scripted model proves the graph still wires together on the new versions; it does not prove a real provider still accepts the tool schema the new `langchain` package sends, which is what the integration run is for.

## Run it on every Monday morning

An automation in the Project that holds the repository takes this prompt and a `schedule` trigger with `cron` set to `0 8 * * 1` in the team's `timezone`. Each week it starts one run and that run opens one pull request. Where Dependabot is already configured, as it is here, the two fit together: Dependabot keeps opening its grouped bump, and this run is the one whose pull request has executed the graph, so it is the one to merge when they differ.

A team with many agent repositories starts the runs from its own scheduler: one `POST /o/{org}/sessions` per repository with this body and a `request_id` that is a UUID v5 of the repository and the week's date, so a job that fires twice starts nothing new. Runs past the key's concurrency limit are created `queued` and start as earlier ones finish.

## Why run it on Rush?

The useful part of this job is the part a bot's pull request skips: installing the new versions and running the graph on them. That takes two Python versions, a fresh resolution, a local server and, when something breaks, a bisection across a family of related packages. In a Rush sandbox the agent works through that unattended, and the commands with their output stay in the run's transcript at `GET /o/{org}/sessions/{id}/messages`.

It needs nothing secret to do it. The scripted model and the stubbed search mean no provider key is read, and `.env` in the sandbox is a copy of the example file with placeholder values. What the team gets on Monday is a pull request that says which packages moved, which were held and why, with proof that the graph still compiles, runs a tool call and loads in the server.

## Frequently asked questions

### Dependabot already opens these pull requests. What is different?

What they were tested with. In this repository a pull request's CI lints, type-checks and runs three tests of the settings class, and the graph is first executed by the next day's scheduled run. The agent executes the graph on the upgraded versions before the pull request exists, and fixes or holds what breaks.

### Why are LangGraph and LangChain upgraded in separate steps?

Only when a check fails. The first attempt upgrades everything together, which is the state the team wants. If that fails, splitting the upgrade by family and then by package ties the failure to one release, so the pull request can name it and hold just that package.

### Does it run the integration test with a real model?

No. That test needs `ANTHROPIC_API_KEY` and `TAVILY_API_KEY`, and the run has neither. Rush refuses a Project secret named `ANTHROPIC_*` with `422 SECRET_NAME_INVALID`, so the key cannot be supplied that way. The repository's integration workflow can be started by hand on the pull request's branch.

### Will it update the model name the agent defaults to?

No. The default in `src/react_agent/context.py` is a product decision, and changing it changes behaviour and cost. If an upgraded provider package stops accepting that model id, the pull request reports it as a finding and leaves the string alone.

## More LangGraph jobs

- [Write pytest Tests for a LangGraph Agent](https://getrush.ai/run/write-pytest-tests/langgraph/)
- [Add Conversation Memory to a LangGraph Agent](https://getrush.ai/run/add-conversation-memory/langgraph/)
- [Add Human-in-the-Loop Approval to a LangGraph Agent](https://getrush.ai/run/add-human-in-the-loop/langgraph/)

## The same job on other stacks

- [Upgrade Python Dependencies Weekly for a Litestar App](https://getrush.ai/run/upgrade-python-dependencies/litestar/)
- [Upgrade Python Dependencies in a Streamlit App](https://getrush.ai/run/upgrade-python-dependencies/streamlit/)
- [Upgrade Python Dependencies Weekly for a Dagster Project](https://getrush.ai/run/upgrade-python-dependencies/dagster/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
