Skip to content

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

refactor(session_host): extract kept receipt progress detach into helper

Steven Enamakelea1635627461
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index 6c50fecf53..2decda5e4c 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -1286,17 +1286,10 @@ impl OpenHumanSessionHost {
let _ =
progress::send_receipt_progress(&receipt, &input, &output, iterations)
.await;
- // The kept receipt must not hold the turn's progress
- // channel open (see `detach_progress`).
- let mut receipt = receipt;
- receipt.options.context.detach_progress();
- log::debug!(
- "[session_host] last commit kept without its progress sinks session={session_id}"
- );
state
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner())
- .last_commit = Some(receipt);
+ .last_commit = Some(progress::kept_receipt(receipt));
{
let mut state = state
.lock()
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.rs
index 5f45881edd..f56f64d432 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
@@ -8,6 +8,18 @@ use tinyagents_runtime::CommitReceipt;
/// 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);
+/// `receipt` as the session keeps it after its turn: without the turn's
+/// progress sinks (`OpenHumanRunContext::detach_progress`). A kept sender
+/// held the turn's progress bridge, and the tenant context it runs under,
+/// alive until the thread's next turn, so a SaaS profile never read as idle.
+pub(super) fn kept_receipt(
+ mut receipt: CommitReceipt<OpenHumanRunContext>,
+) -> CommitReceipt<OpenHumanRunContext> {
+ receipt.options.context.detach_progress();
+ log::debug!("[session_host] last commit kept without its progress sinks");
+ receipt
+}
+
/// 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.