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
fix(session-host): read turn iterations from durable state
Steven Enamakelc3b784126353
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rsindex a4abf34b3f..0784df2f27 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs@@ -90,7 +90,6 @@ impl OpenHumanSessionHost {return Err(anyhow::anyhow!(user_message));}- let history_snapshot = self.history();// Busy state for background-result delivery is marked here, in the// turn's own (profile) scope; the bus subscriber runs off-task.// A guard, so a turn dropped mid-flight does not leave it busy.@@ -108,12 +107,10 @@ impl OpenHumanSessionHost {.await{Ok(response) => {- let history = self.history();- let new_entries = Self::new_entries_for_turn(&history_snapshot, &history);BUS.publish(DomainEvent::AgentTurnCompleted {session_id: self.event_session_id().to_string(),text_chars: response.chars().count(),- iterations: Self::count_iterations(new_entries),+ iterations: self.last_turn_iterations(),});drop(busy);Ok(response)diff --git a/crates/openhuman-core/src/agent/session_host/runtime/turn_results.rs b/crates/openhuman-core/src/agent/session_host/runtime/turn_results.rsindex e5eaa8b64f..024f659272 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/turn_results.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/turn_results.rs@@ -4,6 +4,16 @@use super::super::types::OpenHumanSessionHost;impl OpenHumanSessionHost {+ /// Iterations from the latest durable receipt, used by the legacy+ /// `AgentTurnCompleted` projection after the session turn returns.+ pub(crate) fn last_turn_iterations(&self) -> u32 {+ self.runtime_state+ .lock()+ .unwrap_or_else(|poisoned| poisoned.into_inner())+ .last_turn_iterations+ .max(1)+ }+/// Borrow the holistic token/cost/context totals for the latest completed/// turn (parent + sub-agents) **without consuming them**. `None` until a/// turn has run.diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex 4e6c8b2c52..cf37acb366 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -51,6 +51,7 @@ pub(super) struct OpenHumanSessionState {terminals: Vec<SessionTerminal>,pub(super) last_turn_hit_cap: bool,pub(super) last_turn_usage: Option<crate::agent::tinyagents::host::LastTurnUsage>,+ pub(super) last_turn_iterations: u32,pub(super) context_middleware: Option<TurnContextMiddleware>,required_output: Option<tinyagents_harness::config::RequiredOutput>,pub(crate) pending_turn_overrides: super::types::TurnOverrides,diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rsindex 7e9deff5b0..b0290b3db4 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs@@ -168,6 +168,7 @@ pub(super) async fn finalize_committed_turn(.unwrap_or_else(|poisoned| poisoned.into_inner());state.last_turn_hit_cap = interrupted;state.last_turn_usage = Some(usage.clone());+ state.last_turn_iterations = iterations;state.prelude.clone()};// Completion first: `TurnCompleted` is the progress