mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Match Windows shell guidance to the executor platform (#41368)
## What changed - Include Windows safety guidance in the `exec_command` tool description when a single ready environment reports Windows as its executor platform. - Omit that guidance when the selected executor reports a non-Windows platform. - Preserve the host-based behavior when platform information is unavailable or the tool can target multiple environments. ## Testing - Cover Windows, non-Windows, unknown-platform, and multi-environment tool plans. - Verify remote environments expose guidance that matches their target OS. GitOrigin-RevId: 95e09790446c684ffaff2a0be077db426fff4618
This commit is contained in:
1 parent
7e41be641e
commit
5ed294d49d
6 files changed
+95
-11
No files matched your search
@@ -14,7 +14,10 @@ pub struct CommandToolOptions {
|
||||
#[cfg(test)]
|
||||
pub fn create_exec_command_tool(options: CommandToolOptions) -> ToolSpec {
|
||||
create_exec_command_tool_with_environment_id(
|
||||
options, /*include_environment_id*/ false, /*include_shell_parameter*/ true,
|
||||
options,
|
||||
/*include_environment_id*/ false,
|
||||
/*include_shell_parameter*/ true,
|
||||
/*include_windows_shell_guidance*/ cfg!(windows),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,6 +25,7 @@ pub(crate) fn create_exec_command_tool_with_environment_id(
|
||||
options: CommandToolOptions,
|
||||
include_environment_id: bool,
|
||||
include_shell_parameter: bool,
|
||||
include_windows_shell_guidance: bool,
|
||||
) -> ToolSpec {
|
||||
let yield_time_ms_description = if cfg!(windows) {
|
||||
"Maximum time to wait before returning a session ID for a still-running command. Commands that finish sooner return immediately. For ordinary commands, omit this parameter to use the 10000 ms default. Effective range on Windows is 10000-30000 ms."
|
||||
@@ -90,7 +94,7 @@ pub(crate) fn create_exec_command_tool_with_environment_id(
|
||||
|
||||
ToolSpec::Function(ResponsesApiTool {
|
||||
name: "exec_command".to_string(),
|
||||
description: if cfg!(windows) {
|
||||
description: if include_windows_shell_guidance {
|
||||
format!(
|
||||
"Runs a command in a PTY, returning output or a session ID for ongoing interaction.\n\n{}",
|
||||
windows_shell_guidance()
|
||||
|
||||
@@ -107,6 +107,7 @@ fn exec_command_tool_can_hide_shell_parameter() {
|
||||
},
|
||||
/*include_environment_id*/ false,
|
||||
/*include_shell_parameter*/ false,
|
||||
/*include_windows_shell_guidance*/ cfg!(windows),
|
||||
);
|
||||
|
||||
assert!(!has_parameter(&tool, "shell"));
|
||||
|
||||
@@ -54,6 +54,7 @@ pub(crate) struct ExecCommandHandlerOptions {
|
||||
pub(crate) exec_permission_approvals_enabled: bool,
|
||||
pub(crate) include_environment_id: bool,
|
||||
pub(crate) include_shell_parameter: bool,
|
||||
pub(crate) include_windows_shell_guidance: bool,
|
||||
}
|
||||
|
||||
pub struct ExecCommandHandler {
|
||||
@@ -68,6 +69,7 @@ impl Default for ExecCommandHandler {
|
||||
exec_permission_approvals_enabled: false,
|
||||
include_environment_id: false,
|
||||
include_shell_parameter: true,
|
||||
include_windows_shell_guidance: cfg!(windows),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -92,6 +94,7 @@ impl ToolExecutor<ToolInvocation> for ExecCommandHandler {
|
||||
},
|
||||
self.options.include_environment_id,
|
||||
self.options.include_shell_parameter,
|
||||
self.options.include_windows_shell_guidance,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user