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: route warm session completion to its own progress bridge
Steven Enamakelfed1b07a48c8
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rsindex cd543df42c..77c2e5d978 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs@@ -420,6 +420,10 @@ impl OpenHumanSessionHost {&mut self,tx: Option<tokio::sync::mpsc::Sender<crate::agent::progress::AgentProgress>>,) {+ // A warm runtime retains the last turn's prelude. Release its sender+ // along with the host sender so the finished turn's bridge can drain+ // and persist the final text without waiting for another turn.+ self.update_runtime_prelude_progress(tx.clone());self.on_progress = tx;}diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex 3462e1000f..973586ff92 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -1259,6 +1259,21 @@ async fn collect_prelude_tree_roots(}impl OpenHumanSessionHost {+ pub(super) fn update_runtime_prelude_progress(+ &mut self,+ tx: Option<tokio::sync::mpsc::Sender<crate::agent::progress::AgentProgress>>,+ ) {+ if let Some(prelude) = self+ .runtime_state+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner)+ .prelude+ .as_mut()+ {+ prelude.on_progress = tx;+ }+ }+/// Seed a cold runtime session from a host-provided message log.////// The runtime receives both the seed and any subsequent append; the host@@ -1700,14 +1715,12 @@ impl OpenHumanSessionHost {},{let state = self.runtime_state.clone();- let progress = self.on_progress.clone();let post_turn_hooks = self.post_turn_hooks.clone();let session_id = self.event_session_id.clone();let agent_id = self.agent_definition_id.clone();let channel = self.event_channel.clone();move |receipt| {let state = state.clone();- let progress = progress.clone();let post_turn_hooks = post_turn_hooks.clone();let session_id = session_id.clone();let agent_id = agent_id.clone();@@ -1786,6 +1799,9 @@ impl OpenHumanSessionHost {Some(task) => task.await.unwrap_or_default(),None => Vec::new(),};+ let _ =+ progress::send_receipt_progress(&receipt, &input, &output, iterations)+ .await;state.lock().unwrap_or_else(|poisoned| poisoned.into_inner())@@ -1798,12 +1814,6 @@ impl OpenHumanSessionHost {state.last_turn_usage = Some(usage);state.last_turn_citations = citations;}- if let Some(progress) = &progress {- let _ = progress::send_committed_turn_progress(- progress, &input, &output, iterations,- )- .await;- }crate::agent::hooks::fire_hooks(&post_turn_hooks,crate::agent::hooks::TurnContext {diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rsindex d73909f38c..6a543b0012 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs@@ -1,11 +1,28 @@//! Post-commit progress delivery for a chat turn.use crate::agent::progress::AgentProgress;+use crate::agent::tinyagents::host::OpenHumanRunContext;+use tinyagents_runtime::CommitReceipt;/// Preserve the response path if a progress receiver stays open but stops/// consuming events. The web bridge has its own bounded drain wait afterward.const COMMITTED_TURN_PROGRESS_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(3);+/// Route the commit fence to the turn that produced the receipt. A warm+/// session reuses its commit callback, so a sender captured when the session+/// was created would point at a prior turn's bridge.+pub(super) async fn send_receipt_progress(+ receipt: &CommitReceipt<OpenHumanRunContext>,+ input: &str,+ output: &str,+ iterations: u32,+) -> bool {+ match receipt.options.context.progress.as_ref() {+ Some(progress) => send_committed_turn_progress(progress, input, output, iterations).await,+ None => false,+ }+}+/// Send the terminal event as the progress bridge's drain fence. Content/// capture stays best effort; the completion waits for channel capacity, up to/// a deadline, so a healthy bridge can forward queued tool events first.diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rsindex 1b858a14bf..db81858a16 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs@@ -5,6 +5,76 @@ use std::sync::Arc;use tinyagents_runtime::ToolSnapshot;use tinytools::ToolSpec;+#[tokio::test]+async fn committed_progress_uses_each_turns_receipt_sender() {+ use crate::agent::progress::AgentProgress;+ use tinyagents_runtime::{+ CommitReceipt, ResumeMode, SessionTurnOutcome, TranscriptTurnOptions,+ };++ let receipt = |tx| {+ let mut context = crate::agent::tinyagents::host::OpenHumanRunContext::new();+ context.progress = Some(tx);+ CommitReceipt {+ outcome: SessionTurnOutcome {+ history: Vec::new(),+ output: Some("answer".into()),+ interrupted: false,+ },+ options: TranscriptTurnOptions {+ request_id: None,+ thread_id: None,+ stream: true,+ resume: ResumeMode::Never,+ context,+ },+ transcript: None,+ }+ };+ let (first_tx, mut first_rx) = tokio::sync::mpsc::channel(2);+ let (second_tx, mut second_rx) = tokio::sync::mpsc::channel(2);+ let first = receipt(first_tx);+ let second = receipt(second_tx);++ assert!(super::progress::send_receipt_progress(&second, "question", "answer", 2).await);+ assert!(matches!(+ second_rx.recv().await,+ Some(AgentProgress::TurnContent { .. })+ ));+ assert!(matches!(+ second_rx.recv().await,+ Some(AgentProgress::TurnCompleted { iterations: 2 })+ ));+ assert!(matches!(+ first_rx.try_recv(),+ Err(tokio::sync::mpsc::error::TryRecvError::Empty)+ ));+ drop(first);+}++#[test]+fn clearing_progress_releases_warm_prelude_sender() {+ let tmp = tempfile::tempdir().expect("tempdir");+ let config = crate::config::Config {+ workspace_dir: tmp.path().join("workspace"),+ action_dir: tmp.path().join("workspace"),+ config_path: tmp.path().join("config.toml"),+ ..Default::default()+ };+ let mut host =+ crate::agent::OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")+ .expect("orchestrator");+ host.ensure_runtime_session().expect("warm runtime");++ let (tx, mut rx) = tokio::sync::mpsc::channel(1);+ host.set_on_progress(Some(tx));+ host.set_on_progress(None);+ assert!(matches!(+ rx.try_recv(),+ Err(tokio::sync::mpsc::error::TryRecvError::Disconnected)+ ));+}+/// A full progress channel must not discard the only terminal signal. A busy/// bridge can catch up after the turn commits; it cannot infer completion from/// an event that was dropped.