# Add Dependabot to a Tokio Project

Yes. An agent reads a Tokio project's Cargo.toml and lockfile, writes a grouped .github/dependabot.yml for cargo and Actions, records a baseline and opens a PR.

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

## What the agent does

Cargo gives Dependabot two things to move, the ranges in `Cargo.toml` and the exact versions in `Cargo.lock`, so the agent reads both to say what the first week will bring. In a project laid out like tokio-rs/mini-redis, `Cargo.toml` is a single package on edition 2018 with two binaries, `mini-redis-cli` and `mini-redis-server`, and depends on `tokio` `1` with `full`, `tokio-stream` `0.1`, `bytes` `1`, `clap` `4.2.7` with `derive`, `async-stream` `0.3.0`, `atoi` `2.0.0`, `tracing` `0.1.34` and `tracing-subscriber` `0.3.11` with `env-filter`. Behind an `otel` feature it has four optional crates that must agree with one another: `opentelemetry` `0.20.0`, `tracing-opentelemetry` `0.21.0`, `opentelemetry-aws` `0.8.0` and `opentelemetry-otlp` `0.13.0`. `Cargo.lock` is committed and resolves `tokio` to `1.32.0`, `clap` to `4.4.2`, `tracing-subscriber` to `0.3.17` and `bytes` to `1.5.0`. There is no `.github/dependabot.yml`, and `.github/workflows/ci.yml` is the one workflow: on push and pull request to `master` it runs `cargo build`, `cargo build --features otel`, `cargo test`, `cargo test --features otel` and `cargo fmt --all --check` on Ubuntu, macOS and Windows, checking out with `actions/checkout@v4`.

Checking the ranges against crates.io sorts the dependencies into two kinds. `tokio` at `1.54.1`, `clap` at `4.6.7`, `bytes` at `1.12.1`, `tracing` at `0.1.44`, `tracing-subscriber` at `0.3.23`, `tokio-stream` at `0.1.19` and `async-stream` at `0.3.6` are inside their ranges, so each arrives as a lockfile-only pull request that edits `Cargo.lock` and leaves the manifest alone. `atoi` at `3.1.1` is a major past `2.0.0`, so it rewrites the manifest. The four OpenTelemetry crates are the ones to handle with care: `opentelemetry` is at `0.33.1`, `tracing-opentelemetry` at `0.34.0`, `opentelemetry-otlp` at `0.33.1` and `opentelemetry-aws` at `0.21.0`, every one outside its `0.x` range, and `src/bin/server.rs` uses `opentelemetry::sdk::trace`, `opentelemetry_otlp::new_pipeline` and `XrayPropagator` from the versions pinned today. Raising one of those crates without the others does not build.

So the file the agent writes has two entries in `.github/dependabot.yml` under `version: 2`. The `cargo` entry on `directory: "/"` runs weekly with `groups`: an `opentelemetry` group matching `opentelemetry*` and `tracing-opentelemetry` so the four move in one pull request that CI checks with `--features otel`, a `tokio` group for `tokio` and `tokio-stream`, a `tracing` group for `tracing` and `tracing-subscriber`, and a `minor-and-patch` group with `update-types` limited to minor and patch for the rest, so `atoi` arrives alone as the one major. `open-pull-requests-limit` and a `commit-message` prefix are set. The `github-actions` entry on the same schedule raises `actions/checkout`, whose current major is past the `v4` in `ci.yml`, in its own pull request. A comment above the OpenTelemetry group says that its pull request will need hand edits in `src/bin/server.rs` where the SDK types moved between crates, and that `cargo build --features otel` in CI is what tells the reviewer.

Then the agent records the baseline. It installs a Rust toolchain in its sandbox if none is present, runs `cargo build`, `cargo test` and `cargo test --features otel`, the commands `ci.yml` runs, so the pull request can show the `tests/server.rs` cases such as `key_value_get_set`, `pub_sub` and `send_error_unknown_command` passing before anything moves. It runs `cargo update --dry-run`, which lists each locked crate that would move within its range, and `cargo tree --depth 1` for the direct graph, and pastes both so the first lockfile pull requests have something to compare against. It validates the YAML against the Dependabot v2 schema from SchemaStore, since a misspelled key such as `update-type` is ignored by GitHub rather than refused. `Cargo.toml` and `Cargo.lock` are not changed.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add Dependabot to this Tokio project. Read Cargo.toml, Cargo.lock, .github/workflows/ci.yml, src/bin/server.rs and tests/server.rs first. Check each dependency's range against crates.io and say in the pull request which crates will arrive as lockfile-only updates, which will rewrite Cargo.toml, and that the four OpenTelemetry crates must move together because src/bin/server.rs uses their SDK types. Write .github/dependabot.yml with a weekly cargo entry grouped into opentelemetry (opentelemetry* and tracing-opentelemetry), tokio (tokio and tokio-stream), tracing (tracing and tracing-subscriber) and a minor-and-patch group for everything else, plus a weekly github-actions entry, with open-pull-requests-limit and commit-message prefixes set and a comment on the OpenTelemetry group. Validate the file against the Dependabot v2 JSON schema, run cargo build, cargo test and cargo test --features otel, run cargo update --dry-run and cargo tree --depth 1, and open a pull request that pastes those outputs. Do not change Cargo.toml or Cargo.lock.",
  "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

The pull request adds one file, `.github/dependabot.yml`. Its description sorts the dependencies into lockfile-only updates and manifest updates with the current version of each from crates.io, explains the OpenTelemetry group and the hand edits its first pull request will need, and pastes the schema validation line, the `cargo test` summaries with and without `otel`, the `cargo update --dry-run` list and the direct dependency tree.

GitHub reads the file once it lands on `master`. The first Dependabot pull requests then run the existing `CI` workflow across its three operating systems, so a lockfile bump arrives with `cargo test` already green or red on each, and the OpenTelemetry pull request shows its build failure under `--features otel` before anyone reads the diff. The run's record keeps the sandbox output for comparison.

Before merging, a reviewer picks the schedule day and timezone, decides whether to hold the OpenTelemetry group with an `ignore` rule until someone has time for the SDK migration, and whether `atoi` should move to its new major now or wait. The agent touches no Rust source and no workflow.

## Run it on every Cargo repository without Dependabot

An organisation with many Rust services starts one run per repository from its own server: one `POST /o/{org}/sessions` each, with the repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run already started. Each run reads its own manifest, so a workspace gets one `cargo` entry per member directory or a root entry with `directories`, a crate without a committed lockfile gets manifest-only updates explained in its pull request, and one with `deny.toml` gets `cargo deny check` added to the baseline.

A team that wants the file kept complete runs this prompt monthly from an automation with a `schedule` trigger in the Project that holds the repository. When a new workspace member, a second workflow or a `Dockerfile` has appeared since the last run, that run opens a pull request adding the missing entry or group; otherwise it ends without a pull request and says what it checked.

## Why run it on Rush?

The file is short and the cost of a wrong one is slow rather than loud: a flat configuration sends four OpenTelemetry pull requests that each fail to build for a reason the next one would fix, a misspelled key is silently ignored, and without a baseline nobody knows whether a lockfile bump broke `pub_sub` or it was already flaky. The agent reads the lock, checks the registry, validates the file and runs the suite with and without the feature, so the first Dependabot pull requests land against a known state.

Every command stays with the run, from the toolchain install to `cargo update --dry-run`, and the pull request quotes them. Writing the same file for a fleet of Rust services at once costs no more attention than one, because each run has its own sandbox, its own target directory and its own pull request.

## Frequently asked questions

### Why group the OpenTelemetry crates?

Because `opentelemetry`, `tracing-opentelemetry`, `opentelemetry-otlp` and `opentelemetry-aws` are released in step and `src/bin/server.rs` combines types from all four. A pull request that raises one of them does not compile; one that raises all four fails for a reason a person can fix, which is the SDK types moving between crates, and the comment on the group says so.

### Will Dependabot change Cargo.toml for tokio?

No. `tokio = "1"` already allows every 1.x release, so Dependabot only edits `Cargo.lock`, from `1.32.0` to the current release. The manifest changes only for a crate whose range excludes the new version, which today is `atoi` and the four OpenTelemetry crates.

### What does the github-actions entry do here?

It opens a pull request raising `actions/checkout@v4` to its current major, the only action `ci.yml` uses. If the team later adds a toolchain action or a cache step, the same entry covers those.

### Can the agent run Dependabot itself to prove the file?

No. Dependabot runs on GitHub after the file is merged. What the agent proves is that the file is valid against the published schema, which crates will move and how, and that the suite passes on the current lock with and without the `otel` feature. The first Dependabot pull requests are the real test, and the baseline output is there to compare them against.

## More Tokio jobs

- [Write a Dockerfile for a Tokio Server](https://getrush.ai/run/add-dockerfile/tokio/)
- [Add Fuzz Tests to a Tokio Protocol Parser](https://getrush.ai/run/add-fuzz-tests/tokio/)
- [Add Graceful Shutdown on SIGTERM to a Tokio Server](https://getrush.ai/run/add-graceful-shutdown/tokio/)

## The same job on other stacks

- [Add Dependabot to a Vite React Monorepo](https://getrush.ai/run/add-dependabot/vite-react/)
- [Add Dependabot to a VitePress Site](https://getrush.ai/run/add-dependabot/vitepress/)
- [Add Dependabot to a VS Code Extension](https://getrush.ai/run/add-dependabot/vscode-extension/)

## 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/)
