Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(agents): a durable Pi agent runs through the durable ACP driver (#6242)

ddupont7c689079d238
diff --git a/docs/content/docs/spaces/guides/keep-an-agent-running.mdx b/docs/content/docs/spaces/guides/keep-an-agent-running.mdx
index a83cd541ce..91d0ca2a5f 100644
--- a/docs/content/docs/spaces/guides/keep-an-agent-running.mdx
+++ b/docs/content/docs/spaces/guides/keep-an-agent-running.mdx
@@ -203,7 +203,7 @@ Other limits:
| Gemini CLI | `session/load` | Tools in the default approval mode (a permission was asked in the recorded run) | Read-only tools, and everything in yolo mode | Not run durably |
| Google Antigravity | `session/resume` and `session/load` | Commands (asked in the recorded run) | Not known | Not run durably |
| Goose | `session/load` | None seen in the recorded run | All tools seen | Not run durably |
-| Pi | `session/load` | None seen | All tools seen | Not run durably |
+| Pi | `session/load` | None seen | All tools seen | Runs through the same driver as the others (pi-acp adapter): 6 steps done, and one runner kill resumed with the recovery note in 49 s (one run each, so not a campaign) |
| OpenClaw | `session/resume` and `session/load` | None seen | All tools seen | The driver spec is refused (needs a launch wrapper) |
The four measured rows come from real harness binaries (installed by the cua
diff --git a/libs/cua/crates/cua-cli/src/agent_session_cmd.rs b/libs/cua/crates/cua-cli/src/agent_session_cmd.rs
index d9bf906562..8740d8dc42 100644
--- a/libs/cua/crates/cua-cli/src/agent_session_cmd.rs
+++ b/libs/cua/crates/cua-cli/src/agent_session_cmd.rs
@@ -25,9 +25,6 @@ use std::time::Duration;
/// The prefix that names a durable session where a sandbox goes.
pub const PREFIX: &str = "session:";
-/// The driver's entry in its bundle, for the `pi` harness.
-pub const PI_DRIVER_ENTRY: &str = "pi-durable-driver";
-
/// The session `s` names (`session:NAME`), if it does.
pub fn session_of(s: &str) -> Option<&str> {
s.strip_prefix(PREFIX).filter(|n| !n.is_empty())
@@ -49,9 +46,9 @@ struct Driver {
state_dir: String,
}
-/// The driver of `harness`: `--driver-cmd` (testing), the pi-durable driver
-/// for `pi`, and for every other ACP harness the durable ACP driver of
-/// `cua-agents`.
+/// The driver of `harness`: `--driver-cmd` (testing), else the durable ACP
+/// driver of `cua-agents` (every harness, Pi included, through its ACP
+/// adapter).
fn driver_of(
a: &RunArgs,
name: &str,
@@ -69,14 +66,6 @@ fn driver_of(
state_dir: String::new(),
});
}
- if a.harness == "pi" {
- return Ok(Driver {
- argv: vec!["node".into(), PI_DRIVER_ENTRY.into()],
- env: keys,
- bundle: String::new(),
- state_dir: String::new(),
- });
- }
if !a.files.is_empty() {
return Err(CuaError::InvalidArgument(
"--file is not supported with --durable".into(),
@@ -168,7 +157,7 @@ pub(crate) fn start_params(
}
let driver = driver_of(a, name, keys)?;
let mut env = driver.env;
- // The pi driver (and a --driver-cmd) reads the task from its environment;
+ // A --driver-cmd reads the task from its environment;
// an ACP driver has it in its bundle.
if driver.bundle.is_empty() {
env.insert("CUA_AGENT_HARNESS".into(), a.harness.clone().into());
@@ -513,12 +502,16 @@ mod tests {
let p = start_params(&a, "refactor", shell).unwrap();
assert_eq!(p["name"], "refactor");
assert_eq!(p["max_attempts"], 8);
- assert_eq!(p["spec"]["argv"], json!(["node", PI_DRIVER_ENTRY]));
+ // Pi runs the same durable ACP driver as every other harness (it
+ // has no `node` of its own on the job image: the driver installs one).
+ assert_eq!(p["spec"]["argv"], json!(["/bin/sh", "driver.sh"]));
+ assert!(!p["spec"]["bundle"].as_str().unwrap().is_empty());
assert_eq!(p["spec"]["space"], "research");
assert_eq!(p["spec"]["stall_secs"], 45);
assert_eq!(p["spec"]["on"], "auto");
- assert_eq!(p["spec"]["env"]["CUA_AGENT_PROMPT"], "keep going");
- assert_eq!(p["spec"]["env"]["CUA_AGENT_MODEL"], "m1");
+ // The task is in the bundle, not the environment; the key is in the
+ // environment only.
+ assert!(p["spec"]["env"].get("CUA_AGENT_PROMPT").is_none());
assert_eq!(p["spec"]["env"]["ANTHROPIC_API_KEY"], "sk-ant-test");
// Only fields the coordinator's SessionSpec has (it keeps the same
// list in a test of its own).
@@ -613,7 +606,6 @@ mod tests {
let p = start_params(&a, "fix-it", shell).unwrap();
let spec = &p["spec"];
assert!(!spec["argv"].as_array().unwrap().is_empty());
- assert_ne!(spec["argv"], json!(["node", PI_DRIVER_ENTRY]));
// Packaged for the job: a bundle, no prompt in the environment, the
// key in the environment only (never in the bundle).
let bundle = spec["bundle"].as_str().unwrap();