From 361f003f2915d67339cc83872b2e6a5b36d3cc2e Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Wed, 29 Apr 2026 10:02:43 -0700 Subject: [PATCH] doc: discourage the use of #[async_trait] --- AGENTS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 23f0bab387c7..6939d146b00e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,6 +19,12 @@ In the codex-rs folder where the rust code lives: - You can run `just argument-comment-lint` to run the lint check locally. This is powered by Bazel, so running it the first time can be slow if Bazel is not warmed up, though incremental invocations should take <15s. Most of the time, it is best to update the PR and let CI take responsibility for checking this (or run it asynchronously in the background after submitting the PR). Note CI checks all three platforms, which the local run does not. - When possible, make `match` statements exhaustive and avoid wildcard arms. - Newly added traits should include doc comments that explain their role and how implementations are expected to use them. +- Discourage both `#[async_trait]` and `#[allow(async_fn_in_trait)]` in Rust traits. + - Prefer native RPITIT trait methods with explicit `Send` bounds on the returned future, as in `3c7f013f9735` / `#16630`. + - Preferred trait shape: + `fn foo(&self, ...) -> impl std::future::Future + Send;` + - Implementations may still use `async fn foo(&self, ...) -> T` when they satisfy that contract. + - Do not use `#[allow(async_fn_in_trait)]` as a shortcut around spelling the future contract explicitly. - When writing tests, prefer comparing the equality of entire objects over fields one by one. - When making a change that adds or changes an API, ensure that the documentation in the `docs/` folder is up to date if applicable. - Prefer private modules and explicitly exported public crate API.