Skip to content

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

fix(agent): surface reusable session close failures to the caller

Steven Enamakel106a8893d146
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/close_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/close_subagent.rs
index 63d1626346..807bcb75ce 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/close_subagent.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/close_subagent.rs
@@ -151,7 +151,7 @@ impl CloseSubagentTool {
return Ok(ToolResult::error(
"close_subagent: sub-agent session not found for this parent thread",
));
- }
+ };
let dispatch =
crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);
let thread_id = tool_context.and_then(ToolRunContext::thread_id);
@@ -180,7 +180,7 @@ impl CloseSubagentTool {
Err(err) => Ok(ToolResult::error(format!(
"close_subagent: failed to update sub-agent session: {err}"
))),
- Ok(closed) => {
+ Ok(true) => {
log::info!(
"[subagent_reuse] close subagent_session_id={} parent_session={} closed={} cancelled_running={}",
subagent_session_id,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
index ceaa84a907..a94e8ba908 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
@@ -154,21 +154,16 @@ impl SpawnAsyncSubagentTool {
}
match subagent_sessions::close_if_current(&store, &session) {
Ok(true) => {}
- Ok(false) => log::warn!(
- "[subagent_reuse] fresh close lost lifecycle race parent_thread_id={} subagent_session_id={} agent_id={} task_key={}",
- parent_thread_id.as_deref().unwrap_or("none"),
- session.subagent_session_id,
- definition.id,
- task_key
- ),
- Err(err) => log::warn!(
- "[subagent_reuse] fresh close failed parent_thread_id={} subagent_session_id={} agent_id={} task_key={} error={}",
- parent_thread_id.as_deref().unwrap_or("none"),
- session.subagent_session_id,
- definition.id,
- task_key,
- err
- ),
+ Ok(false) => {
+ return Ok(ToolResult::error(
+ "spawn_async_subagent: reusable session changed during fresh start; retry with the current session",
+ ));
+ }
+ Err(err) => {
+ return Ok(ToolResult::error(format!(
+ "spawn_async_subagent: failed to close reusable session: {err}"
+ )));
+ }
}
}
Ok(None) => {}