Skip to content

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

feat(memory): ingest session summaries into long-term memory

Steven Enamakel53639213a0d1
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 07d140f7b9..a1fb78759f 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
@@ -164,6 +164,7 @@ impl OpenHumanTurnPrelude {
identity,
thread_id,
pack,
+ core: self.host_env.core.clone(),
}))
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/memory_summarizer.rs b/crates/openhuman-core/src/agent/tinyagents/memory_summarizer.rs
index 54efefd95b..e4b3a92297 100644
--- a/crates/openhuman-core/src/agent/tinyagents/memory_summarizer.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/memory_summarizer.rs
@@ -50,6 +50,7 @@ impl MemoryRecallSummarizer {
summary: impl std::future::Future<Output = Result<SummaryRecord>>,
) -> Result<SummaryRecord> {
let pack = crate::memory::lifecycle::prefetch::compaction(
+ &self.turn.dispatch_ctx(),
self.turn.config.clone(),
self.turn.identity.clone(),
self.turn.thread_id.clone(),
diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks.rs b/crates/openhuman-core/src/memory/lifecycle/hooks.rs
index 2f9dbb5e4c..b5b381c081 100644
--- a/crates/openhuman-core/src/memory/lifecycle/hooks.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/hooks.rs
@@ -151,6 +151,18 @@ pub struct MemoryTurn {
pub thread_id: String,
/// The pack the turn was given, if any.
pub pack: Option<TurnPack>,
+ /// The context the turn runs under, held weakly so a finished tenant's
+ /// lease is not kept alive by a lingering turn handle.
+ pub core: Option<std::sync::Weak<crate::core::runtime::CoreContext>>,
+}
+
+impl MemoryTurn {
+ /// The dispatch context the turn's memory work runs under: its own, else
+ /// the calling task's.
+ #[must_use]
+ pub fn dispatch_ctx(&self) -> crate::core::runtime::DispatchCtx {
+ crate::core::runtime::DispatchCtx::from_weak(self.core.as_ref())
+ }
}
/// What the agent loop knows before the model runs.