Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(dispatch): an unpersisted synchronous pause is a failure, not a caveat\n\nReview finding on #5951 (Codex, P2). `awaiting_user_envelope`'s "resuming may\nfail" wording is calibrated for the async path, where a child that lost its\ncheckpoint is still reachable through the durable `subagent_sessions` store.\n\n`awaiting_outcome_to_tool_result` serves the *synchronous* delegation, and that\npath has neither fallback: `dispatch_subagent` returns early into\n`SpawnAsyncSubagentTool` before any durable session is registered, and sets\n`worker_thread_id: None` by construction. So with `checkpoint: None` there is\nno resume route at all — `continue_subagent` finds neither a checkpoint file\nnor a session — and a success envelope would have the orchestrator put a\nquestion to the user whose answer has nowhere to go. As with the write failure\nthis PR already fixes, the loss would only surface after they answered.\n\nReport it as a failure while the parent can still act on it: the question is\nstill surfaced so the user learns what was asked, and the orchestrator is told\nnot to call `continue_subagent` with a task_id that resolves to nothing.\n\nThe generic caveat is left exactly as it was for the async path, where it is\nthe accurate, narrower claim the author intended.\n

M3gA-Mind605469778527
diff --git a/src/openhuman/agent/orchestration/tools/dispatch.rs b/src/openhuman/agent/orchestration/tools/dispatch.rs
index 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.rs
index 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}"
+ );
+}