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
chore: files changed crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs,crates/ope
Steven Enamakel9c1df2a480e4
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rsindex 0d425b3753..9b190f4d30 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs@@ -94,7 +94,9 @@ impl OpenHumanSessionHost {);Some(jobs.retain_root_run_descendants(&root_config.run_id, owner)- .map_err(|error| anyhow::anyhow!("retain headless sub-agent results: {error}"))?,+ .map_err(|error| {+ anyhow::anyhow!("retain headless sub-agent results: {error}")+ })?,)} else {None@@ -199,7 +201,9 @@ impl OpenHumanSessionHost {for job in jobs {match job.status {tinyagents_orchestration::subagent::SubAgentJobStatus::Completed => {- if let Some(child_output) = job.output.filter(|text| !text.trim().is_empty()) {+ if let Some(child_output) =+ job.output.filter(|text| !text.trim().is_empty())+ {output.push_str("\n\n[Sub-agent result: ");output.push_str(&job.agent);output.push_str("]\n");diff --git a/crates/openhuman-core/src/core/cli.rs b/crates/openhuman-core/src/core/cli.rsindex 51fb661edf..99a08844ad 100644--- a/crates/openhuman-core/src/core/cli.rs+++ b/crates/openhuman-core/src/core/cli.rs@@ -422,13 +422,7 @@ fn run_call_command(args: &[String]) -> Result<()> {} else {dispatch};- invoke_method(- dispatch,- default_state(),- &method,- params,- )- .await+ invoke_method(dispatch, default_state(), &method, params).await}).map_err(anyhow::Error::msg)?;diff --git a/crates/openhuman-core/src/cron/scheduler/agent_run.rs b/crates/openhuman-core/src/cron/scheduler/agent_run.rsindex 604c5142f8..86041af22e 100644--- a/crates/openhuman-core/src/cron/scheduler/agent_run.rs+++ b/crates/openhuman-core/src/cron/scheduler/agent_run.rs@@ -171,9 +171,8 @@ pub(super) async fn run_agent_job_for_run(let deadline = tinyagents_harness::turn_deadline::TurnDeadline::starting_now(std::time::Duration::from_secs(timeout_secs),);- let absolute_deadline = tokio::time::Instant::from_std(- deadline.started() + deadline.backstop(),- );+ let absolute_deadline =+ tokio::time::Instant::from_std(deadline.started() + deadline.backstop());let mut host_env = agent.host_env().clone();host_env.turn_deadline = Some(deadline);agent.set_host_env(host_env);diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rsindex 70a17f3597..e357ae26c5 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs@@ -415,7 +415,8 @@ impl OpenHumanAgentRunner {let deadline = tinyagents_harness::turn_deadline::TurnDeadline::starting_now(std::time::Duration::from_secs(timeout_secs),);- let absolute_deadline = tokio::time::Instant::from_std(deadline.started() + deadline.backstop());+ let absolute_deadline =+ tokio::time::Instant::from_std(deadline.started() + deadline.backstop());let mut host_env = agent.host_env().clone();host_env.turn_deadline = Some(deadline);agent.set_host_env(host_env);@@ -483,32 +484,31 @@ impl OpenHumanAgentRunner {Some(context) => Box::pin(crate::core::runtime::CoreContext::scope(context, run)),None => run,};- let final_text =- match tokio::time::timeout_at(absolute_deadline, run).await {- Ok(Ok(text)) => text,- Ok(Err(e)) => {- tracing::warn!(- target: "flows",- agent_ref,- error = %e,- "[flows] agent_runner: harness turn failed"- );- return Err(EngineError::Capability(format!(- "agent node '{agent_ref}' turn failed: {e:#}"- )));- }- Err(_) => {- tracing::warn!(- target: "flows",- agent_ref,- timeout_secs,- "[flows] agent_runner: harness turn timed out"- );- return Err(EngineError::Capability(format!(- "agent node '{agent_ref}' timed out after {timeout_secs}s"- )));- }- };+ let final_text = match tokio::time::timeout_at(absolute_deadline, run).await {+ Ok(Ok(text)) => text,+ Ok(Err(e)) => {+ tracing::warn!(+ target: "flows",+ agent_ref,+ error = %e,+ "[flows] agent_runner: harness turn failed"+ );+ return Err(EngineError::Capability(format!(+ "agent node '{agent_ref}' turn failed: {e:#}"+ )));+ }+ Err(_) => {+ tracing::warn!(+ target: "flows",+ agent_ref,+ timeout_secs,+ "[flows] agent_runner: harness turn timed out"+ );+ return Err(EngineError::Capability(format!(+ "agent node '{agent_ref}' timed out after {timeout_secs}s"+ )));+ }+ };Ok(build_agent_result(agent_ref, &final_text, &request))}diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/agent_tests.rs b/crates/openhuman-core/src/flows/tinyflows/caps/agent_tests.rsindex 73d4c0bea0..c899fae76a 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/agent_tests.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/agent_tests.rs@@ -85,7 +85,11 @@ async fn headless_flow_agent_includes_its_spawned_child_result() {self.root_followup.notify_one();return Ok(ModelResponse::assistant("headless-flow-root-result"));}- if self.spawn_calls.fetch_add(1, std::sync::atomic::Ordering::SeqCst) > 0 {+ if self+ .spawn_calls+ .fetch_add(1, std::sync::atomic::Ordering::SeqCst)+ > 0+ {return Ok(ModelResponse::assistant("headless-flow-root-finished-without-accepted-child",));@@ -116,9 +120,8 @@ async fn headless_flow_agent_includes_its_spawned_child_result() {child_release: tokio::sync::Notify::new(),root_followup: tokio::sync::Notify::new(),});- let _model = crate::inference::provider::factory::test_provider_override::install_model(- model.clone(),- );+ let _model =+ crate::inference::provider::factory::test_provider_override::install_model(model.clone());let workspace = tempfile::tempdir().expect("flow workspace");let mut config = crate::config::Config::default();config.workspace_dir = workspace.path().to_path_buf();@@ -165,15 +168,16 @@ async fn headless_flow_agent_includes_its_spawned_child_result() {.await.expect("the real detached child reaches its model").expect("child-start observation remains connected");- tokio::time::timeout(std::time::Duration::from_secs(5), model.root_followup.notified())- .await- .expect("the parent receives spawn acceptance and produces its final response");+ tokio::time::timeout(+ std::time::Duration::from_secs(5),+ model.root_followup.notified(),+ )+ .await+ .expect("the parent receives spawn acceptance and produces its final response");tokio::task::yield_now().await;let returned_before_child = run.is_finished();model.child_release.notify_one();- let output = run- .await- .expect("flow runner task");+ let output = run.await.expect("flow runner task");let output = output.expect("headless flow agent should settle its child");assert_eq!(diff --git a/crates/openhuman-core/src/inference/host_runtime/ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops.rsindex a319ea9500..3d9c187267 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops.rs@@ -14,6 +14,7 @@ mod complete_once;mod runtime_ops;mod turn_guards;+pub(crate) use agent_chat::agent_chat_reply_for_with_headless;pub use agent_chat::{agent_chat, agent_chat_for, agent_chat_reply_for, agent_chat_simple, AgentChatEnv,AgentChatReply, AgentChatTarget,diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rsindex 595b7ee27d..7d3ea4bb52 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs@@ -366,6 +366,7 @@ pub fn agent_chat_for<'a>(route,env,None,+ false,).await.map(AgentChatReply::into_outcome)@@ -385,6 +386,34 @@ pub async fn agent_chat_reply_for(cwd: Option<String>,route: Option<crate::config::schema::EphemeralRoute>,env: AgentChatEnv,+) -> Result<AgentChatReply, String> {+ agent_chat_reply_for_with_headless(+ config,+ target,+ message,+ model_override,+ temperature,+ thread_id,+ cwd,+ route,+ env,+ false,+ )+ .await+}++#[allow(clippy::too_many_arguments)]+pub(crate) async fn agent_chat_reply_for_with_headless(+ config: &mut Config,+ target: AgentChatTarget<'_>,+ message: &str,+ model_override: Option<String>,+ temperature: Option<f64>,+ thread_id: Option<String>,+ cwd: Option<String>,+ route: Option<crate::config::schema::EphemeralRoute>,+ env: AgentChatEnv,+ headless: bool,) -> Result<AgentChatReply, String> {agent_chat_reply_for_inner(config,@@ -397,6 +426,7 @@ pub async fn agent_chat_reply_for(route,env,None,+ headless,).await}@@ -413,6 +443,7 @@ pub(super) async fn agent_chat_reply_for_inner(route: Option<crate::config::schema::EphemeralRoute>,env: AgentChatEnv,turn_model_source: Option<(crate::agent::tinyagents::TurnModelSource, String)>,+ headless: bool,) -> Result<AgentChatReply, String> {match target {AgentChatTarget::Definition {@@ -592,7 +623,20 @@ pub(super) async fn agent_chat_reply_for_inner(// The host environment of this turn (budget, cancellation, deadline, hooks,// tool-belt authority) rides the session explicitly.let approval = env.host.approval.clone();- agent.set_host_env(env.host);+ if headless {+ agent.enable_headless_descendant_settlement();+ }+ let mut host_env = env.host;+ if headless && host_env.turn_deadline.is_none() {+ host_env.turn_deadline = Some(+ tinyagents_harness::turn_deadline::TurnDeadline::starting_now(+ std::time::Duration::from_secs(+ tinyagents_harness::turn_deadline::DEFAULT_TURN_BACKSTOP_SECS,+ ),+ ),+ );+ }+ agent.set_host_env(host_env);if let Some(queue) = env.run_queue {log::debug!("[inference] agent_chat attached a run queue for mid-turn steering");agent.set_run_queue(Some(queue));diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_source.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_source.rsindex 91d90444e1..4380ece797 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_source.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_source.rs@@ -30,6 +30,7 @@ pub(crate) fn agent_chat_for_with_turn_model_source<'a>(route,env,Some(turn_model_source),+ false,).await.map(AgentChatReply::into_outcome)diff --git a/crates/openhuman-core/src/inference/host_runtime/schemas.rs b/crates/openhuman-core/src/inference/host_runtime/schemas.rsindex 8c91880ca9..412f74a1bf 100644--- a/crates/openhuman-core/src/inference/host_runtime/schemas.rs+++ b/crates/openhuman-core/src/inference/host_runtime/schemas.rs@@ -232,7 +232,8 @@ fn handle_agent_chat(ctx: DispatchCtx, params: Map<String, Value>) -> Controller}_ => crate::inference::host_runtime::ops::AgentChatTarget::Orchestrator,};- crate::inference::host_runtime::ops::agent_chat_reply_for(+ let headless = ctx.is_headless_agent_chat();+ crate::inference::host_runtime::ops::agent_chat_reply_for_with_headless(&mut config,target,&p.message,@@ -243,6 +244,7 @@ fn handle_agent_chat(ctx: DispatchCtx, params: Map<String, Value>) -> Controllercrate::config::schema::EphemeralRoute::from_params(p.inference_url, p.api_key).map(|route| route.with_headers(p.inference_headers)),crate::inference::host_runtime::ops::AgentChatEnv::default(),+ headless,).await?.into_rpc_json()