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): defer terminal journal flush until after commit
Steven Enamakel74eb64b58cd6
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rsindex 2f94703896..a273366bbd 100644--- a/crates/openhuman-core/src/agent/session_host/driver.rs+++ b/crates/openhuman-core/src/agent/session_host/driver.rs@@ -481,11 +481,9 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {);}observed.resolved_route = outcome.resolved_route.clone();+ observed.deferred_terminal = outcome.deferred_terminal.take();(observed.stop.clone(), (observed.model_calls as u32).max(1))};- if let Some(terminal) = outcome.deferred_terminal.take() {- terminal.finish(terminal_stop, terminal_turn).await;- }// The turn compacted its context: persist the compacted history, so the// next turn starts from the checkpoint. The runtime session seals the// current generation and opens the next (the history no longer extendsdiff --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 0cb6f96a1a..4b52eff0b4 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@@ -140,13 +140,16 @@ pub(super) async fn finalize_committed_turn(let input = tinyagents_harness::summarization::last_user_message(&receipt.outcome.history).map(crate::agent::message_convert::user_text_with_markers).unwrap_or_default();- let sidecar = receipt- .options- .context- .session_sidecar- .lock()- .unwrap_or_else(std::sync::PoisonError::into_inner)- .clone();+ let (sidecar, deferred_terminal) = {+ let mut sidecar = receipt+ .options+ .context+ .session_sidecar+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner);+ let terminal = sidecar.deferred_terminal.take();+ (sidecar.clone(), terminal)+ };// This turn's model calls, not every assistant row of the// whole conversation (`turn_iterations`).let iterations = turn_iterations(sidecar.model_calls, &receipt.outcome.history);@@ -160,6 +163,15 @@ pub(super) async fn finalize_committed_turn();let usage = super::holistic_last_turn_usage(&sidecar);let interrupted = sidecar.hit_cap || receipt.outcome.interrupted;+ // This hook runs only after the runtime durably appended the turn. Emit+ // OpenHuman's classified stop before the terminal journal flush, so native+ // completion cannot overwrite a cancellation/timeout/stop or hide commit+ // time from the exported span.+ if let Some(terminal) = deferred_terminal {+ terminal+ .finish(sidecar.stop.clone(), (sidecar.model_calls as u32).max(1))+ .await;+ }// State the caller reads as soon as `run_turn` returns.let prelude = {let mut state = statediff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rsindex cd1658a430..46c101b362 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs@@ -150,6 +150,10 @@ pub(crate) struct SessionTurnSidecar {/// iteration cap). The driver classifies it; `after_commit` carries it on/// `TurnCompleted` so the trace shows a stopped turn at `WARNING`.pub stop: Option<tinyagents_harness::turn_stop::TurnStop>,+ /// Native journal completion is held until the session transcript commits.+ /// The driver stores it here after post-run close/repair has succeeded;+ /// `after_commit` emits the final typed stop before flushing the journal.+ pub deferred_terminal: Option<crate::agent::tinyagents::turn_outcome::DeferredTurnTerminal>,}/// Immutable inputs to the host's pre-dispatch policy.