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
feat(web_chat): deliver cron replies to the originating chat
Steven Enamakelf1578b50a9d3
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rsindex 99b3d17a41..170f511d1a 100644--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs@@ -236,8 +236,10 @@ async fn deliver_to_web_thread(let persist_thread = thread_id.to_string();let persist_request = request_id.clone();let persist_text = text.to_string();+ let persist_ctx = crate::core::runtime::DispatchCtx::ambient();crate::core::runtime::spawn_blocking_scoped(move || {crate::web_chat::persist_delivered_reply(+ &persist_ctx,&workspace,&persist_thread,&persist_request,diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rsindex be94a586db..a5ad74a5b5 100644--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs@@ -573,6 +573,7 @@ async fn start_chat_inner(let deferred_error = match result {Ok(chat_result) => {crate::web_chat::presentation::persist_reply(+ &ctx_task,&thread_id_task,&request_id_task,&chat_result.full_response,diff --git a/crates/openhuman-core/src/web_chat/presentation.rs b/crates/openhuman-core/src/web_chat/presentation.rsindex c77c3b56c5..89d36e7a10 100644--- a/crates/openhuman-core/src/web_chat/presentation.rs+++ b/crates/openhuman-core/src/web_chat/presentation.rs@@ -60,6 +60,7 @@ pub(crate) async fn deliver_response(suggest_follow_ups: bool,) {persist_reply(+ ctx,thread_id,request_id,full_response,@@ -86,6 +87,7 @@ pub(crate) async fn deliver_response(/// painted costs the user a repaint, not the reply. A storage failure is/// logged and never blocks the announcement. `None` stores nothing.pub(crate) async fn persist_reply(+ ctx: &crate::core::runtime::DispatchCtx,thread_id: &str,request_id: &str,full_response: &str,@@ -98,7 +100,8 @@ pub(crate) async fn persist_reply(// work that has no business holding a runtime worker while a turn// is settling. Hand it to the blocking pool and await the handle,// which keeps the ordering this whole change rests on.- let (dir, thread, request, reply, cites) = (+ let (dctx, dir, thread, request, reply, cites) = (+ ctx.clone(),dir.to_path_buf(),thread_id.to_string(),request_id.to_string(),@@ -107,7 +110,7 @@ pub(crate) async fn persist_reply();let persisted = tokio::task::spawn_blocking(move || {super::reply_persistence::persist_delivered_reply(- &dir, &thread, &request, &reply, &cites,+ &dctx, &dir, &thread, &request, &reply, &cites,)}).await;diff --git a/crates/openhuman-core/src/web_chat/reply_persistence.rs b/crates/openhuman-core/src/web_chat/reply_persistence.rsindex db690d0ce3..ada4666bbb 100644--- a/crates/openhuman-core/src/web_chat/reply_persistence.rs+++ b/crates/openhuman-core/src/web_chat/reply_persistence.rs@@ -51,6 +51,7 @@ const REPLY_SCOPE: &str = "web_chat_reply";/// shape `chatDoneExtraMetadata` builds, and any field added to that helper/// belongs here too.pub(crate) fn persist_delivered_reply(+ ctx: &DispatchCtx,workspace_dir: &Path,thread_id: &str,request_id: &str,@@ -71,7 +72,7 @@ pub(crate) fn persist_delivered_reply(extra_metadata["citations"] = json!(citations);}conversations::append_message(- &DispatchCtx::ambient(),+ ctx,workspace_dir.to_path_buf(),thread_id,ConversationMessage {