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(dispatch): an unpersisted synchronous pause is a failure, not a caveat
M3gA-Mindd554a40c5893
diff --git a/src/openhuman/agent/orchestration/tools/dispatch.rs b/src/openhuman/agent/orchestration/tools/dispatch.rsindex 91d00baddc..360192da9b 100644--- a/src/openhuman/agent/orchestration/tools/dispatch.rs+++ b/src/openhuman/agent/orchestration/tools/dispatch.rs@@ -412,11 +412,33 @@ pub(crate) async fn dispatch_subagent(/// side-effect-free fn so the paused-path mapping is unit-testable without a/// registry or a real model — the #4291 regression guard. Synchronous delegate/// dispatch has no worker sub-thread, so `worker_thread_id` is always `None`.+///+/// **An unpersisted pause is a failure on this path, not a caveat.** The+/// envelope's "resuming may fail" wording is calibrated for the async path,+/// where a child that lost its checkpoint is still reachable through the+/// durable `subagent_sessions` store. This function serves the *synchronous*+/// delegation, which returns above before any durable session is registered+/// and has no worker thread by construction — so with no checkpoint there is+/// no resume route at all, and `continue_subagent` will find neither. Handing+/// back a success envelope would have the orchestrator put a question to the+/// user whose answer has nowhere to go, and the loss would only surface after+/// they answered. Report it as a failure instead, while the parent can still+/// act on it.fn awaiting_outcome_to_tool_result(outcome: &crate::openhuman::agent::harness::subagent_runner::SubagentRunOutcome,question: &str,checkpointed: bool,) -> ToolResult {+ if !checkpointed {+ return ToolResult::error(format!(+ "The sub-agent `{}` paused to ask a question, but its state could not be saved \+ and this delegation has no durable session to fall back on, so it cannot be \+ resumed. Its progress is lost. Tell the user what it was asking — \"{}\" — and \+ that the delegation has to be started again; do NOT call continue_subagent \+ with task_id `{}`, there is nothing for it to resume.",+ outcome.agent_id, question, outcome.task_id+ ));+ }ToolResult::success(super::awaiting_user::awaiting_user_envelope(&outcome.task_id,&outcome.agent_id,diff --git a/src/openhuman/agent/orchestration/tools/dispatch_tests.rs b/src/openhuman/agent/orchestration/tools/dispatch_tests.rsindex 6bf28a1fc3..56f15809cb 100644--- a/src/openhuman/agent/orchestration/tools/dispatch_tests.rs+++ b/src/openhuman/agent/orchestration/tools/dispatch_tests.rs@@ -105,3 +105,60 @@ fn subagent_failure_envelope_forbids_fabricated_success() {"preserves the root error: {msg}");}++/// An unpersisted pause on the **synchronous** delegation path is reported as a+/// failure, not as an awaiting-user envelope (#5951 review, Codex P2).+///+/// The distinction is not cosmetic. `awaiting_user_envelope`'s "resuming may+/// fail" caveat is calibrated for the async path, where a child that lost its+/// checkpoint is still reachable through the durable `subagent_sessions` store.+/// Synchronous dispatch returns before any durable session is registered and+/// carries no worker thread, so `checkpoint: None` there means there is no+/// resume route at all. A success envelope would have the orchestrator ask the+/// user a question whose answer is discarded.+#[test]+fn an_unpersisted_synchronous_pause_is_a_failure_not_an_awaiting_user_envelope() {+ use crate::openhuman::agent::harness::subagent_runner::{+ SubagentMode, SubagentRunOutcome, SubagentRunStatus, SubagentUsage,+ };+ use std::time::Duration;++ let question = "Which region should I deploy to?".to_string();+ let outcome = SubagentRunOutcome {+ task_id: "sub-lost1".to_string(),+ agent_id: "mcp_setup".to_string(),+ output: String::new(),+ iterations: 1,+ elapsed: Duration::from_secs(0),+ mode: SubagentMode::Typed,+ status: SubagentRunStatus::AwaitingUser {+ question: question.clone(),+ options: None,+ checkpoint: None,+ },+ final_history: Vec::new(),+ usage: SubagentUsage::default(),+ artifact_paths: Vec::new(),+ };++ let res = awaiting_outcome_to_tool_result(&outcome, &question, false);+ let out = res.output();++ assert!(+ res.is_error,+ "an unresumable pause must not be reported as success: {out}"+ );+ assert!(+ !out.contains("[SUBAGENT_AWAITING_USER]"),+ "no awaiting-user envelope: the orchestrator must not be told to relay \+ a question it cannot act on: {out}"+ );+ assert!(+ out.contains(&question),+ "the question is still surfaced so the user learns what was asked: {out}"+ );+ assert!(+ out.contains("do NOT call continue_subagent"),+ "the orchestrator must be told the resume handle is dead: {out}"+ );+}