Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(cli): cua agent add --durable takes --max-attempts and --stall-secs (#6241)
ddupont7e94c857ae9e
diff --git a/docs/content/docs/cua-cli/reference/cli/agents.mdx b/docs/content/docs/cua-cli/reference/cli/agents.mdxindex a1df4d3f6c..7c4510a0e3 100644--- a/docs/content/docs/cua-cli/reference/cli/agents.mdx+++ b/docs/content/docs/cua-cli/reference/cli/agents.mdx@@ -120,6 +120,8 @@ cua agent add [OPTIONS] --harness <HARNESS> <NAME> [PROMPT]| <span id="cua-agent-add--base-url"></span>`--base-url` | string | | || <span id="cua-agent-add--env-from-host"></span>`--env-from-host` | string | | Provider key variable to forward at each start. Repeatable. || <span id="cua-agent-add--on"></span>`--on` | string | | With --durable: the machine the driver runs on (`auto`, or a machine's name; default: this machine). |+| <span id="cua-agent-add--max-attempts"></span>`--max-attempts` | integer | | With --durable: drives allowed in total before the session fails (default 5). |+| <span id="cua-agent-add--stall-secs"></span>`--stall-secs` | integer | | With --durable: seconds the driver may write no output before it counts as wedged, is cancelled and started again (default 120; 0: never). Drivers print a heartbeat every quarter of it. || <span id="cua-agent-add--every"></span>`--every` | integer | | Schedule PROMPT every N minutes. || <span id="cua-agent-add--daily"></span>`--daily` | string | | Schedule PROMPT every day at HH:MM. || <span id="cua-agent-add--weekly"></span>`--weekly` | string | | Schedule PROMPT every week, `mon 09:00`. |diff --git a/libs/cua/crates/cua-cli/src/agent_cmd.rs b/libs/cua/crates/cua-cli/src/agent_cmd.rsindex c482aaa13e..e2c65d661a 100644--- a/libs/cua/crates/cua-cli/src/agent_cmd.rs+++ b/libs/cua/crates/cua-cli/src/agent_cmd.rs@@ -295,6 +295,15 @@ pub struct AddArgs {/// machine's name; default: this machine).#[arg(long, value_name = "MACHINE", requires = "durable")]pub(crate) on: Option<String>,+ /// With --durable: drives allowed in total before the session fails+ /// (default 5).+ #[arg(long, value_name = "N", requires = "durable")]+ pub(crate) max_attempts: Option<u32>,+ /// With --durable: seconds the driver may write no output before it+ /// counts as wedged, is cancelled and started again (default 120; 0:+ /// never). Drivers print a heartbeat every quarter of it.+ #[arg(long, value_name = "SECS", requires = "durable")]+ pub(crate) stall_secs: Option<u32>,/// Schedule PROMPT every N minutes.#[arg(long, value_name = "MINUTES", requires = "prompt", conflicts_with_all = ["daily", "weekly"])]pub(crate) every: Option<i64>,@@ -343,8 +352,8 @@ pub(crate) fn desugar(cmd: AgentCmd) -> Result<Vec<AgentCmd>, CuaError> {follow: false,durable,on: a.on.clone(),- max_attempts: None,- stall_secs: None,+ max_attempts: a.max_attempts,+ stall_secs: a.stall_secs,name: durable.then(|| a.name.clone()),driver_cmd: None,driver_bundle: None,@@ -995,6 +1004,47 @@ mod tests {format!("{:?}", desugar(cmd).unwrap())}+ /// `agent add --durable` takes the same `--max-attempts` and+ /// `--stall-secs` as `agent run --durable`, and they reach the session.+ #[test]+ fn add_durable_passes_max_attempts_and_stall_secs() {+ let argv = [+ "add",+ "nightly",+ "fix the tests",+ "--harness",+ "claude-code",+ "--durable",+ "--on",+ "auto",+ "--max-attempts",+ "8",+ "--stall-secs",+ "45",+ ];+ let steps = desugar(parse(&argv).unwrap()).unwrap();+ let [AgentCmd::Run(r)] = steps.as_slice() else {+ panic!("one run: {steps:?}")+ };+ assert!(r.durable);+ assert_eq!((r.max_attempts, r.stall_secs), (Some(8), Some(45)));+ // Left out, they stay unset (the coordinator's defaults apply).+ let steps =+ desugar(parse(&["add", "n", "x", "--harness", "claude-code", "--durable"]).unwrap())+ .unwrap();+ let [AgentCmd::Run(r)] = steps.as_slice() else {+ panic!("one run: {steps:?}")+ };+ assert_eq!((r.max_attempts, r.stall_secs), (None, None));+ // Without --durable they mean nothing, so they are refused.+ for flag in ["--max-attempts", "--stall-secs"] {+ assert!(+ parse(&["add", "n", "x", "--harness", "h", "--once", flag, "3"]).is_err(),+ "{flag} needs --durable"+ );+ }+ }+/// Alias equivalence: each new spelling runs exactly what the old/// commands it stands for run.#[test]diff --git a/libs/cua/crates/cua-cli/tests/fixtures/help/agent-add.txt b/libs/cua/crates/cua-cli/tests/fixtures/help/agent-add.txtindex 4b718f0ff3..ef90c8dda1 100644--- a/libs/cua/crates/cua-cli/tests/fixtures/help/agent-add.txt+++ b/libs/cua/crates/cua-cli/tests/fixtures/help/agent-add.txt@@ -55,6 +55,12 @@ Options:--on <MACHINE>With --durable: the machine the driver runs on (`auto`, or a machine's name; default: this machine)+ --max-attempts <N>+ With --durable: drives allowed in total before the session fails (default 5)++ --stall-secs <SECS>+ With --durable: seconds the driver may write no output before it counts as wedged, is cancelled and started again (default 120; 0: never). Drivers print a heartbeat every quarter of it+--every <MINUTES>Schedule PROMPT every N minutesdiff --git a/scripts/docs-generators/cli-specs/cua.json b/scripts/docs-generators/cli-specs/cua.jsonindex 37b7b90b57..21efa92c30 100644--- a/scripts/docs-generators/cli-specs/cua.json+++ b/scripts/docs-generators/cli-specs/cua.json@@ -1225,6 +1225,38 @@"type": "string","value_name": "MACHINE"},+ {+ "aliases": [],+ "default_value": null,+ "env": null,+ "help": "With --durable: drives allowed in total before the session fails (default 5)",+ "hidden": false,+ "is_optional": true,+ "multiple_values": false,+ "name": "max-attempts",+ "possible_values": [],+ "repeatable": false,+ "short_name": null,+ "takes_value": true,+ "type": "integer",+ "value_name": "N"+ },+ {+ "aliases": [],+ "default_value": null,+ "env": null,+ "help": "With --durable: seconds the driver may write no output before it counts as wedged, is cancelled and started again (default 120; 0: never). Drivers print a heartbeat every quarter of it",+ "hidden": false,+ "is_optional": true,+ "multiple_values": false,+ "name": "stall-secs",+ "possible_values": [],+ "repeatable": false,+ "short_name": null,+ "takes_value": true,+ "type": "integer",+ "value_name": "SECS"+ },{"aliases": [],"default_value": null,