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): add deadline wind-down for runtime sessions
Steven Enamakel8043ab5ba34f
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rsindex 14b1f5edbe..3eb0f56c24 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs@@ -18,9 +18,26 @@ pub(super) async fn send_receipt_progress(output: &str,iterations: u32,) -> bool {+ // How the driver says the turn ended: a turn the harness stopped early+ // (breaker, wind-down, iteration cap) still commits, so the stop rides on+ // the terminal event for the trace collector to close it at WARNING.+ let stop = receipt+ .options+ .context+ .session_sidecar+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner)+ .stop+ .clone();+ if let Some(stop) = &stop {+ log::debug!(+ "[agent_session] committed turn was stopped early; carrying it on TurnCompleted {}",+ stop.status_message()+ );+ }match receipt.options.context.progress.as_ref() {Some(progress) => {- send_committed_turn_progress(progress, input, output, iterations, None).await+ send_committed_turn_progress(progress, input, output, iterations, stop).await}None => false,}diff --git a/crates/openhuman-core/src/agent/tinyagents/deadline_wind_down.rs b/crates/openhuman-core/src/agent/tinyagents/deadline_wind_down.rsindex 46018d88e4..1c00f45eac 100644--- a/crates/openhuman-core/src/agent/tinyagents/deadline_wind_down.rs+++ b/crates/openhuman-core/src/agent/tinyagents/deadline_wind_down.rs@@ -31,7 +31,7 @@ use tinyagents_harness::steering::{SteeringCommand, SteeringHandle};use tinyinference_llm::model::ModelResponse;use tinytools::ToolResult;-use crate::agent::tinyagents::host::OpenHumanRunContext;+use crate::agent::tinyagents::host::{OpenHumanRunContext, SessionTurnSidecar};use crate::agent::tinyagents::observability::SubagentScope;use crate::agent::turn_deadline::TurnDeadline;@@ -41,6 +41,9 @@ pub(crate) struct DeadlineWindDownMiddleware {deadline: TurnDeadline,/// Latched on the first pause, so `Pause` is sent exactly once.fired: Arc<AtomicBool>,+ /// The turn's session sidecar; the pause is recorded there so the driver+ /// can report the turn as wound down rather than completed.+ sidecar: std::sync::OnceLock<Arc<std::sync::Mutex<SessionTurnSidecar>>>,}impl DeadlineWindDownMiddleware {@@ -49,9 +52,16 @@ impl DeadlineWindDownMiddleware {handle,deadline,fired: Arc::new(AtomicBool::new(false)),+ sidecar: std::sync::OnceLock::new(),}}+ /// Record the pause on `sidecar` (the turn's run-context sidecar). Set+ /// once, before the run starts.+ pub(crate) fn set_sidecar(&self, sidecar: Arc<std::sync::Mutex<SessionTurnSidecar>>) {+ let _ = self.sidecar.set(sidecar);+ }+/// Whether this middleware has paused the run.pub(crate) fn fired(&self) -> bool {self.fired.load(Ordering::SeqCst)@@ -72,6 +82,16 @@ impl DeadlineWindDownMiddleware {"[turn_deadline] wind-down point passed; pausing the run so the turn closes with an answer before the backstop");self.handle.send(SteeringCommand::Pause);+ if let Some(sidecar) = self.sidecar.get() {+ sidecar+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner)+ .wind_down = true;+ tracing::debug!(+ target: "turn_deadline",+ "[turn_deadline] wind-down recorded on the turn sidecar; the turn will be reported as stopped"+ );+ }true}}@@ -121,12 +141,16 @@ pub(super) fn install(run_context: &OpenHumanRunContext,subagent_scope: &Option<SubagentScope>,) -> Option<Arc<DeadlineWindDownMiddleware>> {- install_for(+ let middleware = install_for(harness,handle.as_ref(),run_context.turn_deadline,subagent_scope.is_some(),- )+ )?;+ // `install_for` hands back the instance it registered; record the pause+ // on the turn's sidecar through that same shared state.+ middleware.set_sidecar(run_context.session_sidecar.clone());+ Some(middleware)}/// [`install`] over plain values, for tests.