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(subagent_host): report cancelled delegate runs as cancelled
Steven Enamakelf31fb6e1c40a
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_tests.rsindex 991192fb1b..a519c9c89f 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_tests.rs@@ -21,6 +21,8 @@ struct BlockingDelegationTool {started: tokio::sync::mpsc::Sender<()>,}+struct FailingDelegationTool;+#[async_trait]impl Tool for BlockingDelegationTool {fn name(&self) -> &str {@@ -39,6 +41,24 @@ impl Tool for BlockingDelegationTool {}}+#[async_trait]+impl Tool for FailingDelegationTool {+ fn name(&self) -> &str {+ "delegate"+ }+ fn description(&self) -> &str {+ "configured delegate that returns a product error"+ }+ fn parameters_schema(&self) -> serde_json::Value {+ serde_json::json!({})+ }+ async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<tinytools::ToolResult> {+ Ok(tinytools::ToolResult::error(+ "configured policy rejected the request",+ ))+ }+}+#[async_trait]impl Tool for DelegationRegistrationTool {fn name(&self) -> &str {@@ -174,6 +194,37 @@ async fn config_delegate_dispatch_honours_the_parent_cancellation_token() {);}+#[tokio::test]+async fn config_delegate_dispatch_preserves_tool_failure_in_shared_jobs() {+ let dispatch = DelegateToolDispatch::new(Arc::new(FailingDelegationTool));+ let parent = crate::agent::tinyagents::host::OpenHumanRunContext::new()+ .into_tinyagents(RunConfig::new("config-delegate-error-parent"));+ let jobs = crate::core::runtime::slot_for::<+ tinyagents_orchestration::subagent::SubAgentJobRegistry,+ >(&parent.data.dispatch_ctx());++ let result = dispatch+ .execute(+ &(),+ tinyagents_harness::CallId::new("configured-error-call"),+ serde_json::json!({"agent": "configured-error", "prompt": "work"}),+ tinytools::ToolCallOptions::default(),+ &parent,+ )+ .await+ .expect("the host returns the configured tool result");++ assert!(result.is_error);+ assert!(result.output().contains("configured policy rejected the request"));+ assert!(jobs.list().iter().any(|job| {+ job.agent == "configured-error"+ && job.status == tinyagents_orchestration::subagent::SubAgentJobStatus::Incomplete+ && job.error.as_deref().is_some_and(|error| {+ error.contains("configured policy rejected the request")+ })+ }), "the registered job retains the configured product failure");+}+#[test]fn collapsed_dispatch_mapping_has_exact_advertised_vocabulary_and_rejects_drift() {let tool = CollapsedDelegationTool::for_targets(vec![diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rsindex 3a696f9e81..e910b01e30 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs@@ -1136,14 +1136,17 @@ impl SubagentExecutor<crate::agent::tinyagents::host::OpenHumanRunContext> for Olet cancellation = execution.cancellation.clone();let invoke = Box::pin(async move {tokio::select! {- _ = cancellation.cancelled() => Ok(tinytools::ToolResult::error(- "delegate: cancelled before the configured agent completed"- )),+ _ = cancellation.cancelled() => (+ Ok(tinytools::ToolResult::error(+ "delegate: cancelled before the configured agent completed"+ )),+ true,+ ),result = tool.execute_with_context(arguments,tinytools::ToolCallOptions::default(),Some(&tool_context),- ) => result,+ ) => (result, false),}});let result = match dispatch.into_core() {@@ -1156,9 +1159,11 @@ impl SubagentExecutor<crate::agent::tinyagents::host::OpenHumanRunContext> for ONone => invoke.await,};match result {- Ok(tool_result) => {+ Ok((tool_result, cancelled)) => {let output = tool_result.output();- let status = if tool_result.is_error {+ let status = if cancelled {+ SubagentRunStatus::Cancelled+ } else if tool_result.is_error {SubagentRunStatus::Incomplete {reason: "configured delegate reported failure".into(),}@@ -1192,7 +1197,9 @@ impl SubagentExecutor<crate::agent::tinyagents::host::OpenHumanRunContext> for Oneutral.extensions.insert("iterations".into(), serde_json::Value::Number(1.into()));- neutral.status = if tool_result.is_error {+ neutral.status = if cancelled {+ SubagentOutcomeKind::Cancelled+ } else if tool_result.is_error {SubagentOutcomeKind::Incomplete(SubagentIncomplete::new("configured delegate reported failure",))