Skip to content

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

fix(web_chat): move resume_stopped_thread after message validation

Steven Enamakel86e45492299e
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
index 0e56abb006..aa058f795c 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
@@ -396,7 +396,7 @@ pub(crate) fn discard_pending_for_thread(thread_id: &str) -> usize {
/// before Stop but registered after the registry sweep still cannot enqueue a
/// completion. Task tombstones additionally protect that stopped generation
/// after the next turn reopens the thread.
-pub(crate) fn finish_stop_for_thread(thread_id: &str, task_ids: &[String]) {
+pub(crate) fn finish_stop_for_thread(_thread_id: &str, task_ids: &[String]) {
let mut state = queue()
.lock()
.expect("background_completions queue poisoned");
diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
index 7d712258f8..a70a8672d0 100644
--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs
+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
@@ -61,11 +61,6 @@ pub async fn start_chat(
return Err("message is required".to_string());
}
- // A fresh user request is the explicit boundary after Stop. Keep the gate
- // installed through registry cancellation so a child registering late
- // cannot deliver a result into the stopped generation.
- crate::agent::orchestration::background_completions::resume_stopped_thread(&thread_id);
-
// [pdf/image-attach fix] Process attachments at ingress, BEFORE the message is
// injection-scanned, persisted to history/JSONL, or auto-saved to the memory
// store. Otherwise a multi-MB base64 data URI floods every upstream stage
@@ -227,6 +222,11 @@ pub async fn start_chat(
}
}
+ // A fresh accepted user request is the explicit boundary after Stop. Keep
+ // the gate installed through validation and registry cancellation so a
+ // child registering late cannot deliver into the stopped generation.
+ crate::agent::orchestration::background_completions::resume_stopped_thread(&thread_id);
+
let map_key = key_for(&thread_id);
let parsed_mode = match queue_mode.as_deref() {