The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(embed): bound cancellation drain and isolate fleet measurements
Steven Enamakelbbd3d83d80fc
diff --git a/crates/openhuman-core/src/security/keyring/encrypted_file_backend.rs b/crates/openhuman-core/src/security/keyring/encrypted_file_backend.rsindex 01add1ddee..e74bd17b2a 100644--- a/crates/openhuman-core/src/security/keyring/encrypted_file_backend.rs+++ b/crates/openhuman-core/src/security/keyring/encrypted_file_backend.rs@@ -4,7 +4,7 @@//! [`init_master_key`] loads the key once from [`MASTER_KEY_ENV`] or//! [`MASTER_KEY_FILE_ENV`] for headless hosts, otherwise from the OS keychain.//! The cached key avoids repeated prompts in dev-signed macOS builds;-//! this backend never reads the OS keychain itself.+//! file operations use the cache; initialization may access the OS keychain.use std::path::{Path, PathBuf};use std::sync::OnceLock;diff --git a/crates/openhuman-core/src/tools/timeout/mod.rs b/crates/openhuman-core/src/tools/timeout/mod.rsindex 8f2ab22bcd..16547ed574 100644--- a/crates/openhuman-core/src/tools/timeout/mod.rs+++ b/crates/openhuman-core/src/tools/timeout/mod.rs@@ -332,7 +332,9 @@ async fn collect_command_output(// Its PID cannot be reused while signalling this group.group.kill();child.start_kill()?;- drain.await?;+ if let Ok(result) = tokio::time::timeout(Duration::from_secs(2), drain).await {+ result?;+ }}result = &mut drain => { result?; }}diff --git a/crates/openhuman-embed/examples/linux_fleet.rs b/crates/openhuman-embed/examples/linux_fleet.rsindex 47008e6c1f..362d00529a 100644--- a/crates/openhuman-embed/examples/linux_fleet.rs+++ b/crates/openhuman-embed/examples/linux_fleet.rs@@ -37,7 +37,10 @@ fn main() -> anyhow::Result<()> {}async fn measure(count: usize) -> anyhow::Result<()> {- let mock = MockServer::start().await;+ let mock = MockServer::builder()+ .disable_request_recording()+ .start()+ .await;Mock::given(wiremock::matchers::method("POST")).and(wiremock::matchers::path("/v1/chat/completions")).respond_with(ResponseTemplate::new(200).set_body_json(json!({diff --git a/crates/openhuman-embed/tests/README.md b/crates/openhuman-embed/tests/README.mdindex 2086d80218..7decf4823a 100644--- a/crates/openhuman-embed/tests/README.md+++ b/crates/openhuman-embed/tests/README.md@@ -39,7 +39,6 @@ recorded on the wrong server.| [`public_api.rs`](public_api.rs) | Compile-time check that the host-facing types and signatures stay exported. || [`turn_cancellation.rs`](turn_cancellation.rs) | Cancellation before send, during inference and during a builtin shell command; repeated requests and agent reuse. || [`process_cancellation.rs`](process_cancellation.rs) | On Linux, dropping a command future kills its shell descendants. |-| `inline_permissions.rs` | An inline UI decision precedes execution; concurrent agents and one-turn denials stay isolated. || `usage_hooks.rs` | Per-agent stop policy and per-turn cumulative usage observation, with provider charges and no extra calls after a stop. || [`turn_tools.rs`](turn_tools.rs) | One-turn belt replacement/revocation, resumed-session schemas and independent concurrent workers. |diff --git a/crates/openhuman-embed/tests/process_cancellation.rs b/crates/openhuman-embed/tests/process_cancellation.rsindex e7aa730509..479c9e4214 100644--- a/crates/openhuman-embed/tests/process_cancellation.rs+++ b/crates/openhuman-embed/tests/process_cancellation.rs@@ -216,3 +216,46 @@ async fn host_commands_receive_stdin_and_timeout_after_reaping() {let pid = std::fs::read_to_string(pidfile).unwrap();assert!(!std::path::Path::new(&format!("/proc/{}", pid.trim())).exists());}++#[tokio::test]+async fn cancellation_reaps_the_leader_when_an_escaped_descendant_holds_its_pipes() {+ let scratch = tempfile::tempdir().unwrap();+ let pidfile = scratch.path().join("escaped.pid");+ let mut command = tokio::process::Command::new("/bin/sh");+ command.args([+ "-c",+ &format!(+ "setsid sh -c 'echo $$ > {}; sleep 30' & wait",+ pidfile.display()+ ),+ ]);+ let cleanup = openhuman_embed::process::CommandCleanup::default();+ let mut run = Box::pin(cleanup.scope(output_unbounded(&mut command)));+ let pid = tokio::time::timeout(Duration::from_secs(5), async {+ loop {+ tokio::select! {+ result = &mut run => panic!("command ended early: {result:?}"),+ _ = tokio::time::sleep(Duration::from_millis(10)) => {}+ }+ if let Ok(pid) = std::fs::read_to_string(&pidfile) {+ break pid;+ }+ }+ })+ .await+ .unwrap();+ drop(run);+ let settled = tokio::time::timeout(Duration::from_secs(4), cleanup.wait()).await;+ // This deliberately escaped group belongs to the fixture; clean it on+ // both red and green paths before asserting the bounded acknowledgement.+ let status = std::process::Command::new("kill")+ .args(["-KILL", "--", &format!("-{}", pid.trim())])+ .status()+ .unwrap();+ assert!(status.success());+ cleanup.wait().await;+ assert!(+ settled.is_ok(),+ "escaped descendant blocked cancellation acknowledgement"+ );+}diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.mdindex 6ca3140e1e..4d88a495d7 100644--- a/docs/TEST-COVERAGE-MATRIX.md+++ b/docs/TEST-COVERAGE-MATRIX.md@@ -665,7 +665,6 @@ The thread JSONL store moved to `tinyagents_session::threads` (`vendor/tinyagent| 16.1.14 | Agent and turn hook isolation | RI | `crates/openhuman-embed/tests/scoped_hooks.rs` | ✅ | Additive same-named callbacks, overlapping worker turns, one-turn callback lifetime, resumed-session snapshots, core-scheduled turn callbacks and reuse of a removed agent id without registry leakage || 16.1.15 | Agent-turn route attribution headers | RU+RI | `crates/openhuman-embed/tests/route_headers.rs`, `crates/openhuman-embed/src/turn_tests.rs` | ✅ | Per-route headers reach only the named endpoint and turn, remain absent on other agents and backend requests, and are redacted in Debug; wire fields pinned against the registered controller schema || 16.1.16 | Tool-hook turn identity and cwd | RI | `crates/openhuman-embed/tests/tool_hook_context.rs` | ✅ | Before and after hooks report the worker/session and working root used by builtin shell; a later turn returns to its agent default |-| 16.1.17 | Inline agent/turn permission callback | RI | `crates/openhuman-embed/tests/inline_permissions.rs` | ✅ | UI decisions precede execution; denials narrow authority, concurrent agents remain independent, cancellation closes a pending receiver and a closed UI refuses execution || 16.1.18 | Per-turn host-tool replacement | RI | `crates/openhuman-embed/tests/turn_tools.rs` | ✅ | Replacement and empty-belt revocation apply to resumed HostOnly and mixed definitions, without restoring historical declarations or affecting other agents and later turns || 16.1.19 | Scoped usage observation and budget stop | RI | `crates/openhuman-embed/tests/usage_hooks.rs` | ✅ | Cumulative charged cost and tokens, known-zero versus unpriced calls, per-agent policy and per-turn observer isolation; no summary-repair model calls after a stop |