Skip to content

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

fix(channels): restart channel service after session resume

Steven Enamakel33683d9bc101
diff --git a/crates/openhuman-core/src/channels/runtime/session.rs b/crates/openhuman-core/src/channels/runtime/session.rs
index cde70bdc60..04d97a26cd 100644
--- a/crates/openhuman-core/src/channels/runtime/session.rs
+++ b/crates/openhuman-core/src/channels/runtime/session.rs
@@ -103,18 +103,27 @@ pub(crate) fn resume_channel_service() {
fn spawn_channel_service_with<F, Fut>(
controller: ChannelSessionController,
- run: F,
+ mut run: F,
) -> tokio::task::JoinHandle<()>
where
- F: FnOnce(CancellationToken) -> Fut + Send + 'static,
+ F: FnMut(CancellationToken) -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
{
- tokio::spawn(run(controller.current()))
+ tokio::spawn(async move {
+ let mut session = controller.current();
+ loop {
+ run(session.clone()).await;
+ if !session.is_cancelled() {
+ return;
+ }
+ session = controller.wait_for_resume().await;
+ }
+ })
}
pub(crate) fn spawn_current_channel_service_with<F, Fut>(run: F) -> tokio::task::JoinHandle<()>
where
- F: FnOnce(CancellationToken) -> Fut + Send + 'static,
+ F: FnMut(CancellationToken) -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
{
spawn_channel_service_with(SESSION.clone(), run)