mirror of
https://github.com/openai/codex.git
synced 2026-10-30 19:18:49 +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:
@@ -1306,23 +1306,44 @@ fn fs_copy_params_round_trip_with_recursive_directory_copy() {
|
||||
|
||||
#[test]
|
||||
fn thread_shell_command_params_round_trip() {
|
||||
let params = ThreadShellCommandParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
command: "printf 'hello world\\n'".to_string(),
|
||||
};
|
||||
for timeout_ms in [None, Some(0), Some(28_800_000)] {
|
||||
let params = ThreadShellCommandParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
command: "printf 'hello world\\n'".to_string(),
|
||||
timeout_ms,
|
||||
};
|
||||
|
||||
let value = serde_json::to_value(¶ms).expect("serialize thread/shellCommand params");
|
||||
let value = serde_json::to_value(¶ms).expect("serialize thread/shellCommand params");
|
||||
assert_eq!(
|
||||
value,
|
||||
json!({
|
||||
"threadId": "thr_123",
|
||||
"command": "printf 'hello world\\n'",
|
||||
"timeoutMs": timeout_ms,
|
||||
})
|
||||
);
|
||||
|
||||
let decoded = serde_json::from_value::<ThreadShellCommandParams>(value)
|
||||
.expect("deserialize thread/shellCommand params");
|
||||
assert_eq!(decoded, params);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_shell_command_params_without_timeout_remain_valid() {
|
||||
let decoded = serde_json::from_value::<ThreadShellCommandParams>(json!({
|
||||
"threadId": "thr_123",
|
||||
"command": "echo hello",
|
||||
}))
|
||||
.expect("deserialize thread/shellCommand params without timeoutMs");
|
||||
assert_eq!(
|
||||
value,
|
||||
json!({
|
||||
"threadId": "thr_123",
|
||||
"command": "printf 'hello world\\n'",
|
||||
})
|
||||
decoded,
|
||||
ThreadShellCommandParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
command: "echo hello".to_string(),
|
||||
timeout_ms: None,
|
||||
}
|
||||
);
|
||||
|
||||
let decoded = serde_json::from_value::<ThreadShellCommandParams>(value)
|
||||
.expect("deserialize thread/shellCommand params");
|
||||
assert_eq!(decoded, params);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1129,6 +1129,12 @@ pub struct ThreadShellCommandParams {
|
||||
/// such as pipes, redirects, and quoting. This runs unsandboxed with full
|
||||
/// access rather than inheriting the thread sandbox policy.
|
||||
pub command: String,
|
||||
/// Maximum execution time in milliseconds. Defaults to one hour when omitted
|
||||
/// or null. Must be non-negative; zero requests an immediate timeout, not
|
||||
/// unlimited execution. Does not affect the immediate RPC acknowledgement.
|
||||
#[ts(type = "number | null")]
|
||||
#[ts(optional = nullable)]
|
||||
pub timeout_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
|
||||
Reference in New Issue
Block a user