Skip to content

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

fix(agent): keep awaiting-input pauses from blocking task completion

Steven Enamakelf7be6236944d
diff --git a/Cargo.lock b/Cargo.lock
index d5c6793f79..790ab238d8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8480,6 +8480,7 @@ version = "2.1.4"
dependencies = [
"anyhow",
"async-trait",
+ "regex",
"serde",
"serde_json",
"tinyagents-harness",
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
index 3818f8fe18..aa0d89de86 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
@@ -374,6 +374,11 @@ pub(crate) async fn record_awaiting_input(
) {
let task_id = task_id.into();
let agent_id = agent_id.into();
+ // A pause is deliverable to the parent, but it is not the task's final
+ // completion. Give the pause its own router key so a later result from the
+ // same task is not mistaken for a duplicate (TinyAgents applies the same
+ // rule by omitting AwaitingUser from completion records).
+ let pause_record_id = awaiting_input_record_id(&task_id);
let summary = crate::agent::orchestration::tools::awaiting_user::awaiting_user_envelope(
&task_id,
&agent_id,
@@ -385,7 +390,7 @@ pub(crate) async fn record_awaiting_input(
ctx,
workspace_dir,
parent_session,
- task_id,
+ pause_record_id,
agent_id,
summary,
parent_thread_id,
@@ -394,6 +399,13 @@ pub(crate) async fn record_awaiting_input(
.await;
}
+/// Completion-router key for an awaiting-input notification. The real task id
+/// remains available in the notification body; this separate key leaves the
+/// task id's dedupe slot open for its eventual terminal result.
+fn awaiting_input_record_id(task_id: &str) -> String {
+ format!("{task_id}:awaiting-input")
+}
+
/// Drop every workspace's router and all process-local state about them. Called
/// when the core server stops (`openhuman_rpc::server::serve`), so the completion logs'
/// file handles close before a data reset removes their directory (Windows
@@ -457,9 +469,15 @@ pub(crate) fn pending_for(workspace_dir: &Path, thread_id: &str) -> Vec<Completi
/// answer. The router withdraws an already-recorded completion and drops one
/// that arrives later. Returns whether a pending completion was withdrawn.
pub(crate) fn mark_collected(workspace_dir: &Path, task_id: &str) -> bool {
- let outcome = router_for_workspace(workspace_dir).tombstone(task_id);
- log::debug!("[background_completions] mark_collected task_id={task_id} outcome={outcome:?}");
- matches!(outcome, Ok(TombstoneOutcome::Suppressed))
+ let router = router_for_workspace(workspace_dir);
+ let completion = router.tombstone(task_id);
+ let pause = router.tombstone(&awaiting_input_record_id(task_id));
+ log::debug!(
+ "[background_completions] mark_collected task_id={task_id} completion={completion:?} \
+ pause={pause:?}"
+ );
+ matches!(completion, Ok(TombstoneOutcome::Suppressed))
+ || matches!(pause, Ok(TombstoneOutcome::Suppressed))
}
/// Drop every queued completion for `thread_id` and everything that finishes