mirror of
https://github.com/instructkr/claw-code.git
synced 2026-05-18 13:31:28 +08:00
omx(team): auto-checkpoint worker-1 [1]
This commit is contained in:
@@ -177,33 +177,10 @@ async fn execute_bash_async(
|
|||||||
let mut command = prepare_tokio_command(&input.command, &cwd, &sandbox_status, true);
|
let mut command = prepare_tokio_command(&input.command, &cwd, &sandbox_status, true);
|
||||||
|
|
||||||
let output_result = if let Some(timeout_ms) = input.timeout {
|
let output_result = if let Some(timeout_ms) = input.timeout {
|
||||||
match timeout(Duration::from_millis(timeout_ms), command.output()).await {
|
if let Ok(result) = timeout(Duration::from_millis(timeout_ms), command.output()).await {
|
||||||
Ok(result) => (result?, false),
|
(result?, false)
|
||||||
Err(_) => {
|
} else {
|
||||||
let is_test = is_test_command(&input.command);
|
return Ok(timeout_output(&input, timeout_ms, sandbox_status));
|
||||||
let return_code_interpretation = if is_test { "test.hung" } else { "timeout" };
|
|
||||||
return Ok(BashCommandOutput {
|
|
||||||
stdout: String::new(),
|
|
||||||
stderr: format!("Command exceeded timeout of {timeout_ms} ms"),
|
|
||||||
raw_output_path: None,
|
|
||||||
interrupted: true,
|
|
||||||
is_image: None,
|
|
||||||
background_task_id: None,
|
|
||||||
backgrounded_by_user: None,
|
|
||||||
assistant_auto_backgrounded: None,
|
|
||||||
dangerously_disable_sandbox: input.dangerously_disable_sandbox,
|
|
||||||
return_code_interpretation: Some(String::from(return_code_interpretation)),
|
|
||||||
no_output_expected: Some(true),
|
|
||||||
structured_content: Some(vec![test_timeout_provenance(
|
|
||||||
&input.command,
|
|
||||||
timeout_ms,
|
|
||||||
is_test,
|
|
||||||
)]),
|
|
||||||
persisted_output_path: None,
|
|
||||||
persisted_output_size: None,
|
|
||||||
sandbox_status: Some(sandbox_status),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(command.output().await?, false)
|
(command.output().await?, false)
|
||||||
@@ -240,6 +217,36 @@ async fn execute_bash_async(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn timeout_output(
|
||||||
|
input: &BashCommandInput,
|
||||||
|
timeout_ms: u64,
|
||||||
|
sandbox_status: SandboxStatus,
|
||||||
|
) -> BashCommandOutput {
|
||||||
|
let is_test = is_test_command(&input.command);
|
||||||
|
let return_code_interpretation = if is_test { "test.hung" } else { "timeout" };
|
||||||
|
BashCommandOutput {
|
||||||
|
stdout: String::new(),
|
||||||
|
stderr: format!("Command exceeded timeout of {timeout_ms} ms"),
|
||||||
|
raw_output_path: None,
|
||||||
|
interrupted: true,
|
||||||
|
is_image: None,
|
||||||
|
background_task_id: None,
|
||||||
|
backgrounded_by_user: None,
|
||||||
|
assistant_auto_backgrounded: None,
|
||||||
|
dangerously_disable_sandbox: input.dangerously_disable_sandbox,
|
||||||
|
return_code_interpretation: Some(String::from(return_code_interpretation)),
|
||||||
|
no_output_expected: Some(true),
|
||||||
|
structured_content: Some(vec![test_timeout_provenance(
|
||||||
|
&input.command,
|
||||||
|
timeout_ms,
|
||||||
|
is_test,
|
||||||
|
)]),
|
||||||
|
persisted_output_path: None,
|
||||||
|
persisted_output_size: None,
|
||||||
|
sandbox_status: Some(sandbox_status),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn is_test_command(command: &str) -> bool {
|
fn is_test_command(command: &str) -> bool {
|
||||||
let normalized = command
|
let normalized = command
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
|
|||||||
@@ -338,6 +338,7 @@ pub fn recipe_for(scenario: &FailureScenario) -> RecoveryRecipe {
|
|||||||
/// Looks up the recipe, enforces the one-attempt-before-escalation
|
/// Looks up the recipe, enforces the one-attempt-before-escalation
|
||||||
/// policy, simulates step execution (controlled by the context), and
|
/// policy, simulates step execution (controlled by the context), and
|
||||||
/// emits structured [`RecoveryEvent`]s for every attempt.
|
/// emits structured [`RecoveryEvent`]s for every attempt.
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub fn attempt_recovery(scenario: &FailureScenario, ctx: &mut RecoveryContext) -> RecoveryResult {
|
pub fn attempt_recovery(scenario: &FailureScenario, ctx: &mut RecoveryContext) -> RecoveryResult {
|
||||||
let recipe = recipe_for(scenario);
|
let recipe = recipe_for(scenario);
|
||||||
let recipe_id = scenario.to_string();
|
let recipe_id = scenario.to_string();
|
||||||
|
|||||||
Reference in New Issue
Block a user