Skip to content

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

feat(agent): add external channel history reset

Steven Enamakel39d05e31d6ce
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rs
index ddc5229355..3081a6ab20 100644
--- a/crates/openhuman-core/src/agent/host_agents.rs
+++ b/crates/openhuman-core/src/agent/host_agents.rs
@@ -133,6 +133,21 @@ impl HostAgent {
.await
}
+ /// Reset the durable session used by an external channel command. The
+ /// caller serializes this operation with turns for the same trusted
+ /// tenant, agent, and canonical session identity.
+ pub(crate) async fn reset_external_channel_history(
+ &self,
+ session_key: &str,
+ event_session_id: &str,
+ channel: &str,
+ ) -> anyhow::Result<bool> {
+ let mut session = self.session_host(&self.config, Some(session_key))?;
+ session.set_thread_id(Some(session_key));
+ session.set_event_context(event_session_id, channel);
+ self.scope(session.reset_bound_history()).await
+ }
+
/// Build a session for this agent from `config` -- normally a clone of
/// [`HostAgent::config`] carrying a driver's overrides.
///
diff --git a/crates/openhuman-core/src/agent/session_host/session_api.rs b/crates/openhuman-core/src/agent/session_host/session_api.rs
index 13e631dc63..64fcb51bf4 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,21 @@ use crate::agent::tinyagents::host::OpenHumanRunContext;
use super::OpenHumanSessionHost;
impl OpenHumanSessionHost {
+ /// 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
+ /// resumed before delegating to it.
+ pub(crate) async fn reset_bound_history(&mut self) -> Result<bool> {
+ self.ensure_runtime_session()?;
+ self.resume_bound_session().await?;
+ self.runtime_session
+ .as_mut()
+ .expect("runtime session initialized")
+ .reset_history()
+ .await
+ .map_err(|error| anyhow::anyhow!(error.to_string()))
+ }
+
/// Install imported conversation rows once, before the first turn binds
/// this durable session. Empty imports do not reserve a session, and a
/// transcript already written by a prior turn always wins unchanged.