From 797f0ff5941982907850d02ad4c76749fef62fa2 Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Mon, 26 Jan 2026 16:54:18 -0800 Subject: [PATCH 1/4] Reject request_user_input outside Plan/Pair --- .../core/src/tools/handlers/request_user_input.rs | 14 ++++++++------ codex-rs/core/tests/suite/request_user_input.rs | 13 +++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/codex-rs/core/src/tools/handlers/request_user_input.rs b/codex-rs/core/src/tools/handlers/request_user_input.rs index d2c55b08df7a..112dcae21ea5 100644 --- a/codex-rs/core/src/tools/handlers/request_user_input.rs +++ b/codex-rs/core/src/tools/handlers/request_user_input.rs @@ -36,12 +36,14 @@ impl ToolHandler for RequestUserInputHandler { } }; - let disallowed_mode = match session.collaboration_mode().await.mode { - ModeKind::Execute => Some("Execute"), - ModeKind::Custom => Some("Custom"), - _ => None, - }; - if let Some(mode_name) = disallowed_mode { + let mode = session.collaboration_mode().await.mode; + if !matches!(mode, ModeKind::Plan | ModeKind::PairProgramming) { + let mode_name = match mode { + ModeKind::Code => "Code", + ModeKind::Execute => "Execute", + ModeKind::Custom => "Custom", + ModeKind::Plan | ModeKind::PairProgramming => unreachable!(), + }; return Err(FunctionCallError::RespondToModel(format!( "request_user_input is unavailable in {mode_name} mode" ))); diff --git a/codex-rs/core/tests/suite/request_user_input.rs b/codex-rs/core/tests/suite/request_user_input.rs index 2d81fc9ad820..387296961051 100644 --- a/codex-rs/core/tests/suite/request_user_input.rs +++ b/codex-rs/core/tests/suite/request_user_input.rs @@ -286,6 +286,19 @@ async fn request_user_input_rejected_in_execute_mode() -> anyhow::Result<()> { .await } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn request_user_input_rejected_in_code_mode() -> anyhow::Result<()> { + assert_request_user_input_rejected("Code", |model| CollaborationMode { + mode: ModeKind::Code, + settings: Settings { + model, + reasoning_effort: None, + developer_instructions: None, + }, + }) + .await +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn request_user_input_rejected_in_custom_mode() -> anyhow::Result<()> { assert_request_user_input_rejected("Custom", |model| CollaborationMode { From 12180437ae644f2b8f21f79be99e55e608ccf0a2 Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Mon, 26 Jan 2026 16:59:09 -0800 Subject: [PATCH 2/4] Add AGENTS.md note --- AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AGENTS.md b/AGENTS.md index a0dcb9872879..5dca2723f291 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,6 +11,7 @@ In the codex-rs folder where the rust code lives: - Always collapse if statements per https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if - Always inline format! args when possible per https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args - Use method references over closures when possible per https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls +- When possible, make `match` statements exhaustive and avoid wildcard arms so new enum variants fail loudly. - 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. - If you change `ConfigToml` or nested config types, run `just write-config-schema` to update `codex-rs/core/config.schema.json`. From 822ac88133796a10a5d48632ffd8a058b4622e4d Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Mon, 26 Jan 2026 17:00:42 -0800 Subject: [PATCH 3/4] Tweak --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 5dca2723f291..dc05575c480f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ In the codex-rs folder where the rust code lives: - Always collapse if statements per https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if - Always inline format! args when possible per https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args - Use method references over closures when possible per https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls -- When possible, make `match` statements exhaustive and avoid wildcard arms so new enum variants fail loudly. +- When possible, make `match` statements exhaustive and avoid wildcard arms so new enum variants are handled 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. - If you change `ConfigToml` or nested config types, run `just write-config-schema` to update `codex-rs/core/config.schema.json`. From 367561c4609abc0659bcbb6eed123dd240000d3c Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Mon, 26 Jan 2026 17:01:10 -0800 Subject: [PATCH 4/4] Tweak --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index dc05575c480f..4b6f8992e4e4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ In the codex-rs folder where the rust code lives: - Always collapse if statements per https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if - Always inline format! args when possible per https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args - Use method references over closures when possible per https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls -- When possible, make `match` statements exhaustive and avoid wildcard arms so new enum variants are handled explicitly. +- When possible, make `match` statements exhaustive and avoid wildcard arms. - 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. - If you change `ConfigToml` or nested config types, run `just write-config-schema` to update `codex-rs/core/config.schema.json`.