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
refactor(tests): clean up imports in e2e tests
Steven Enamakel9f8e1c49c5cc
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rsindex d44b7e78a2..a03d9139fe 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs@@ -551,8 +551,8 @@ impl OpenHumanSecurityGate {}));- let is_headless_spawn_control = self.headless_descendant_settlement- && call.tool_name == "spawn_subagent";+ let is_headless_spawn_control =+ self.headless_descendant_settlement && call.tool_name == "spawn_subagent";let is_cron_denial = is_cron_turn&& (call.tool_name == SHELL_TOOL|| tool.external_effect_with_args(&call.arguments)diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rsindex 43590a8e51..f4d826b5c1 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs@@ -180,14 +180,9 @@ async fn a_read_only_tool_is_allowed_in_every_tier() {}}-async fn cron_decision(- gate: OpenHumanSecurityGate,- tool_name: &str,-) -> GateDecision {- let core = crate::core::runtime::CoreContext::for_test(- crate::core::runtime::DomainSet::full(),- None,- );+async fn cron_decision(gate: OpenHumanSecurityGate, tool_name: &str) -> GateDecision {+ let core =+ crate::core::runtime::CoreContext::for_test(crate::core::runtime::DomainSet::full(), None);let origin = crate::security::turn_origin::AgentTurnOrigin::TrustedAutomation {job_id: "cron-security-test".into(),source: crate::security::turn_origin::TrustedAutomationSource::Cron,@@ -248,7 +243,10 @@ async fn cron_headless_settlement_does_not_allow_effectful_spawn_aliases() {"spawn_subagent",).await;- assert!(!decision.is_allowed(), "external-effect classification wins");+ assert!(+ !decision.is_allowed(),+ "external-effect classification wins"+ );}#[tokio::test]diff --git a/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs b/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rsindex c4cbc0441e..b16e204363 100644--- a/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs@@ -23,7 +23,9 @@ struct CronChildModel {child_release: tokio::sync::Notify,}-fn scheduled_agent_fixture(timeout_secs: u64) -> (+fn scheduled_agent_fixture(+ timeout_secs: u64,+) -> (TempDir,Config,std::sync::Arc<crate::core::runtime::CoreContext>,@@ -40,9 +42,8 @@ fn scheduled_agent_fixture(timeout_secs: u64) -> (config.reliability.scheduler_retries = 0;std::fs::create_dir_all(&config.workspace_dir).expect("workspace");- let definitions = Arc::new(- crate::agent_registry::host_definition::AgentDefinitionRegistry::builtins_only(),- );+ let definitions =+ Arc::new(crate::agent_registry::host_definition::AgentDefinitionRegistry::builtins_only());let core = crate::core::runtime::CoreContext::for_test_with_config(crate::core::runtime::DomainSet::full(),config.clone(),@@ -143,8 +144,7 @@ impl ChatModel<()> for CronChildModel {response.finish_reason = Some("tool_calls".into());return Ok(response);}- let _drop =- ChildInvocationDrop(std::sync::Arc::clone(&self.child_invocation_dropped));+ let _drop = ChildInvocationDrop(std::sync::Arc::clone(&self.child_invocation_dropped));self.child_release.notified().await;return Ok(ModelResponse::assistant("headless-cron-child-result"));}@@ -189,9 +189,7 @@ async fn scheduled_agent_history_includes_its_spawned_child_result() {let model = std::sync::Arc::new(CronChildModel {spawn_calls: std::sync::atomic::AtomicUsize::new(0),child_calls: std::sync::atomic::AtomicUsize::new(0),- child_invocation_dropped: std::sync::Arc::new(- std::sync::atomic::AtomicBool::new(false),- ),+ child_invocation_dropped: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),accepted_followups: std::sync::atomic::AtomicUsize::new(0),child_attempts_dangerous_tool: false,child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),@@ -205,9 +203,10 @@ async fn scheduled_agent_history_includes_its_spawned_child_result() {let (child_started_tx, child_started_rx) = tokio::sync::oneshot::channel();*model.child_started.lock().unwrap() = Some(child_started_tx);let scheduler_config = config.clone();- let run = tokio::spawn(async move {- dispatch_scheduled_agent(core, dispatch, scheduler_config).await- });+ let run =+ tokio::spawn(+ async move { dispatch_scheduled_agent(core, dispatch, scheduler_config).await },+ );match tokio::time::timeout(std::time::Duration::from_secs(5), child_started_rx).await {Ok(Ok(())) => {}Ok(Err(error)) => panic!("child-start observation disconnected: {error}"),@@ -240,9 +239,14 @@ async fn scheduled_agent_history_includes_its_spawned_child_result() {model.spawn_calls.load(std::sync::atomic::Ordering::SeqCst),1);- assert_eq!(model.child_calls.load(std::sync::atomic::Ordering::SeqCst), 1);assert_eq!(- model.accepted_followups.load(std::sync::atomic::Ordering::SeqCst),+ model.child_calls.load(std::sync::atomic::Ordering::SeqCst),+ 1+ );+ assert_eq!(+ model+ .accepted_followups+ .load(std::sync::atomic::Ordering::SeqCst),1,"the parent accepted the real spawn result before the child completed");@@ -254,9 +258,7 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settlelet model = std::sync::Arc::new(CronChildModel {spawn_calls: std::sync::atomic::AtomicUsize::new(0),child_calls: std::sync::atomic::AtomicUsize::new(0),- child_invocation_dropped: std::sync::Arc::new(- std::sync::atomic::AtomicBool::new(false),- ),+ child_invocation_dropped: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),accepted_followups: std::sync::atomic::AtomicUsize::new(0),child_attempts_dangerous_tool: false,child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),@@ -269,9 +271,10 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settlelet (child_started_tx, child_started_rx) = tokio::sync::oneshot::channel();*model.child_started.lock().unwrap() = Some(child_started_tx);let scheduler_config = config.clone();- let run = tokio::spawn(async move {- dispatch_scheduled_agent(core, dispatch, scheduler_config).await- });+ let run =+ tokio::spawn(+ async move { dispatch_scheduled_agent(core, dispatch, scheduler_config).await },+ );match tokio::time::timeout(std::time::Duration::from_secs(5), child_started_rx).await {Ok(Ok(())) => {}@@ -299,13 +302,21 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settle.as_deref().unwrap_or_default().contains("headless-cron-child-result"));- assert_eq!(model.spawn_calls.load(std::sync::atomic::Ordering::SeqCst), 1);assert_eq!(- model.accepted_followups.load(std::sync::atomic::Ordering::SeqCst),+ model.spawn_calls.load(std::sync::atomic::Ordering::SeqCst),+ 1+ );+ assert_eq!(+ model+ .accepted_followups+ .load(std::sync::atomic::Ordering::SeqCst),1,"the root accepted the child before waiting on it");- assert_eq!(model.child_calls.load(std::sync::atomic::Ordering::SeqCst), 1);+ assert_eq!(+ model.child_calls.load(std::sync::atomic::Ordering::SeqCst),+ 1+ );assert!(model.child_invocation_dropped@@ -313,3 +324,77 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settle"the root deadline dropped the child model future");}++#[tokio::test]+async fn scheduled_cron_child_cannot_run_its_declared_destructive_tool() {+ let _inference = crate::inference::inference_test_guard_async().await;+ let model = std::sync::Arc::new(CronChildModel {+ spawn_calls: std::sync::atomic::AtomicUsize::new(0),+ child_calls: std::sync::atomic::AtomicUsize::new(0),+ child_invocation_dropped: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),+ accepted_followups: std::sync::atomic::AtomicUsize::new(0),+ child_attempts_dangerous_tool: true,+ child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),+ child_started: std::sync::Mutex::new(None),+ child_release: tokio::sync::Notify::new(),+ });+ let _model =+ crate::inference::provider::factory::test_provider_override::install_model(model.clone());+ let (_temp, config, core, dispatch, job) = scheduled_agent_fixture(900);+ let inspect_dispatch = dispatch.clone();+ let (child_started_tx, child_started_rx) = tokio::sync::oneshot::channel();+ *model.child_started.lock().unwrap() = Some(child_started_tx);+ let scheduler_config = config.clone();+ let run =+ tokio::spawn(+ async move { dispatch_scheduled_agent(core, dispatch, scheduler_config).await },+ );+ match tokio::time::timeout(std::time::Duration::from_secs(5), child_started_rx).await {+ Ok(Ok(())) => {}+ Ok(Err(error)) => panic!("scheduled child exited before its model call: {error}"),+ Err(_) => {+ let _ = tokio::time::timeout(std::time::Duration::from_secs(5), run).await;+ panic!("scheduled child never reached its model");+ }+ }+ tokio::time::timeout(std::time::Duration::from_secs(5), run)+ .await+ .expect("Cron should settle the denied child result")+ .expect("Cron scheduler task");++ assert_eq!(+ model.spawn_calls.load(std::sync::atomic::Ordering::SeqCst),+ 1+ );+ assert_eq!(+ model.child_calls.load(std::sync::atomic::Ordering::SeqCst),+ 1+ );+ assert!(+ model+ .child_dangerous_tool_schema_seen+ .load(std::sync::atomic::Ordering::SeqCst),+ "the real child model request exposed the declared destructive tool"+ );+ let owner = crate::agent::tinyagents::tool_registration::subagent_owner_key(+ &config.workspace_dir,+ &format!("cron:{}", job.id),+ None,+ );+ let jobs = crate::core::runtime::slot_for::<+ tinyagents_harness_tools::subagents::SubAgentJobRegistry,+ >(&inspect_dispatch)+ .try_list_owned(owner)+ .expect("inspect the exact Cron session owner");+ assert_eq!(jobs.len(), 1, "one native child belongs to this Cron job");+ assert_eq!(+ jobs[0].status,+ tinyagents_orchestration::subagent::SubAgentJobStatus::Failed,+ "Cron admits only the orchestration control call, not child actions"+ );+ assert!(jobs[0]+ .error+ .as_deref()+ .unwrap_or_default()+ .contains("Scheduled agent turns may use read-only tools only"));+}diff --git a/tests/cli_agent_chat_headless_e2e.rs b/tests/cli_agent_chat_headless_e2e.rsindex c700d3ae18..99b8fcd66a 100644--- a/tests/cli_agent_chat_headless_e2e.rs+++ b/tests/cli_agent_chat_headless_e2e.rs@@ -1,7 +1,7 @@//! A one-shot compiled CLI call waits for its registered async child and//! reports child failure as a failed call.-use serde_json::{Value, json};+use serde_json::{json, Value};use std::fs::File;use std::net::TcpListener;use std::path::{Path, PathBuf};