Skip to content

Commit d3f8ff9

Browse files
bellmanbellman
authored andcommitted
omx(team): auto-checkpoint worker-1 [1]
1 parent 5c40d4e commit d3f8ff9

2 files changed

Lines changed: 35 additions & 27 deletions

File tree

rust/crates/runtime/src/bash.rs

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -177,33 +177,10 @@ async fn execute_bash_async(
177177
let mut command = prepare_tokio_command(&input.command, &cwd, &sandbox_status, true);
178178

179179
let output_result = if let Some(timeout_ms) = input.timeout {
180-
match timeout(Duration::from_millis(timeout_ms), command.output()).await {
181-
Ok(result) => (result?, false),
182-
Err(_) => {
183-
let is_test = is_test_command(&input.command);
184-
let return_code_interpretation = if is_test { "test.hung" } else { "timeout" };
185-
return Ok(BashCommandOutput {
186-
stdout: String::new(),
187-
stderr: format!("Command exceeded timeout of {timeout_ms} ms"),
188-
raw_output_path: None,
189-
interrupted: true,
190-
is_image: None,
191-
background_task_id: None,
192-
backgrounded_by_user: None,
193-
assistant_auto_backgrounded: None,
194-
dangerously_disable_sandbox: input.dangerously_disable_sandbox,
195-
return_code_interpretation: Some(String::from(return_code_interpretation)),
196-
no_output_expected: Some(true),
197-
structured_content: Some(vec![test_timeout_provenance(
198-
&input.command,
199-
timeout_ms,
200-
is_test,
201-
)]),
202-
persisted_output_path: None,
203-
persisted_output_size: None,
204-
sandbox_status: Some(sandbox_status),
205-
});
206-
}
180+
if let Ok(result) = timeout(Duration::from_millis(timeout_ms), command.output()).await {
181+
(result?, false)
182+
} else {
183+
return Ok(timeout_output(&input, timeout_ms, sandbox_status));
207184
}
208185
} else {
209186
(command.output().await?, false)
@@ -240,6 +217,36 @@ async fn execute_bash_async(
240217
})
241218
}
242219

220+
fn timeout_output(
221+
input: &BashCommandInput,
222+
timeout_ms: u64,
223+
sandbox_status: SandboxStatus,
224+
) -> BashCommandOutput {
225+
let is_test = is_test_command(&input.command);
226+
let return_code_interpretation = if is_test { "test.hung" } else { "timeout" };
227+
BashCommandOutput {
228+
stdout: String::new(),
229+
stderr: format!("Command exceeded timeout of {timeout_ms} ms"),
230+
raw_output_path: None,
231+
interrupted: true,
232+
is_image: None,
233+
background_task_id: None,
234+
backgrounded_by_user: None,
235+
assistant_auto_backgrounded: None,
236+
dangerously_disable_sandbox: input.dangerously_disable_sandbox,
237+
return_code_interpretation: Some(String::from(return_code_interpretation)),
238+
no_output_expected: Some(true),
239+
structured_content: Some(vec![test_timeout_provenance(
240+
&input.command,
241+
timeout_ms,
242+
is_test,
243+
)]),
244+
persisted_output_path: None,
245+
persisted_output_size: None,
246+
sandbox_status: Some(sandbox_status),
247+
}
248+
}
249+
243250
fn is_test_command(command: &str) -> bool {
244251
let normalized = command
245252
.split_whitespace()

rust/crates/runtime/src/recovery_recipes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ pub fn recipe_for(scenario: &FailureScenario) -> RecoveryRecipe {
338338
/// Looks up the recipe, enforces the one-attempt-before-escalation
339339
/// policy, simulates step execution (controlled by the context), and
340340
/// emits structured [`RecoveryEvent`]s for every attempt.
341+
#[allow(clippy::too_many_lines)]
341342
pub fn attempt_recovery(scenario: &FailureScenario, ctx: &mut RecoveryContext) -> RecoveryResult {
342343
let recipe = recipe_for(scenario);
343344
let recipe_id = scenario.to_string();

0 commit comments

Comments
 (0)