Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(shell): status read errors free a released process; report Docker's applied timeout

sanil-23a4f2c9d50af5
diff --git a/crates/openhuman-core/src/sandbox/shell_exec_fixture.rs b/crates/openhuman-core/src/sandbox/shell_exec_fixture.rs
index f6cdd2f76a..eb575e624b 100644
--- a/crates/openhuman-core/src/sandbox/shell_exec_fixture.rs
+++ b/crates/openhuman-core/src/sandbox/shell_exec_fixture.rs
@@ -166,8 +166,10 @@ impl FixtureLive {
.await;
let state = match finished {
Ok(status) => {
+ // Ended only once the wait itself succeeded.
+ let code = status?.code().unwrap_or(-1);
self.ended = true;
- LiveState::Exited(status?.code().unwrap_or(-1))
+ LiveState::Exited(code)
}
Err(_) if tokio::time::Instant::now() >= self.deadline => {
self.stop().await;
diff --git a/crates/openhuman-core/src/sandbox/shell_processes.rs b/crates/openhuman-core/src/sandbox/shell_processes.rs
index 37ce7e6594..6a93f19ca3 100644
--- a/crates/openhuman-core/src/sandbox/shell_processes.rs
+++ b/crates/openhuman-core/src/sandbox/shell_processes.rs
@@ -229,15 +229,18 @@ impl ShellProcesses {
let entry = self.entry(id)?;
let mut entry = entry.lock().await;
if entry.ended.is_none() {
+ let read = match entry.handle.read(Duration::ZERO).await {
+ Ok(read) => read,
+ Err(error) => {
+ let message = format!("Could not read process {id}: {error}");
+ return Err(self.failed(&mut entry, message));
+ }
+ };
let LiveRead {
stdout,
stderr,
state,
- } = entry
- .handle
- .read(Duration::ZERO)
- .await
- .map_err(|error| format!("Could not read process {id}: {error}"))?;
+ } = read;
entry.pending_stdout.push_str(&stdout);
entry.pending_stderr.push_str(&stderr);
self.settle(&mut entry, state);
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_run.rs b/crates/openhuman-core/src/tools/impl/system/shell_run.rs
index 5297eb8eb1..f4a9d2643b 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell_run.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_run.rs
@@ -239,7 +239,10 @@ pub(super) async fn run_in_policy(
meter,
)
.await;
- let result = finish(outcome, slot, command, started, effective, audit);
+ // Docker stops the command at the model's time; a native run holding a
+ // slot yields before its deadline, so a timeout here is that bound.
+ let applied = deadline_instead.map_or(effective, |deadline| effective.min(deadline));
+ let result = finish(outcome, slot, command, started, applied, audit);
(true, result)
}