Skip to content

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

fix(agent): resume durable subagent when session id fills agent field

Steven Enamakel8d3305f6015d
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs
index 84c04b847a..0692dc4b7d 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs
@@ -116,7 +116,10 @@ impl ContinueSubagentTool {
fresh task if the worker was closed."
)));
};
- if session.agent_id != agent_id {
+ // The session id already identifies a worker within this parent's
+ // store. Accept it in `agent_id` too when a caller copies the roster's
+ // session id into both fields, but keep rejecting unrelated agents.
+ if session.agent_id != agent_id && session.subagent_session_id != agent_id {
return Ok(ToolResult::error(format!(
"continue_subagent: agent_id mismatch — durable session '{}' belongs to \
'{}', caller passed '{agent_id}'",
@@ -134,7 +137,7 @@ impl ContinueSubagentTool {
tracing::info!(
task_id = %task_id,
subagent_session_id = %session.subagent_session_id,
- agent_id = %agent_id,
+ agent_id = %session.agent_id,
status = ?session.status,
"[continue_subagent] resuming durable session via reusable async path"
);
@@ -203,7 +206,7 @@ impl Tool for ContinueSubagentTool {
},
"agent_id": {
"type": "string",
- "description": "The worker's agent_id (from the envelope or the roster line)."
+ "description": "The worker's agent_id (from the envelope or roster). For a durable session, its subagent_session_id is also accepted here when used as task_id."
},
"message": {
"type": "string",
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
index 6cca4e02b6..22872827a2 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
@@ -262,23 +262,38 @@ async fn continue_subagent_resumes_idle_durable_session_e2e() {
RunConfig::new("continue-async-e2e").with_thread("thread-continue-parent"),
);
let session_id = session.subagent_session_id.clone();
- let result = with_parent_context(ctx, async {
- ContinueSubagentTool::new()
+ let (wrong_agent, result) = with_parent_context(ctx, async {
+ let tool = ContinueSubagentTool::new();
+ let wrong_agent = tool
.execute_with_live_parent_context(
json!({
"task_id": session_id,
- "agent_id": "researcher",
+ "agent_id": "unrelated_agent",
+ "message": "this must not resume the worker"
+ }),
+ None,
+ parent_run.data.child(),
+ Some(&parent_run),
+ )
+ .await?;
+ let result = tool
+ .execute_with_live_parent_context(
+ json!({
+ "task_id": session_id,
+ "agent_id": session.subagent_session_id,
"message": "looks good — proceed with continue-durable-canary"
}),
None,
parent_run.data.child(),
Some(&parent_run),
)
- .await
+ .await?;
+ Ok::<_, anyhow::Error>((wrong_agent, result))
})
.await
.expect("tool execution");
+ assert!(wrong_agent.is_error, "unrelated agent id must be rejected");
assert!(!result.is_error, "{}", result.output());
let out = result.output();
assert!(