> Index of all Nori docs pages for agents: https://docs.noriagentic.com/llms.txt · Ask a question: https://noriagentic.com/ask

# How to have an agent upgrade dependencies every night and open PRs

Create an **On a schedule** automation that runs every night, give it the list of repositories, and tell the agent to upgrade within your version policy, run the tests, and open one pull request per repository. Each night Nori starts the agent on a fresh cloud machine with your repositories already cloned, and the run’s summary lands in Slack or in the automation’s history.

## Prerequisites

- The [GitHub App](https://docs.noriagentic.com/sessions/guides/github/) installed with access to every repository in scope, and the repositories added under **Settings → Environment** so each machine starts with them.
- A setup script (**Settings → Environment → Setup script & tools**) that installs the toolchains your tests need, for example Node and Python.
- A connected agent under **Integrations → Token providers**.
- Optional: the [Nori Slack app](https://docs.noriagentic.com/sessions/guides/slack/) and a channel such as `#deps`, with its channel ID, for a nightly summary thread.
- Branch protection and CI on each repository, so upgrade pull requests are checked and reviewed before merging.

## Steps

1. Open **Automations** → **New automation** and name it `Nightly dependency upgrades`.
2. Under **Starts when**, choose **On a schedule**, then **Daily** under **Schedule**. Set **Time** to a quiet hour such as 02:00 and **Timezone** to your IANA zone.
3. Write the **Instructions** (see the example): the repositories, the version policy, the test command, and what to do when tests fail.
4. Under **Deliver to**, choose **Slack thread** for a nightly summary your team can reply to, or **Standalone session** to keep results in the automation’s history only.
5. Optional: for heavy test suites, run on a larger machine. Add `--size large` when you create it from the CLI, or under **Run with** pick a [custom agent](https://docs.noriagentic.com/sessions/guides/custom-agents/) that has a larger machine size.
6. Save with **Create** or **Submit for approval**.

## Example

```bash
nori-sessions triggers create \
  --name "Nightly dependency upgrades" \
  --type cron \
  --cron-schedule "0 2 * * *" \
  --timezone America/New_York \
  --slack-channel-id C0123456789 \
  --prompt "For each of these repositories: api, web, worker.
1. If an open pull request from a previous night's upgrade exists, update
   that branch instead of opening another.
2. Upgrade dependencies to the newest versions allowed by the current
   version ranges (patch and minor only). Update the lockfile.
3. Run the repository's test suite.
4. If tests pass, open a pull request titled 'chore(deps): nightly upgrade'
   listing each package and version change. Never merge.
5. If tests fail, find which upgrade broke them, leave that package at its
   old version, and say why in the pull request.
Reply with one line per repository: PR link, packages upgraded, tests."
```

Major-version upgrades work the same way; give them their own weekly automation so their pull requests get a separate, slower review.

## Verify it works

1. Choose **Run now** on the automation (CLI: `nori-sessions triggers test --id <id>`) instead of waiting for 02:00.
2. Check GitHub for one upgrade pull request per repository, with CI running.
3. Read the Slack thread, or **Recent activity** → **Last response**, for the per-repository summary.
4. The next morning, check that the scheduled run fired: **Recent activity** shows its time and **Succeeded** or **Failed**. Runs stop at the automation time limit (6 hours by default), and a failing automation posts a notice in its origin channel.

See [automations](https://docs.noriagentic.com/sessions/guides/triggers/) for schedules, retries, and time limits.
