Skip to content

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

refactor(runtime): adjust session host history clearing and summarizer logic

Steven Enamakel626503eb48ab
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
index 35975594c1..d5b728210a 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
@@ -590,11 +590,14 @@ impl OpenHumanSessionHost {
));
}
- /// Clears the agent's conversation history.
+ /// Discards this host's cached session composition.
+ ///
+ /// This synchronous compatibility method does not reset durable history;
+ /// callers that serve a user-visible reset command must use
+ /// `reset_bound_history` so the transcript generation changes atomically.
pub fn clear_history(&mut self) {
- // Runtime `Session` owns the only generic history and has no mutable
- // clear operation by design. Dropping this uncommitted/committed
- // composition starts a fresh runtime session on the next public turn.
+ // Dropping the composition only affects this host instance. Durable
+ // transcript state remains untouched.
self.runtime_session = None;
self.runtime_state = Arc::new(std::sync::Mutex::new(
super::super::runtime_session::OpenHumanSessionState::default(),
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
index 8ebc7a5eaf..cc1223241a 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs
@@ -18,7 +18,7 @@ use tinyagents_harness::{
use tokio::sync::mpsc;
use crate::{
- agent::{host_agents::HostAgent, queued_turn::QueuedPayload, session_lease::SessionLease},
+ agent::{queued_turn::QueuedPayload, session_lease::SessionLease},
channels::bus::NativeProgressiveReply,
core::runtime::DispatchCtx,
};
@@ -377,7 +377,28 @@ impl FailureClassifier for NativeFailures {
struct NativeSummarizer;
#[async_trait]
-impl Summarizer<QueuedPayload> for NativeSummarizer {}
+impl Summarizer<QueuedPayload> for NativeSummarizer {
+ async fn grounded_close(
+ &self,
+ request: &TurnRequest<QueuedPayload>,
+ reason: &str,
+ ) -> Option<TurnResult> {
+ let error = if reason.contains("idle") {
+ let idle = request
+ .idle_timeout
+ .unwrap_or_else(crate::agent::turn_policy::configured_idle_window);
+ crate::web_chat::web_errors::turn_idle_error_message(idle.as_secs())
+ } else {
+ let deadline = request.deadline.unwrap_or_default();
+ crate::web_chat::web_errors::turn_timeout_error_message(deadline.as_secs())
+ };
+ let (failure_type, message) = NativeFailures.classify(&error);
+ Some(TurnResult {
+ reply: message,
+ data: serde_json::json!({"failure_type": failure_type}),
+ })
+ }
+}
struct NativeRuntime {
shared: Arc<NativeShared>,
@@ -446,7 +467,7 @@ pub(crate) async fn run(
},
host_authored: false,
disposition: QueueDisposition::Interrupt,
- deadline: Some(crate::agent::session_host::turn_backstop::configured_backstop()),
+ deadline: crate::agent::session_host::turn_backstop::configured_backstop(),
idle_timeout: Some(crate::agent::turn_policy::configured_idle_window()),
};
let runner_result = runtime.runner.run(request).await;