Skip to content

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

fix(orchestration): clean up stop order when resuming a thread

Steven Enamakelb4083ce13bcc
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
index aa058f795c..92f0b1e0bb 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs
@@ -140,7 +140,9 @@ impl QueueState {
}
fn resume_thread(&mut self, thread_id: &str) {
- self.stopped_threads.remove(thread_id);
+ if self.stopped_threads.remove(thread_id) {
+ self.stopped_order.retain(|stopped| stopped != thread_id);
+ }
}
fn mark_stopped_task_if_thread_stopped(&mut self, thread_id: &str, task_id: &str) -> bool {
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
index 10a187c9ef..0f1320fb3c 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
@@ -440,3 +440,14 @@ fn discard_pending_for_thread_blocks_late_results_until_the_next_turn() {
assert_eq!(pending_count("sess-stop"), 1);
let _ = take_pending("sess-stop");
}
+
+#[test]
+fn resuming_a_thread_removes_its_stop_order_entry() {
+ let mut state = QueueState::default();
+ state.stop("thread-resume");
+
+ state.resume_thread("thread-resume");
+
+ assert!(!state.stopped_threads.contains("thread-resume"));
+ assert!(state.stopped_order.is_empty());
+}