mirror of
https://github.com/openai/codex.git
synced 2026-10-23 18:08:45 +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:
@@ -2426,12 +2426,26 @@ impl ThreadRequestProcessor {
|
||||
request_id: &ConnectionRequestId,
|
||||
params: ThreadShellCommandParams,
|
||||
) -> Result<ThreadShellCommandResponse, JSONRPCErrorError> {
|
||||
let ThreadShellCommandParams { thread_id, command } = params;
|
||||
let ThreadShellCommandParams {
|
||||
thread_id,
|
||||
command,
|
||||
timeout_ms,
|
||||
} = params;
|
||||
let command = command.trim().to_string();
|
||||
if command.is_empty() {
|
||||
return Err(invalid_request("command must not be empty"));
|
||||
}
|
||||
|
||||
let timeout_ms = timeout_ms
|
||||
.map(|timeout_ms| {
|
||||
u64::try_from(timeout_ms).map_err(|_| {
|
||||
invalid_params(format!(
|
||||
"thread/shellCommand timeoutMs must be non-negative, got {timeout_ms}"
|
||||
))
|
||||
})
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
let (_, thread) = self.load_thread(&thread_id).await?;
|
||||
ensure_direct_input_allowed(thread.as_ref()).await?;
|
||||
|
||||
@@ -2449,7 +2463,10 @@ impl ThreadRequestProcessor {
|
||||
self.submit_core_op(
|
||||
request_id,
|
||||
thread.as_ref(),
|
||||
Op::RunUserShellCommand { command },
|
||||
Op::RunUserShellCommand {
|
||||
command,
|
||||
timeout_ms,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.map_err(|err| internal_error(format!("failed to start shell command: {err}")))?;
|
||||
|
||||
Reference in New Issue
Block a user