mirror of
https://github.com/openai/codex.git
synced 2026-02-01 14:44:17 +00:00
Reject request_user_input outside Plan/Pair (#9955)
## Context Previous work in https://github.com/openai/codex/pull/9560 only rejected `request_user_input` in Execute and Custom modes. Since then, additional modes (e.g., Code) were added, so the guard should be mode-agnostic. ## What changed - Switch the handler to an allowlist: only Plan and PairProgramming are allowed - Return the same error for any other mode (including Code) - Add a Code-mode rejection test alongside the existing Execute/Custom tests ## Why This prevents `request_user_input` from being used in modes where it is not intended, even as new modes are introduced.
This commit is contained in:
committed by
GitHub
parent
73bd84dee0
commit
47aa1f3b6a
@@ -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 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
|
- 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
|
- 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.
|
||||||
- When writing tests, prefer comparing the equality of entire objects over fields one by one.
|
- 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.
|
- 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`.
|
- If you change `ConfigToml` or nested config types, run `just write-config-schema` to update `codex-rs/core/config.schema.json`.
|
||||||
|
|||||||
@@ -36,12 +36,14 @@ impl ToolHandler for RequestUserInputHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let disallowed_mode = match session.collaboration_mode().await.mode {
|
let mode = session.collaboration_mode().await.mode;
|
||||||
ModeKind::Execute => Some("Execute"),
|
if !matches!(mode, ModeKind::Plan | ModeKind::PairProgramming) {
|
||||||
ModeKind::Custom => Some("Custom"),
|
let mode_name = match mode {
|
||||||
_ => None,
|
ModeKind::Code => "Code",
|
||||||
};
|
ModeKind::Execute => "Execute",
|
||||||
if let Some(mode_name) = disallowed_mode {
|
ModeKind::Custom => "Custom",
|
||||||
|
ModeKind::Plan | ModeKind::PairProgramming => unreachable!(),
|
||||||
|
};
|
||||||
return Err(FunctionCallError::RespondToModel(format!(
|
return Err(FunctionCallError::RespondToModel(format!(
|
||||||
"request_user_input is unavailable in {mode_name} mode"
|
"request_user_input is unavailable in {mode_name} mode"
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -286,6 +286,19 @@ async fn request_user_input_rejected_in_execute_mode() -> anyhow::Result<()> {
|
|||||||
.await
|
.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)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn request_user_input_rejected_in_custom_mode() -> anyhow::Result<()> {
|
async fn request_user_input_rejected_in_custom_mode() -> anyhow::Result<()> {
|
||||||
assert_request_user_input_rejected("Custom", |model| CollaborationMode {
|
assert_request_user_input_rejected("Custom", |model| CollaborationMode {
|
||||||
|
|||||||
Reference in New Issue
Block a user