mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Support configurable timeouts for thread shell commands (#41384)
## What changed - Add an optional `timeoutMs` parameter to `thread/shellCommand` and propagate it to user shell execution. - Preserve the one-hour default when the parameter is omitted or `null`, allow longer deadlines, and treat `0` as an immediate timeout. - Reject negative or otherwise invalid values before execution. Timing out an auxiliary shell command leaves its active turn running. ## Testing - Cover default, extended, immediate, invalid, standalone, active-turn, and interruption behavior. GitOrigin-RevId: d72f67793d9766b7383f28d30140270a4a76a495
This commit is contained in:
@@ -61,11 +61,15 @@ pub(crate) enum UserShellCommandMode {
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct UserShellCommandTask {
|
||||
command: String,
|
||||
timeout_ms: Option<u64>,
|
||||
}
|
||||
|
||||
impl UserShellCommandTask {
|
||||
pub(crate) fn new(command: String) -> Self {
|
||||
Self { command }
|
||||
pub(crate) fn new(command: String, timeout_ms: Option<u64>) -> Self {
|
||||
Self {
|
||||
command,
|
||||
timeout_ms,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +93,7 @@ impl SessionTask for UserShellCommandTask {
|
||||
session,
|
||||
turn_context,
|
||||
self.command.clone(),
|
||||
self.timeout_ms,
|
||||
cancellation_token,
|
||||
UserShellCommandMode::StandaloneTurn,
|
||||
)
|
||||
@@ -101,6 +106,7 @@ pub(crate) async fn execute_user_shell_command(
|
||||
session: Arc<Session>,
|
||||
turn_context: Arc<TurnContext>,
|
||||
command: String,
|
||||
timeout_ms: Option<u64>,
|
||||
cancellation_token: CancellationToken,
|
||||
mode: UserShellCommandMode,
|
||||
) {
|
||||
@@ -212,9 +218,7 @@ pub(crate) async fn execute_user_shell_command(
|
||||
// inherit a managed proxy from the surrounding session or turn.
|
||||
network: None,
|
||||
network_environment_id: None,
|
||||
// TODO(zhao-oai): Now that we have ExecExpiration::Cancellation, we
|
||||
// should use that instead of an "arbitrarily large" timeout here.
|
||||
expiration: USER_SHELL_TIMEOUT_MS.into(),
|
||||
expiration: timeout_ms.unwrap_or(USER_SHELL_TIMEOUT_MS).into(),
|
||||
capture_policy: ExecCapturePolicy::ShellTool,
|
||||
sandbox: SandboxType::None,
|
||||
windows_sandbox_policy_cwd: cwd.clone().into(),
|
||||
|
||||
Reference in New Issue
Block a user