Skip to content

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

refactor(session_host): extract deferred terminal installation into helper

Steven Enamakel28db1c3970d7
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index caf1121606..abaa17d7a6 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -233,25 +233,9 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {
));
}
};
- // From here onward close, required-output repair, and durable commit
- // can still be cancelled or fail. Keep the native terminal handle on
- // the per-turn sidecar immediately so `on_terminal` can finalize it
- // after Tiny persists any recoverable partial transcript.
- sidecar
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner)
- .deferred_terminal = outcome.deferred_terminal.take();
- let supplemental_trace = sidecar
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner)
- .deferred_terminal
- .as_ref()
- .map(|terminal| {
- grounded_close::SupplementalTrace::new(
- terminal.events.clone(),
- terminal.run_id.clone(),
- )
- });
+ let supplemental_trace = grounded_close::SupplementalTrace::install_for_turn(
+ &sidecar, &mut outcome,
+ );
if outcome.text.trim().is_empty() && outcome.tool_outcomes.is_empty() {
return Err(driver_error(
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
index b446ba5a93..ea0d2306eb 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
@@ -72,6 +72,19 @@ impl SupplementalTrace {
})
}
+ pub(super) fn install_for_turn(
+ sidecar: &std::sync::Mutex<crate::agent::tinyagents::host::run_context::SessionTurnSidecar>,
+ outcome: &mut TinyagentsTurnOutcome,
+ ) -> Option<Arc<Self>> {
+ let terminal = outcome.deferred_terminal.take()?;
+ let trace = Self::new(terminal.events.clone(), terminal.run_id.clone());
+ sidecar
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .deferred_terminal = Some(terminal);
+ Some(trace)
+ }
+
fn begin(&self, model: &str) -> (CallId, u64) {
let n = self.next_call.fetch_add(1, Ordering::Relaxed);
let call_id = CallId::new(format!("{}-host-supplemental-{n}", self.run_id.as_str()));
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
index 5757c371a8..fb56082be3 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -100,7 +100,7 @@ pub(super) fn tier_gate_decision(
/// On success returns a [`SubagentRunOutcome`] whose `output` is the
/// final assistant text. On failure the error is suitable for stringifying
/// into a `tool_result` block — including the two dispatch refusals, whose
-/// messages tell the model to summarise rather than delegate again.
+/// messages direct the model to summarize rather than delegate again.
pub(crate) async fn run_subagent_direct_with_native_context(
definition: &AgentDefinition,
task_prompt: &str,
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
index 46c101b362..fad0280344 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -150,9 +150,7 @@ 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.
+ /// Deferred native terminal finalized after transcript durability.
pub deferred_terminal: Option<crate::agent::tinyagents::turn_outcome::DeferredTurnTerminal>,
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
index 7aff746e84..25c6d9be3e 100644
--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
@@ -1,7 +1,6 @@
//! [`EventListener`] implementation for [`OpenhumanEventBridge`] — projects
//! each `tinyagents` [`AgentEvent`] onto an [`AgentProgress`] update (or a
-//! grep-friendly trace line for events with no UI surface), plus the
-//! prompt-cache layout diagnostic helper drained after a run.
+//! grep-friendly trace lines for events with no UI surface.
use tinyagents_harness::cache::CacheLayoutEvent;
use tinyagents_harness::events::{AgentEvent, EventListener, EventRecord};
diff --git a/crates/openhuman-core/src/core/observability.rs b/crates/openhuman-core/src/core/observability.rs
index e2e7958697..d18c538a63 100644
--- a/crates/openhuman-core/src/core/observability.rs
+++ b/crates/openhuman-core/src/core/observability.rs
@@ -16,10 +16,6 @@
pub(crate) mod progress_tracing;
-#[cfg(test)]
-#[path = "observability/trace_export_adoption_tests.rs"]
-mod trace_export_adoption_tests;
-
#[path = "observability_channel_message.rs"]
mod channel_message;
#[cfg(feature = "crash-reporting")]
diff --git a/crates/openhuman-core/src/core/observability/progress_tracing.rs b/crates/openhuman-core/src/core/observability/progress_tracing.rs
index c773d1e17a..2c35787b2b 100644
--- a/crates/openhuman-core/src/core/observability/progress_tracing.rs
+++ b/crates/openhuman-core/src/core/observability/progress_tracing.rs
@@ -1,11 +1,13 @@
//! Native trace export for completed TinyAgents runs.
//!
-//! OpenHuman owns product attribution, privacy gates, local export settings,
-//! and the authenticated backend transport. TinyAgents owns the span
-//! collector, journal projection, and OTLP payload format.
+//! OpenHuman gates and sends native TinyAgents trace exports.
mod export;
+#[cfg(test)]
+#[path = "trace_export_adoption_tests.rs"]
+mod adoption_tests;
+
use tinyagents_harness::observability::trace_export::ExportBrand;
/// Product identity stamped onto exported telemetry.