Skip to content

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

fix(session_host): ingest memory after post-commit hooks

Steven Enamakel768d60b0afb0
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
index 26dc263d04..cfee4dfcae 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
@@ -234,7 +234,7 @@ impl OpenHumanTurnPrelude {
)
.await;
};
- crate::core::runtime::DispatchCtx::ambient().spawn(deferred_memory_work(profile_context, work));
+ self.dispatch_ctx().spawn(deferred_memory_work(profile_context, work));
}
}
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
index 21ab8642f1..49fb8f7262 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs
@@ -61,6 +61,7 @@ pub(super) fn turn_iterations(sidecar_model_calls: usize, history: &[Message]) -
/// return its handle. The caller can fence later work on the handle. Returns
/// whether the completion was delivered.
pub(super) async fn complete_then_defer<P, T>(
+ dispatch: &crate::core::runtime::DispatchCtx,
publish: P,
tail: T,
) -> (bool, tokio::task::JoinHandle<()>)
@@ -75,7 +76,7 @@ where
elapsed_ms = elapsed_ms(started),
"[session-runtime] post-commit: turn completion published"
);
- let handle = crate::core::runtime::DispatchCtx::ambient().spawn(async move {
+ let handle = dispatch.spawn(async move {
let started = Instant::now();
tail.await;
tracing::debug!(
@@ -213,6 +214,7 @@ pub(super) async fn finalize_committed_turn(
}
};
let (_, pending) = complete_then_defer(
+ &receipt.options.run_context.data.dispatch_ctx(),
super::progress::send_receipt_progress(&receipt, &input, &output, iterations),
goal_accounting,
)
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit_tests.rs
index 67b84b1027..f9e8aae93e 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit_tests.rs
@@ -62,7 +62,7 @@ async fn completion_is_published_before_slow_post_commit_work_finishes() {
let (delivered, pending) = tokio::time::timeout(
std::time::Duration::from_secs(5),
- complete_then_defer(publish, slow_tail),
+ complete_then_defer(&crate::core::runtime::DispatchCtx::unbound(), publish, slow_tail),
)
.await
.expect("completion does not wait for the slow tail");