The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(web_chat): prevent turn activity from being cleared while a turn is still running
Steven Enamakelf209064ac1fa
diff --git a/crates/openhuman-core/src/web_chat/ops/turn_guards_tests.rs b/crates/openhuman-core/src/web_chat/ops/turn_guards_tests.rsindex 4bb035e64c..2030c94db7 100644--- a/crates/openhuman-core/src/web_chat/ops/turn_guards_tests.rs+++ b/crates/openhuman-core/src/web_chat/ops/turn_guards_tests.rs@@ -72,8 +72,7 @@ const CEILING: Option<Duration> = Some(Duration::from_secs(3_600));/// ceiling.#[tokio::test(start_paused = true)]async fn a_turn_that_keeps_progressing_outlives_the_idle_window() {- let res = drive_turn_with_deadline(CEILING, IDLE, None, async {- let activity = super::super::super::turn_activity::current().expect("activity scoped");+ let res = drive_turn_with_deadline(CEILING, IDLE, None, |activity| async move {for _ in 0..90 {tokio::time::sleep(Duration::from_secs(17)).await;activity.observe(&text_delta());@@ -90,7 +89,7 @@ async fn a_turn_that_keeps_progressing_outlives_the_idle_window() {#[tokio::test(start_paused = true)]async fn a_silent_turn_ends_after_the_idle_window() {let started = tokio::time::Instant::now();- let err = drive_turn_with_deadline(CEILING, IDLE, None, async {+ let err = drive_turn_with_deadline(CEILING, IDLE, None, |_| async {std::future::pending::<()>().await;Ok(result("never"))})@@ -109,8 +108,7 @@ async fn a_silent_turn_ends_after_the_idle_window() {/// A turn that stays busy forever is still bounded by the fixed ceiling.#[tokio::test(start_paused = true)]async fn a_turn_busy_past_the_ceiling_hits_the_backstop() {- let err = drive_turn_with_deadline(CEILING, IDLE, None, async {- let activity = super::super::super::turn_activity::current().expect("activity scoped");+ let err = drive_turn_with_deadline(CEILING, IDLE, None, |activity| async move {loop {tokio::time::sleep(Duration::from_secs(30)).await;activity.observe(&text_delta());diff --git a/crates/openhuman-core/src/web_chat/turn_activity.rs b/crates/openhuman-core/src/web_chat/turn_activity.rsindex e47d1c688c..b23cf3a146 100644--- a/crates/openhuman-core/src/web_chat/turn_activity.rs+++ b/crates/openhuman-core/src/web_chat/turn_activity.rs@@ -301,20 +301,6 @@ pub(crate) fn tap(bridge_rx}-tokio::task_local! {- static CURRENT_TURN_ACTIVITY: TurnActivity;-}--/// The activity record scoped on the current task, if any.-pub(crate) fn current() -> Option<TurnActivity> {- CURRENT_TURN_ACTIVITY.try_with(Clone::clone).ok()-}--/// Run `future` with `activity` scoped on the task.-pub(crate) async fn with_turn_activity<F: Future>(activity: TurnActivity, future: F) -> F::Output {- CURRENT_TURN_ACTIVITY.scope(activity, future).await-}-#[cfg(test)]#[path = "turn_activity_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/web_chat/turn_activity_tests.rs b/crates/openhuman-core/src/web_chat/turn_activity_tests.rsindex 7ed80b2e31..419c9e232d 100644--- a/crates/openhuman-core/src/web_chat/turn_activity_tests.rs+++ b/crates/openhuman-core/src/web_chat/turn_activity_tests.rs@@ -192,16 +192,6 @@ async fn tap_records_and_forwards_in_order() {assert_eq!(activity.idle_for(Instant::now()), None, "call a still open");}-#[tokio::test]-async fn task_local_scope_is_visible_inside_only() {- assert!(current().is_none());- let activity = TurnActivity::new();- assert!(with_turn_activity(activity, async { current() })- .await- .is_some());- assert!(current().is_none());-}-#[tokio::test]async fn stuck_point_names_where_the_turn_went_quiet() {let activity = TurnActivity::new();