Skip to content

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

fix(memory): a finished plan's notes are queued under the caller's profile scope

sanil-23ed8b3197d196
diff --git a/crates/openhuman-core/src/memory/lifecycle/plan_notes.rs b/crates/openhuman-core/src/memory/lifecycle/plan_notes.rs
index 5ff7c56fba..d03a6564a7 100644
--- a/crates/openhuman-core/src/memory/lifecycle/plan_notes.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/plan_notes.rs
@@ -76,10 +76,13 @@ pub async fn learn_plan_notes(
);
let notes = learnings(plan);
let total = notes.len();
- // The queue does blocking file I/O, as it does for the memory tool.
- let runtime = tokio::runtime::Handle::current();
- let queued = tokio::task::spawn_blocking(move || {
- runtime.block_on(async {
+ // The queue opens its storage under the current profile scope. Like the
+ // memory tool's writes, the work runs on a task that carries the caller's
+ // scope (the session host calls this inside the profile's scope): a bare
+ // spawn would run unscoped, and in SaaS the queue refuses every write.
+ let dispatch = crate::core::runtime::DispatchCtx::ambient();
+ let queued = dispatch
+ .spawn(async move {
let mut queued = 0;
for (text, kind) in notes {
let args = json!({
@@ -105,9 +108,8 @@ pub async fn learn_plan_notes(
}
queued
})
- })
- .await
- .unwrap_or(0);
+ .await
+ .unwrap_or(0);
tracing::debug!(
thread_id = %plan.thread_id,
queued,