What the agent does
The agent reads how the crate is built and what CI already checks. In a Tokio application laid out like tokio-rs/mini-redis, Cargo.toml declares a library plus two binaries, mini-redis-server and mini-redis-cli, on edition 2018, with tokio at 1 with the full feature set, clap 4 with derive, bytes, tracing and tracing-subscriber with env-filter, and four optional crates (opentelemetry 0.20, tracing-opentelemetry 0.21, opentelemetry-aws 0.8 and opentelemetry-otlp 0.13) behind an otel feature. Cargo.lock is committed and resolves those ranges to fixed versions such as tokio 1.32.0 and clap 4.4.2. .github/workflows/ci.yml runs one build job across ubuntu-latest, macos-latest and windows-latest: cargo build, the same build with --features otel, cargo test twice the same way, and cargo fmt --all --check. Nothing looks at the RustSec advisory database, and there is no Dependabot configuration to raise a flag when a dependency is yanked or advised against.
The agent installs the tool with cargo install cargo-audit --locked and runs cargo audit from the crate root. The command reads Cargo.lock, not the feature set, so every crate pinned there is checked, including the OpenTelemetry tree that only the otel feature compiles. The report lists each advisory with its RustSec id, the affected crate and version, the versions that fix it, and the dependency path that pulls it in; warnings cover unmaintained and yanked crates. The agent sorts the findings into three piles: advisories a cargo update -p <crate> resolves within the ranges Cargo.toml already allows, advisories that need a range change in Cargo.toml and therefore a review decision, and warnings with no fix available.
For the first pile it runs the targeted update, then cargo build, cargo test, and the same two commands with --features otel, because a bumped crate inside the OpenTelemetry tree only compiles under that feature and the matrix job would otherwise catch it after the merge. For the second and third piles it writes .cargo/audit.toml with an [advisories] table whose ignore list carries each advisory id and a comment naming the crate, why it cannot move yet, and the path that pulls it in, so the entry reads as a decision rather than silence. A range change to Cargo.toml is proposed in the pull request description with the version jump it would need, not made, unless the fix is a patch or minor release inside the current range.
The CI change is a second job in ci.yml, named audit, running on ubuntu-latest only, since the lockfile is the same on every platform and one check is enough. It checks out the repository, installs cargo-audit from a pinned release through cargo install --locked, and runs cargo audit, which exits non-zero on any advisory not listed in audit.toml. The workflow also gains a weekly schedule trigger alongside push and pull_request, because an advisory can be published against a lockfile that has not changed in months. The agent runs actionlint over the edited workflow and cargo audit once more to confirm a clean exit before opening the pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add cargo-audit to CI for this Tokio application. Read Cargo.toml, Cargo.lock and .github/workflows/ci.yml first. Install cargo-audit with cargo install --locked and run cargo audit from the crate root. For each advisory that a cargo update -p <crate> resolves within the ranges Cargo.toml already allows, apply it and rerun cargo build and cargo test, both with and without --features otel. For advisories that need a Cargo.toml range change, or warnings with no fix, write .cargo/audit.toml with an ignore entry per advisory and a comment naming the crate, the reason and the dependency path; propose the range change in the pull request description instead of making it. Add a separate audit job to ci.yml on ubuntu-latest that installs a pinned cargo-audit release and runs cargo audit, and add a weekly schedule trigger. Run actionlint and cargo audit until both exit clean, then open a pull request that lists every advisory found, what was updated, and every ignore entry with its reason.",
"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
The pull request adds the audit job and the schedule trigger to .github/workflows/ci.yml, adds .cargo/audit.toml when any advisory had to be recorded, and changes Cargo.lock where a targeted update was possible. Its description lists each advisory the first run reported with its id, crate and dependency path, which ones the lockfile change resolves, the build and test summaries with and without the otel feature, and each ignore entry with the reason beside it.
Where an advisory can only be fixed by a new major version of a crate named in Cargo.toml, the description shows the current range, the fixed version, and what else in the lock tree moves with it, so the maintainers can take that step in a change of their own rather than inside an audit pull request.
Before merging, a reviewer reads the ignore list for any entry that deserves a fix instead, checks that the updated lockfile still builds on the three platforms in the existing matrix once the checks run, and decides whether the scheduled run should also open an issue when it fails, which the pinned action can do with a small addition.
Run it on every week
A team with several Rust services sends this body once per repository from its own server, each a POST /o/{org}/sessions with that 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 rather than a second one. Each run reads its own Cargo.toml and workflow: a crate that already carries a deny.toml gets its advisories checked through cargo deny check advisories instead, and one whose CI runs on a self-hosted runner keeps that runner label.
Once the job is in place, an automation on the Project with a schedule trigger set to a weekly cron and the prompt "run cargo audit; for each new advisory, apply the targeted cargo update if the ranges allow it, rerun the tests with and without the otel feature, and open a pull request; otherwise add an ignore entry with the reason" starts one run a week. Its runs push a branch and open a pull request only when the lockfile or the ignore list changed; a week with no new advisory produces no pull request.
The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.
Why run it on Rush?
The first audit of a lockfile that has aged for a while is the slow part: each advisory needs a look at the dependency path, a check of whether the crate's range allows the fix, and a test run under every feature that compiles the affected tree. The agent does each of those in the open, with the command output kept, and writes the decision into audit.toml or the pull request description so the next person does not repeat the investigation.
The sandbox has a full Rust toolchain, so cargo install, the builds and the tests run for real rather than being described. A team with many crates runs the same request across all of them at once, each in its own sandbox, and gets one pull request per repository with its own advisory list and its own test results.
Frequently asked questions
Does cargo audit need the otel feature enabled to check those crates?
No. cargo audit reads Cargo.lock, which lists every crate the resolver pinned, optional ones included, so the OpenTelemetry crates are checked whether or not the feature is on. The feature matters only when the agent rebuilds and retests after an update, which is why it runs the build and tests both ways.
Will it change the version ranges in Cargo.toml?
Only for a patch or minor release that already fits the existing range, which cargo update -p applies to the lockfile without touching Cargo.toml at all. A fix that needs a new major version is written up in the pull request description with the jump it requires and left for a change of its own.
What happens to an advisory with no fixed version?
It goes into .cargo/audit.toml under [advisories] ignore, with a comment naming the crate, the dependency path and the reason, so CI passes and the decision is recorded next to the id. When a fixed version appears later, removing the line makes the job fail again until the lockfile moves.
Why a separate job instead of a step in the existing matrix job?
The matrix job runs three times, once per operating system, and the lockfile is identical on all three, so one audit on Linux is enough. A job of its own also needs no Rust build before it reports, and an advisory failure does not hide behind a compile error on Windows or the other way round.
More Tokio jobs
The same job on other stacks
- Add cargo-audit to CI for a Rust CLI (Rust CLI)
More jobs like this: Upgrade dependencies weekly
- Add cargo-deny to a Rust Workspace (Rust)
- Add cargo-deny to a Rust Library Workspace (Rust library)