Skip to content

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

fix(memory): take a channel turn's origin from the run context

M3gA-Mind17209923c14c
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index 8733f6e367..a1353326f4 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -1133,8 +1133,7 @@ impl OpenHumanSessionHost {
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner())
.take_turn_inputs();
- let current_input =
- view.history.last().filter(|last| **last == request.input);
+ let origin = options.run_context.data.origin.clone();
let (enriched, memory_turn) = futures::join!(
prelude.enrich_request(
&original_user_message,
@@ -1147,7 +1146,8 @@ impl OpenHumanSessionHost {
Box::pin(prelude.memory_pre_turn(
view.history,
view.committed_turns,
- current_input,
+ view.history.last().filter(|last| **last == request.input),
+ origin,
)),
);
options.run_context.data.memory_turn = memory_turn;
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 2abecc05f8..5bd6ae37cc 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
@@ -74,11 +74,16 @@ impl OpenHumanTurnPrelude {
/// Logs a user-authored turn and recalls its pack. Remembers the turn so
/// the reply is logged under the same identity and index, and returns
/// the turn's memory for the run context.
+ /// `origin` is the turn's origin as the run context carries it (the
+ /// session host never reads the task-local one); a channel turn is
+ /// logged as observed from its sender
+ /// ([`crate::memory::lifecycle::sender::channel_actor`]).
pub(super) async fn memory_pre_turn(
&self,
history: &[Message],
committed_turns: usize,
current: Option<&Message>,
+ origin: Option<crate::agent::turn_origin::AgentTurnOrigin>,
) -> Option<Arc<MemoryTurn>> {
let user_text = self
.mutable
@@ -114,7 +119,7 @@ impl OpenHumanTurnPrelude {
in_prompt_from,
at: Utc::now(),
resumed_after_compaction: compacted && committed_turns > 0,
- observed_actor: crate::agent::turn_origin::current()
+ observed_actor: origin
.as_ref()
.and_then(crate::memory::lifecycle::sender::channel_actor),
},
diff --git a/docs/specs/memory-v2.md b/docs/specs/memory-v2.md
index 89c3f779ca..0ebc9bd5a3 100644
--- a/docs/specs/memory-v2.md
+++ b/docs/specs/memory-v2.md
@@ -186,7 +186,14 @@ did what it stores (CortexDB's `observed_actor`, with the memory's owner as
`subject`): an assistant turn its agent (`agent:<id>`), a synced email its
sender (`user:<address>`, with the sender's name). An email address is
trimmed and lower-cased, so one person is one actor; a phone number is kept as
-the connector's dial digits (`+15551234567`). Neither is redacted. A write
+the connector's dial digits (`+15551234567`). Neither is redacted. A user
+turn whose origin is a channel message is observed from its sender
+(`memory::lifecycle::sender`): `user:+<dial digits>` for a phone on a
+phone-addressed channel, `user:<email>`, else `<channel>:<sender>` (a Telegram
+id, a WhatsApp `<lid>@lid`), with the channel's push or profile name (no
+channel exposes a saved contact name); a cron run is not attributed. Today
+the channel runtime runs its turns on the harness graph, which logs no turns
+(`memory::bus`), so this applies once a channel turn is logged. A write
CortexDB refuses for it is written again without it (tinymemory's fallback). Off, and always on the hosted engine, nothing on the wire changes.
## Agent tool: `memory`