Skip to content

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

fix(orchestration): report unexecuted subagent tool calls as failures

Steven Enamakelb9f26db90179
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs
index 8240626e03..d3acefd93d 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs
@@ -15,6 +15,12 @@ pub(crate) fn is_unexecuted_tool_call_stub(output: &str) -> bool {
.any(char::is_alphanumeric)
}
+pub(crate) fn format_subagent_failure(tool: &str, error: &str) -> String {
+ format!(
+ "{tool} failed and did not complete. Do not treat this as success or fabricate output. Details: {error}"
+ )
+}
+
pub(crate) fn incomplete_stop(
reason: &str,
failure_cause: Option<tinyagents_harness::no_progress::ClassifiedStopCause>,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_completion.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_completion.rs
index f59d7ad182..3646f25f4b 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_completion.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_completion.rs
@@ -56,13 +56,23 @@ pub(super) fn make_completion(
let result = result.map_err(anyhow::Error::msg);
match result {
Ok(outcome) => {
- match outcome.status {
+ let status = if matches!(outcome.status, SubagentRunStatus::Completed)
+ && super::dispatch::is_unexecuted_tool_call_stub(&outcome.output)
+ {
+ SubagentRunStatus::Incomplete {
+ reason: "returned an unexecuted tool call instead of a result"
+ .to_string(),
+ }
+ } else {
+ outcome.status.clone()
+ };
+ match status {
SubagentRunStatus::Completed => {
if let Err(err) = subagent_sessions::mark_finished(
&background_store,
&background_subagent_session_id,
&outcome.task_id,
- &outcome.status,
+ &status,
outcome.final_history.clone(),
) {
log::warn!(
@@ -129,7 +139,7 @@ pub(super) fn make_completion(
&background_store,
&background_subagent_session_id,
&outcome.task_id,
- &outcome.status,
+ &status,
outcome.final_history.clone(),
) {
log::warn!(
@@ -309,6 +319,10 @@ pub(super) fn make_completion(
}
Err(err) => {
let error = err.to_string();
+ let failure = super::dispatch::format_subagent_failure(
+ "spawn_subagent",
+ &error,
+ );
if let Err(store_err) = subagent_sessions::mark_failed(
&background_store,
&background_subagent_session_id,
@@ -330,19 +344,19 @@ pub(super) fn make_completion(
// surfaces it as a follow-up chat turn.
if emit_lifecycle_effects {
completion_target
- .failed(&background_task_id, &background_agent_id, &error)
+ .failed(&background_task_id, &background_agent_id, &failure)
.await;
crate::agent::orchestration::subagent_events::publish_subagent_failed(
background_parent_session,
background_task_id.clone(),
background_agent_id.clone(),
- error.clone(),
+ failure.clone(),
);
abort_report
.deliver(AgentProgress::SubagentFailed {
agent_id: background_agent_id,
task_id: background_task_id,
- error,
+ error: failure,
})
.await;
}