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
test(agent): cover repeated turns releasing progress senders
Steven Enamakel39c1c79b300b
diff --git a/crates/openhuman-core/src/agent/agent_turn_progress_release_tests.rs b/crates/openhuman-core/src/agent/agent_turn_progress_release_tests.rsindex 447e6de927..82404f48cb 100644--- a/crates/openhuman-core/src/agent/agent_turn_progress_release_tests.rs+++ b/crates/openhuman-core/src/agent/agent_turn_progress_release_tests.rs@@ -1,30 +1,43 @@//! A finished turn must release every clone of its progress sender once the-//! caller clears the sink, so the web channel's progress bridge (which only-//! exits when its receiver closes) does not outlive the turn on a cached-//! session.+//! caller clears the sink. The web channel's progress bridge only exits when+//! its receiver closes, so a clone retained by the cached session (the+//! committed receipt's run context carries `progress` and the attached+//! parent's `on_progress`) kept one bridge task — and in SaaS mode its+//! profile's turn context — alive per turn.use super::*;#[tokio::test]async fn clearing_progress_after_a_turn_closes_the_receiver() {- let provider = Arc::new(ScriptedProvider::new(vec![text_response("Hello world")]));+ let provider = Arc::new(ScriptedProvider::new(vec![+ text_response("first"),+ text_response("second"),+ ]));let (mut agent, _tmp) =build_agent_with(provider, vec![Box::new(EchoTool)], Box::new(NativeDialect));- let (tx, mut rx) = tokio::sync::mpsc::channel(256);- let weak = tx.downgrade();- agent.set_on_progress(Some(tx));- agent.turn("hi").await.expect("turn");- agent.set_on_progress(None);+ // Two turns on the same (cached) session host, each with its own sink, as+ // the web channel does.+ for message in ["hi", "again"] {+ let (tx, mut rx) = tokio::sync::mpsc::channel(256);+ let weak = tx.downgrade();+ agent.set_on_progress(Some(tx));+ agent.turn(message).await.expect("turn");+ agent.set_on_progress(None);- eprintln!("DIAG strong_count after clear = {}", weak.strong_count());- while rx.try_recv().is_ok() {}- assert!(- matches!(- rx.try_recv(),- Err(tokio::sync::mpsc::error::TryRecvError::Disconnected)- ),- "a cached session kept {} progress sender clone(s) alive after the turn",- weak.strong_count()- );+ assert_eq!(+ weak.strong_count(),+ 0,+ "the session kept progress sender clone(s) alive after the turn"+ );+ // The turn's own events are still delivered, then the channel closes.+ let mut saw_completed = false;+ while let Some(event) = rx.recv().await {+ saw_completed |= matches!(+ event,+ crate::agent::progress::AgentProgress::TurnCompleted { .. }+ );+ }+ assert!(saw_completed, "turn must still report TurnCompleted");+ }}