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(agent): update context handling in subagent host
Steven Enamakel200d548c0747
diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rsindex f3148ababf..b508ee7a39 100644--- a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs@@ -64,8 +64,8 @@ pub struct HostTurnTools {pub policy: Option<Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<- crate::agent::tinyagents::host::OpenHumanRunContext,- >,+ crate::agent::tinyagents::host::OpenHumanRunContext,+ >,>,>,}@@ -180,8 +180,8 @@ impl HostTurnTools {mut self,policy: Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<- crate::agent::tinyagents::host::OpenHumanRunContext,- >,+ crate::agent::tinyagents::host::OpenHumanRunContext,+ >,>,) -> Self {self.policy = Some(policy);@@ -205,8 +205,8 @@ pub(super) struct MergedHostTurnTools {pub policy: Option<Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<- crate::agent::tinyagents::host::OpenHumanRunContext,- >,+ crate::agent::tinyagents::host::OpenHumanRunContext,+ >,>,>,pub withheld: HashSet<String>,diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rsindex c83c3d1148..f1ecef0693 100644--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs@@ -386,8 +386,8 @@ impl SessionHostBuilder {mut self,policy: Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<- crate::agent::tinyagents::host::OpenHumanRunContext,- >,+ crate::agent::tinyagents::host::OpenHumanRunContext,+ >,>,) -> Self {self.tool_policy = Some(policy);diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rsindex e19473dd9d..beff53cb02 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs@@ -85,13 +85,13 @@ pub(crate) async fn spawn_async_via_driver_tool(input: String,options: SubagentRunOptions,completion: impl Fn(- String,- Result<SubagentRunOutcome, String>,- bool,- ) -> Pin<Box<dyn Future<Output = ()> + Send>>- + Send- + Sync- + 'static,+ String,+ Result<SubagentRunOutcome, String>,+ bool,+ ) -> Pin<Box<dyn Future<Output = ()> + Send>>+ + Send+ + Sync+ + 'static,) -> Result<String, SubagentRunError> {spawn_async_via_driver_tool_using_jobs(parent, definition, input, options, None, None, completion,@@ -109,13 +109,13 @@ pub(crate) async fn resume_async_via_driver_tool(input: String,options: SubagentRunOptions,completion: impl Fn(- String,- Result<SubagentRunOutcome, String>,- bool,- ) -> Pin<Box<dyn Future<Output = ()> + Send>>- + Send- + Sync- + 'static,+ String,+ Result<SubagentRunOutcome, String>,+ bool,+ ) -> Pin<Box<dyn Future<Output = ()> + Send>>+ + Send+ + Sync+ + 'static,) -> Result<String, SubagentRunError> {spawn_async_via_driver_tool_using_jobs(parent,@@ -137,13 +137,13 @@ pub(crate) async fn spawn_async_via_driver_tool_with_jobs(options: SubagentRunOptions,jobs: tinyagents_harness_tools::subagents::SubAgentJobRegistry,completion: impl Fn(- String,- Result<SubagentRunOutcome, String>,- bool,- ) -> Pin<Box<dyn Future<Output = ()> + Send>>- + Send- + Sync- + 'static,+ String,+ Result<SubagentRunOutcome, String>,+ bool,+ ) -> Pin<Box<dyn Future<Output = ()> + Send>>+ + Send+ + Sync+ + 'static,) -> Result<String, SubagentRunError> {spawn_async_via_driver_tool_using_jobs(parent,@@ -165,13 +165,13 @@ async fn spawn_async_via_driver_tool_using_jobs(jobs: Option<tinyagents_harness_tools::subagents::SubAgentJobRegistry>,continuation: Option<(SubagentTaskKey, SubagentResume)>,completion: impl Fn(- String,- Result<SubagentRunOutcome, String>,- bool,- ) -> Pin<Box<dyn Future<Output = ()> + Send>>- + Send- + Sync- + 'static,+ String,+ Result<SubagentRunOutcome, String>,+ bool,+ ) -> Pin<Box<dyn Future<Output = ()> + Send>>+ + Send+ + Sync+ + 'static,) -> Result<String, SubagentRunError> {let task_id = continuation.as_ref()diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rsindex cb804dd7b6..92acaf8c55 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs@@ -6,8 +6,8 @@ use tinyagents_orchestration::subagent::{};use super::lifecycle::{- OpenHumanDriverBundle, OpenHumanPersistence, decode_driver_job_result,- load_subagent_checkpoint, merged_resume_history,+ decode_driver_job_result, load_subagent_checkpoint, merged_resume_history,+ OpenHumanDriverBundle, OpenHumanPersistence,};use super::{SubagentMode, SubagentRunError, SubagentRunOutcome, SubagentRunStatus, SubagentUsage};@@ -100,11 +100,9 @@ fn driver_error_does_not_hide_completed_mismatched_or_persistence_failures() {tinytools::ToolResult::error("provider transport failed"),] {let error = decode_driver_job_result(result, &bundle, &task_key).unwrap_err();- assert!(- error- .to_string()- .contains("driver-backed async spawn failed")- );+ assert!(error+ .to_string()+ .contains("driver-backed async spawn failed"));}bundle.failures.lock().unwrap().insert(@@ -130,11 +128,9 @@ fn driver_error_does_not_hide_completed_mismatched_or_persistence_failures() {&task_key,).unwrap_err();- assert!(- error- .to_string()- .contains("driver-backed async spawn failed")- );+ assert!(error+ .to_string()+ .contains("driver-backed async spawn failed"));bundle.host_outcome.lock().unwrap().insert(task_key.clone(),@@ -339,12 +335,11 @@ async fn tiny_session_port_recovers_legacy_key_from_owned_pause_and_hides_foreig.unwrap();assert_eq!(owned.len(), 1);assert_eq!(owned[0].lifecycle_key, Some(key));- assert!(- port.list_for_parent("foreign-session", Some("thread"))- .await- .unwrap()- .is_empty()- );+ assert!(port+ .list_for_parent("foreign-session", Some("thread"))+ .await+ .unwrap()+ .is_empty());}#[tokio::test]diff --git a/crates/openhuman-core/src/agent/subagent_host/mod.rs b/crates/openhuman-core/src/agent/subagent_host/mod.rsindex af10fedd01..f4512efb7a 100644--- a/crates/openhuman-core/src/agent/subagent_host/mod.rs+++ b/crates/openhuman-core/src/agent/subagent_host/mod.rs@@ -56,7 +56,6 @@ mod persisted_compat_tests;// Public API — the entry point and the shapes it returns.pub use autonomous::{definition_iter_cap, subagent_iter_cap_with_autonomous_lift};-pub use lifecycle::OpenHumanSubagentHost;pub(crate) use lifecycle::checkpoint_resume;pub(crate) use lifecycle::detached_subagent_parent;pub(crate) use lifecycle::load_subagent_checkpoint;@@ -65,6 +64,7 @@ pub(crate) use lifecycle::resume_async_via_driver_tool;pub(crate) use lifecycle::spawn_async_via_driver_tool;#[cfg(test)]pub(crate) use lifecycle::spawn_async_via_driver_tool_with_jobs;+pub use lifecycle::OpenHumanSubagentHost;pub use types::{SubagentCheckpointData, SubagentMode, SubagentRunError, SubagentRunOptions, SubagentRunOutcome,SubagentRunStatus, SubagentUsage,diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex dc15f8a783..b6a66d052a 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -23,8 +23,8 @@ use crate::agent::subagent_host::types::{use crate::agent::tinyagents::budget::MAX_SPAWN_DEPTH;use crate::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};use crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS;-use tinyagents_definition::{AgentTier, IterationPolicy, PromptSource, validate_tier_transition};-use tinyagents_harness::context::{RunConfig, RunDepth, current_run_depth, with_run_depth};+use tinyagents_definition::{validate_tier_transition, AgentTier, IterationPolicy, PromptSource};+use tinyagents_harness::context::{current_run_depth, with_run_depth, RunConfig, RunDepth};use tinytools::ToolSpec;use tinytools_std::file_state::with_file_state_agent_id;diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests_driver_bridge_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests_driver_bridge_tests.rsindex 0e56700798..cd68d58528 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_driver_bridge_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_driver_bridge_tests.rs@@ -1,5 +1,5 @@use super::*;-use crate::agent::subagent_host::{SubagentRunStatus, spawn_async_via_driver_tool_with_jobs};+use crate::agent::subagent_host::{spawn_async_via_driver_tool_with_jobs, SubagentRunStatus};#[tokio::test]async fn prepared_subagent_runs_through_driver_jobs_dispatcher() {@@ -251,12 +251,10 @@ async fn independent_host_bundles_share_and_project_the_persisted_winner() {!leader.final_history.is_empty(),"winner history is preserved");- assert!(- leader- .final_history- .iter()- .any(|row| { row.role == "tool" && row.tool_call_id.as_deref() == Some("call-1") })- );+ assert!(leader+ .final_history+ .iter()+ .any(|row| { row.role == "tool" && row.tool_call_id.as_deref() == Some("call-1") }));assert_eq!(leader.usage.input_tokens, follower.usage.input_tokens);assert!(leader.usage.input_tokens > 0, "winner usage is preserved");assert_eq!(leader.artifact_paths, follower.artifact_paths);@@ -403,21 +401,19 @@ async fn closing_a_durable_driver_session_cancels_only_its_registered_child() {);let owner_scope: std::sync::Arc<dyn Fn(u64) -> String + Send + Sync> =std::sync::Arc::new(move |_| owner.clone());- assert!(- port.close("close-driver-session")- .await- .expect("Tiny close adapter cancels then closes the durable row")- );+ assert!(port+ .close("close-driver-session")+ .await+ .expect("Tiny close adapter cancels then closes the durable row"));assert_eq!(jobs.get(job_id.as_str()).unwrap().status,SubAgentJobStatus::Running,"the job remains visible while cooperative cancellation unwinds");- assert!(- port.close("close-driver-session")- .await- .expect("repeated close is idempotent without re-cancelling")- );+ assert!(port+ .close("close-driver-session")+ .await+ .expect("repeated close is idempotent without re-cancelling"));assert!(!parent_cancellation.is_cancelled(), "parent stays live");let tiny_store: std::sync::Arc<dyn TinySessionStore> = std::sync::Arc::new(port.clone());diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rsindex bf320bd6c8..e179fd08cd 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs@@ -1,5 +1,5 @@use super::*;-use tinyagents_harness::context::{RunDepth, current_run_depth, with_run_depth};+use tinyagents_harness::context::{current_run_depth, with_run_depth, RunDepth};struct BlockingSubagentCloseTool {started: tokio::sync::mpsc::Sender<()>,diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rsindex 3e4b9d785f..213f31e98b 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs@@ -1,5 +1,5 @@use super::*;-use tinyagents_harness::context::{RunDepth, current_run_depth, with_run_depth};+use tinyagents_harness::context::{current_run_depth, with_run_depth, RunDepth};#[test]fn filter_named_scope_keeps_only_named() {@@ -125,16 +125,12 @@ async fn typed_mode_system_prompt_includes_subagent_role_contract() {.iter().find(|m| m.role == "system").expect("system message should be present");- assert!(- system_msg- .content- .contains("You are a subagent (depth 1) working for a parent agent, not the end user.")- );- assert!(- system_msg- .content- .contains("Your assignment: the actual task prompt")- );+ assert!(system_msg+ .content+ .contains("You are a subagent (depth 1) working for a parent agent, not the end user."));+ assert!(system_msg+ .content+ .contains("Your assignment: the actual task prompt"));for heading in ["Answer","Evidence used",@@ -148,11 +144,9 @@ async fn typed_mode_system_prompt_includes_subagent_role_contract() {"missing {heading} heading");}- assert!(- system_msg.content.contains(- "Do not state unsupported facts; disclose truncated or partial tool results."- )- );+ assert!(system_msg+ .content+ .contains("Do not state unsupported facts; disclose truncated or partial tool results."));}#[tokio::test]diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests_trace_export_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests_trace_export_tests.rsindex e0615a16bd..78706dcc9b 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_trace_export_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_trace_export_tests.rs@@ -1,5 +1,5 @@use super::*;-use crate::agent::subagent_host::{SubagentRunStatus, spawn_async_via_driver_tool_with_jobs};+use crate::agent::subagent_host::{spawn_async_via_driver_tool_with_jobs, SubagentRunStatus};/// The native journal tree must preserve the exact run identity handed to the/// prepared child by Tiny's driver, including the host lifecycle link and the@@ -9,7 +9,7 @@ use crate::agent::subagent_host::{SubagentRunStatus, spawn_async_via_driver_toolasync fn prepared_child_run_is_exported_from_its_native_journal_lineage() {use tinyagents_harness::events::AgentEvent;use tinyagents_harness::observability::trace_export::{- TraceContext, collector::SpanCollector, serialize::spans_to_ndjson,+ collector::SpanCollector, serialize::spans_to_ndjson, TraceContext,};let scratch = tempfile::tempdir().expect("isolated native trace fixture");@@ -246,11 +246,9 @@ async fn prepared_child_run_is_exported_from_its_native_journal_lineage() {.expect("native projection preserves the provider-reported charge");assert_eq!(generation.attributes["gen_ai.usage.input_tokens"], 120);assert_eq!(generation.attributes["gen_ai.usage.output_tokens"], 8);- assert!(- generation- .attributes- .contains_key("gen_ai.pricing.input_per_mtok_usd")- );+ assert!(generation+ .attributes+ .contains_key("gen_ai.pricing.input_per_mtok_usd"));let exported = spans_to_ndjson(tinyagents_harness::observability::trace_export::serialize::SpanEnvelope::Otel,spans,diff --git a/crates/openhuman-core/src/triage/escalation_model_tests.rs b/crates/openhuman-core/src/triage/escalation_model_tests.rsindex 7a73810864..d6e66c08f4 100644--- a/crates/openhuman-core/src/triage/escalation_model_tests.rs+++ b/crates/openhuman-core/src/triage/escalation_model_tests.rs@@ -497,7 +497,7 @@ async fn escalate_dispatch_preserves_orchestrator_tools_without_child_delegation.iter().map(|tool| tool.name.as_str()).collect();- assert!(tool_names.contains(&"file_read"));+ assert!(tool_names.contains(&"grep"), "the orchestrator keeps its advertised coding tool");assert!(!tool_names.iter()