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(tools): move shell timeout helpers to tinytools-std
Steven Enamakel8a6181f6e9ed
diff --git a/Cargo.lock b/Cargo.lockindex d7aadcddde..5f2c098f4d 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4740,6 +4740,7 @@ dependencies = ["tinymemory-api","tinymemory-tools","tinytools",+ "tinytools-std","tokio","tokio-stream","tracing-subscriber",diff --git a/crates/openhuman-core/src/agent/platform_shell.rs b/crates/openhuman-core/src/agent/platform_shell.rsindex f71533b6d5..60af183e76 100644--- a/crates/openhuman-core/src/agent/platform_shell.rs+++ b/crates/openhuman-core/src/agent/platform_shell.rs@@ -197,10 +197,10 @@ fn build_tokio_command_with(command: &str, pipefail: PipeFail) -> tokio::processconfigure_shell_args(cmd.as_std_mut(), command, pipefail);// Every shell-family child leads its own process group and dies with the// handle that owns it, so a deadline (see- // `crate::tools::timeout::output_or_kill`) or a cancelled future cannot+ // `tinytools_std::timeout::output_or_kill`) or a cancelled future cannot// leave a pipeline running behind the tool that reported it finished.cmd.kill_on_drop(true);- crate::tools::timeout::own_process_group(cmd.as_std_mut());+ tinytools_std::timeout::own_process_group(cmd.as_std_mut());cmd}@@ -221,8 +221,8 @@ fn build_std_command_with(command: &str, pipefail: PipeFail) -> std::process::Coconfigure_shell_args(&mut cmd, command, pipefail);// Same contract as the tokio builder: the child leads its own process// group so a deadline can reach the whole pipeline (see- // `crate::tools::timeout::kill_process_group`).- crate::tools::timeout::own_process_group(&mut cmd);+ // `tinytools_std::timeout::kill_process_group`).+ tinytools_std::timeout::own_process_group(&mut cmd);cmd}diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/shell_turn_budget.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/shell_turn_budget.rsindex 8022e7b91e..4779f90f2f 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/shell_turn_budget.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/shell_turn_budget.rs@@ -91,7 +91,7 @@ pub(crate) fn clamp_shell_timeout(.saturating_sub(SHELL_TIMEOUT_RESERVE).max(remaining / 2).as_secs()- .clamp(1, crate::tools::timeout::MAX_TIMEOUT_SECS);+ .clamp(1, tinytools_std::timeout::MAX_TIMEOUT_SECS);if requested.is_some_and(|secs| secs <= cap) {return None;}diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/shell_turn_budget_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/shell_turn_budget_tests.rsindex 36a89a2aad..f4fbf74ab5 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/shell_turn_budget_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/shell_turn_budget_tests.rs@@ -38,7 +38,7 @@ fn an_unbounded_command_gets_the_turn_remainder_as_its_deadline() {#[test]fn injected_timeout_never_exceeds_the_shell_schema_maximum() {let clamp = clamp_shell_timeout(None, SECS(7_200)).expect("unbounded is clamped");- assert_eq!(clamp.clamped_secs, crate::tools::timeout::MAX_TIMEOUT_SECS);+ assert_eq!(clamp.clamped_secs, tinytools_std::timeout::MAX_TIMEOUT_SECS);}#[test]diff --git a/crates/openhuman-core/src/config/ops/agent.rs b/crates/openhuman-core/src/config/ops/agent.rsindex a21c41b671..165d30ee39 100644--- a/crates/openhuman-core/src/config/ops/agent.rs+++ b/crates/openhuman-core/src/config/ops/agent.rs@@ -203,7 +203,7 @@ pub async fn apply_agent_settings(config: &mut Config,update: AgentSettingsPatch,) -> Result<Outcome<serde_json::Value>, String> {- use crate::tools::timeout::{MAX_TIMEOUT_SECS, MIN_TIMEOUT_SECS};+ use tinytools_std::timeout::{MAX_TIMEOUT_SECS, MIN_TIMEOUT_SECS};if let Some(timeout_secs) = update.agent_timeout_secs {if !(MIN_TIMEOUT_SECS..=MAX_TIMEOUT_SECS).contains(&timeout_secs) {@@ -281,8 +281,8 @@ pub async fn get_agent_settings() -> Result<Outcome<serde_json::Value>, String>"agent_timeout_secs": config.agent.agent_timeout_secs,"effective_timeout_secs": crate::tools::timeout::tool_execution_timeout_secs(),"env_override": crate::tools::timeout::env_override_active(),- "min_timeout_secs": crate::tools::timeout::MIN_TIMEOUT_SECS,- "max_timeout_secs": crate::tools::timeout::MAX_TIMEOUT_SECS,+ "min_timeout_secs": tinytools_std::timeout::MIN_TIMEOUT_SECS,+ "max_timeout_secs": tinytools_std::timeout::MAX_TIMEOUT_SECS,"tool_dispatcher": config.agent.tool_dispatcher,"tool_dispatcher_env_override": td::tool_dispatcher_env_override(),});diff --git a/crates/openhuman-core/src/config/schema/agent.rs b/crates/openhuman-core/src/config/schema/agent.rsindex 28015f078c..504364a91b 100644--- a/crates/openhuman-core/src/config/schema/agent.rs+++ b/crates/openhuman-core/src/config/schema/agent.rs@@ -387,7 +387,7 @@ fn default_tool_result_budget_bytes() -> usize {}fn default_agent_timeout_secs() -> u64 {- crate::tools::timeout::DEFAULT_TIMEOUT_SECS+ tinytools_std::timeout::DEFAULT_TIMEOUT_SECS}fn default_agent_max_tool_iterations() -> usize {diff --git a/crates/openhuman-core/src/modules/search/proxy.rs b/crates/openhuman-core/src/modules/search/proxy.rsindex bd9adde7d3..3932ca3a3b 100644--- a/crates/openhuman-core/src/modules/search/proxy.rs+++ b/crates/openhuman-core/src/modules/search/proxy.rs@@ -29,7 +29,7 @@ use crate::config::Config;/// one after another; both routinely exceeded 30 s in production and came back/// as a bus timeout although the module was still working. 90 s stays under/// the harness's own default tool deadline-/// ([`crate::tools::timeout::DEFAULT_TIMEOUT_SECS`], 120 s), so the module's+/// ([`tinytools_std::timeout::DEFAULT_TIMEOUT_SECS`], 120 s), so the module's/// answer, not the harness kill, decides the result. This is the floor; a/// larger configured tool budget extends it (see [`execute_tool_timeout_for`]).pub(super) const EXECUTE_TOOL_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(90);diff --git a/crates/openhuman-core/src/modules/search/proxy_tests.rs b/crates/openhuman-core/src/modules/search/proxy_tests.rsindex 9399b0342c..68d96c3713 100644--- a/crates/openhuman-core/src/modules/search/proxy_tests.rs+++ b/crates/openhuman-core/src/modules/search/proxy_tests.rs@@ -125,7 +125,7 @@ async fn execute_tool_outlives_the_bus_default_timeout() {fn the_execute_tool_deadline_stays_under_the_harness_tool_deadline() {assert!(EXECUTE_TOOL_TIMEOUT > tinybus::connection::DEFAULT_TIMEOUT);assert!(- EXECUTE_TOOL_TIMEOUT.as_secs() < crate::tools::timeout::DEFAULT_TIMEOUT_SECS,+ EXECUTE_TOOL_TIMEOUT.as_secs() < tinytools_std::timeout::DEFAULT_TIMEOUT_SECS,"the harness would kill the call before the module could answer");}@@ -142,7 +142,7 @@ fn the_execute_tool_deadline_follows_a_raised_tool_budget() {// The default budget keeps today's 90 s, and a tighter budget never drops// the bus deadline below the floor (the harness deadline is tighter).assert_eq!(- execute_tool_timeout_for(crate::tools::timeout::DEFAULT_TIMEOUT_SECS),+ execute_tool_timeout_for(tinytools_std::timeout::DEFAULT_TIMEOUT_SECS),EXECUTE_TOOL_TIMEOUT);assert_eq!(execute_tool_timeout_for(10), EXECUTE_TOOL_TIMEOUT);diff --git a/crates/openhuman-core/src/sandbox/ops.rs b/crates/openhuman-core/src/sandbox/ops.rsindex bdaac78d0c..99ee979244 100644--- a/crates/openhuman-core/src/sandbox/ops.rs+++ b/crates/openhuman-core/src/sandbox/ops.rs@@ -459,7 +459,7 @@ async fn execute_unsandboxed(cmd.env(k, v);}- let result = crate::tools::timeout::output_or_kill(&mut cmd, timeout).await;+ let result = tinytools_std::timeout::output_or_kill(&mut cmd, timeout).await;match result {Ok(Ok(output)) => Ok(SandboxExecResult {exit_code: output.status.code().unwrap_or(-1),diff --git a/crates/openhuman-core/src/tools/impl/system/install_tool.rs b/crates/openhuman-core/src/tools/impl/system/install_tool.rsindex b2a97422a0..9544a5998c 100644--- a/crates/openhuman-core/src/tools/impl/system/install_tool.rs+++ b/crates/openhuman-core/src/tools/impl/system/install_tool.rs@@ -198,7 +198,7 @@ impl Tool for InstallToolTool {cmd.args(&prefix).arg(package);cmd.current_dir(&self.security.workspace_dir);- let output = match crate::tools::timeout::output_or_kill(+ let output = match tinytools_std::timeout::output_or_kill(&mut cmd,Duration::from_secs(INSTALL_TIMEOUT_SECS),)diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rsindex 3285c8d8e7..2ffb3f9a45 100644--- a/crates/openhuman-core/src/tools/impl/system/shell.rs+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs@@ -175,11 +175,11 @@ impl ShellTool {/// deadline applies only when the caller passes `timeout_secs` (issue/// #4023). A `0` explicitly disables it. Any positive value is clamped to/// `1..=3600`. See- /// [`crate::tools::timeout::explicit_call_timeout_duration`].+ /// [`tinytools_std::timeout::explicit_call_timeout_duration`].fn explicit_timeout(&self, requested: Option<u64>) -> Option<Duration> {- crate::tools::timeout::explicit_call_timeout_duration(+ tinytools_std::timeout::explicit_call_timeout_duration(requested,- crate::tools::timeout::MAX_TIMEOUT_SECS,+ tinytools_std::timeout::MAX_TIMEOUT_SECS,)}}@@ -498,7 +498,7 @@ impl ShellTool {}let mut env = std::collections::BTreeMap::new();- for (name, value) in shell_child_env(crate::tools::timeout::CommandEnvironment::var_os)+ for (name, value) in shell_child_env(tinytools_std::timeout::CommandEnvironment::var_os){let Ok(value) = value.into_string() else {return (@@ -555,7 +555,7 @@ impl ShellTool {};cmd.env_clear();- for (var, val) in shell_child_env(crate::tools::timeout::CommandEnvironment::var_os) {+ for (var, val) in shell_child_env(tinytools_std::timeout::CommandEnvironment::var_os) {cmd.env(var, val);}@@ -595,8 +595,8 @@ impl ShellTool {if explicit_timeout.is_some() { "explicit" } else { "no" });let result = match explicit_timeout {- Some(timeout) => crate::tools::timeout::output_or_kill(&mut cmd, timeout).await,- None => Ok(crate::tools::timeout::output_unbounded(&mut cmd).await),+ Some(timeout) => tinytools_std::timeout::output_or_kill(&mut cmd, timeout).await,+ None => Ok(tinytools_std::timeout::output_unbounded(&mut cmd).await),};let tool_result = match result {@@ -687,7 +687,7 @@ impl ShellTool {// long command isn't killed while still bounding a wedged sandbox.let explicit_timeout = self.explicit_timeout(requested_timeout);let effective = explicit_timeout.unwrap_or_else(|| {- Duration::from_secs(crate::tools::timeout::SANDBOX_UNBOUNDED_CAP_SECS)+ Duration::from_secs(tinytools_std::timeout::SANDBOX_UNBOUNDED_CAP_SECS)});tracing::debug!(timeout_secs = effective.as_secs(),diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rsindex 83b9db21e8..ae1c9ee846 100644--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs@@ -296,7 +296,7 @@ fn shell_timeout_honors_explicit_per_call_value() {// Above the cap clamps down to MAX_TIMEOUT_SECS (3600).assert_eq!(tool.explicit_timeout(Some(9_999)),- Some(Duration::from_secs(crate::tools::timeout::MAX_TIMEOUT_SECS))+ Some(Duration::from_secs(tinytools_std::timeout::MAX_TIMEOUT_SECS)));}diff --git a/crates/openhuman-embed/Cargo.toml b/crates/openhuman-embed/Cargo.tomlindex f059ec056c..641227d0a5 100644--- a/crates/openhuman-embed/Cargo.toml+++ b/crates/openhuman-embed/Cargo.toml@@ -91,6 +91,7 @@ tinyinference-embeddings = { path = "../../vendor/tinyagents/vendor/tinyinferenc# path as the core's so the trait unifies.# `AgentDefinitionSpec::tool_rules` takes the shared tool-rule vocabulary too.tinytools = { path = "../../vendor/tinyagents/vendor/tinytools/crates/tinytools" }+tinytools-std = { path = "../../vendor/tinyagents/vendor/tinytools/crates/tinytools-std" }tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }url = "2"uuid = { version = "1", features = ["v4"] }diff --git a/crates/openhuman-embed/src/process.rs b/crates/openhuman-embed/src/process.rsindex a76ac2b9f9..e440c5f0a8 100644--- a/crates/openhuman-embed/src/process.rs+++ b/crates/openhuman-embed/src/process.rs@@ -13,7 +13,7 @@ pub use openhuman_core::core::runtime::{AGENT_WORKER_STACK_BYTES, MAX_BLOCKING_T/// Scoped ownership for host commands outside an agent turn. After dropping/// the scoped future, await `wait()` before acknowledging cancellation.-pub use openhuman_core::tools::timeout::ProcessCleanup as CommandCleanup;+pub use tinytools_std::timeout::ProcessCleanup as CommandCleanup;/// Sentry options and event scrubbing shared by desktop and terminal hosts.#[cfg(feature = "crash-reporting")]@@ -118,11 +118,11 @@ pub async fn command_output(input: Vec<u8>,deadline: std::time::Duration,) -> std::io::Result<std::process::Output> {- let cleanup = openhuman_core::tools::timeout::ProcessCleanup::default();+ let cleanup = tinytools_std::timeout::ProcessCleanup::default();let result = cleanup.scope(tokio::time::timeout(deadline,- openhuman_core::tools::timeout::output_with_input(command, Some(input)),+ tinytools_std::timeout::output_with_input(command, Some(input)),)).await;cleanup.wait().await;diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rsindex e3fedd4f9d..dd569f07b7 100644--- a/crates/openhuman-embed/src/turn.rs+++ b/crates/openhuman-embed/src/turn.rs@@ -90,7 +90,7 @@ pub struct Turn {trace_content: crate::observe::TraceContent,hooks: openhuman_core::agent::hooks::HookScope,tools: Option<openhuman_core::agent::HostTools>,- tool_env: Option<openhuman_core::tools::timeout::CommandEnvironment>,+ tool_env: Option<tinytools_std::timeout::CommandEnvironment>,}impl Turn {@@ -161,7 +161,7 @@ impl Turn {/// Interpreter pools are bypassed so a pooled process cannot carry another/// turn's environment. Independently spawned host tasks must carry the scope.pub fn tool_env(mut self, env: impl IntoIterator<Item = (String, String)>) -> Self {- self.tool_env = Some(openhuman_core::tools::timeout::CommandEnvironment::new(env));+ self.tool_env = Some(tinytools_std::timeout::CommandEnvironment::new(env));self}diff --git a/crates/openhuman-embed/src/turn_cancellation.rs b/crates/openhuman-embed/src/turn_cancellation.rsindex d8da22f817..1ff2b8e877 100644--- a/crates/openhuman-embed/src/turn_cancellation.rs+++ b/crates/openhuman-embed/src/turn_cancellation.rs@@ -2,7 +2,7 @@use std::sync::Arc;-use openhuman_core::tools::timeout::ProcessCleanup;+use tinytools_std::timeout::ProcessCleanup;use tokio::sync::watch;#[derive(Clone, Copy, PartialEq, Eq)]diff --git a/crates/openhuman-embed/tests/process_cancellation.rs b/crates/openhuman-embed/tests/process_cancellation.rsindex 36f4078bdd..7bbf983eb7 100644--- a/crates/openhuman-embed/tests/process_cancellation.rs+++ b/crates/openhuman-embed/tests/process_cancellation.rs@@ -2,7 +2,7 @@#![cfg(target_os = "linux")]-use openhuman_core::tools::timeout::{output_or_kill, output_unbounded, ProcessCleanup};+use tinytools_std::timeout::{output_or_kill, output_unbounded, ProcessCleanup};use std::time::Duration;/// Cancelling a tool must also stop descendants of its shell.diff --git a/crates/openhuman-embed/tests/tool_environment.rs b/crates/openhuman-embed/tests/tool_environment.rsindex 9ac96036f5..595c74eb1a 100644--- a/crates/openhuman-embed/tests/tool_environment.rs+++ b/crates/openhuman-embed/tests/tool_environment.rs@@ -2,7 +2,7 @@#![cfg(unix)]-use openhuman_core::tools::timeout::{output_unbounded, CommandEnvironment};+use tinytools_std::timeout::{output_unbounded, CommandEnvironment};#[tokio::test]async fn overlapping_command_environments_replace_inheritance_without_crossing_turns() {diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rsindex 1198ccde7e..8c6601146e 100644--- a/tests/json_rpc_e2e.rs+++ b/tests/json_rpc_e2e.rs@@ -10088,7 +10088,7 @@ async fn json_rpc_config_agent_timeout_settings_roundtrip() {// Restore the process-global timeout so later tests in this binary don't// inherit the 300s value set above (the AtomicU64 is per-process, not per-test).openhuman_core::tools::timeout::set_tool_timeout_secs(- openhuman_core::tools::timeout::DEFAULT_TIMEOUT_SECS,+ tinytools_std::timeout::DEFAULT_TIMEOUT_SECS,);mock_join.abort();