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(agent): import legacy history into bound sessions
Steven Enamakel4068b806372f
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rsindex 7c3226627b..71f4e8dcb4 100644--- a/crates/openhuman-core/src/agent/host_agents.rs+++ b/crates/openhuman-core/src/agent/host_agents.rs@@ -102,6 +102,7 @@ impl HostAgent {cancellation: tinyagents_harness::CancellationToken,turn_deadline: Option<std::time::Duration>,imported_history: &[tinyagents_session::transcript::TranscriptMessage],+ legacy_history: Option<crate::channels::providers::relay::LegacyHistoryImport>,) -> anyhow::Result<String> {let config = self.config.clone();let agent_id = self.definition.id.clone();@@ -109,6 +110,17 @@ impl HostAgent {session.set_thread_id(Some(session_key));session.set_event_context(event_session_id, channel);session.adopt_imported_history(imported_history)?;+ if let Some(source) = legacy_history {+ let dispatch = crate::core::runtime::DispatchCtx::new(Arc::clone(&self.context));+ session+ .adopt_legacy_history_if_needed(|| async {+ source+ .load(&dispatch)+ .await+ .map_err(anyhow::Error::msg)+ })+ .await?;+ }self.scope(crate::agent::turn_host::AgentTurnHost::run(&mut session,crate::agent::turn_host::AgentTurnRequest {diff --git a/crates/openhuman-core/src/agent/session_host/session_api.rs b/crates/openhuman-core/src/agent/session_host/session_api.rsindex 64fcb51bf4..a9f3084cf8 100644--- a/crates/openhuman-core/src/agent/session_host/session_api.rs+++ b/crates/openhuman-core/src/agent/session_host/session_api.rs@@ -16,6 +16,51 @@ use crate::agent::tinyagents::host::OpenHumanRunContext;use super::OpenHumanSessionHost;impl OpenHumanSessionHost {+ /// Whether this exact bound session already carries authoritative durable+ /// state. A freshly opened header alone is not enough: hosts may still need+ /// to adopt legacy history once. Explicit reset boundaries and recorded+ /// prompt/tool snapshots are authoritative even when the current head is+ /// intentionally empty.+ pub(crate) fn bound_history_is_authoritative(&self) -> anyhow::Result<bool> {+ let Some(session) = self.session.as_ref() else {+ return Ok(false);+ };+ let locator = self.session_locator();+ let head = locator.head_generation(session);+ let Some(read) = locator.read_session_transcript(&head) else {+ return Ok(false);+ };+ let Some(transcript) = read+ .read_session()+ .map_err(|error| anyhow::anyhow!(error.to_string()))?+ else {+ return Ok(false);+ };+ Ok(!transcript.messages.is_empty()+ || transcript.meta.turn_count > 0+ || transcript.meta.prefix_reset+ || transcript.meta.prefix_message_count.is_some()+ || transcript.tools.is_some())+ }++ /// Load legacy history only when the exact bound session has no durable+ /// turn or explicit empty/reset boundary. A failed load returns before the+ /// caller can start a turn and create a misleading empty session.+ pub(crate) async fn adopt_legacy_history_if_needed<F, Fut>(+ &self,+ load: F,+ ) -> anyhow::Result<bool>+ where+ F: FnOnce() -> Fut,+ Fut: std::future::Future<Output = anyhow::Result<Vec<TranscriptMessage>>>,+ {+ if self.bound_history_is_authoritative()? {+ return Ok(false);+ }+ let messages = load().await?;+ self.adopt_imported_history(&messages)+ }+/// Reset the bound durable transcript without deleting its sealed/// generations. The runtime owns the session identity and reset/// serialization; this host method only ensures the bound session is