Skip to content

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

fix(agent): handle missing runtime session in host

Steven Enamakel06869eaf4f3c
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index bc2973520d..4f8817e0a3 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -1324,45 +1324,12 @@ impl OpenHumanSessionHost {
context.workspace = self.workspace_descriptor.clone();
let cancellation = context.cancellation.clone();
let root_config = context.root_run_config("openhuman-session");
- // `suppress_transcript_autoload` must decide the resume mode HERE, before
- // the explicit identity-keyed resume below runs. `begin_turn_resume`
- // applies the same override later, inside the lifecycle's resume hook,
- // which is too late for a thread-bound session: `runtime.resume` has
- // already loaded the thread's own transcript into the history by then,
- // so the override suppressed nothing (#6377).
- let suppress_transcript_autoload = self
- .runtime_state
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner())
- .pending_turn_overrides
- .suppress_transcript_autoload;
- if suppress_transcript_autoload {
- tracing::debug!(
- thread_id = ?self.thread_id,
- "[session_host] transcript autoload suppressed for this turn"
- );
- }
let options = TurnOptions {
request_id: crate::agent::turn_origin::current_request_id(),
thread_id: self.thread_id.clone(),
stream: self.on_progress.is_some(),
session: self.session.clone(),
- resume: if suppress_transcript_autoload {
- ResumeMode::Never
- } else if self.session.is_some() {
- // Exact, identity-keyed resume. Unlike `LatestForAgent` it
- // cannot splice a different thread's transcript into this
- // turn, and the file it reads is the file the turn appends to.
- ResumeMode::Session
- } else if self
- .runtime_session
- .as_ref()
- .is_some_and(|session| session.history().is_empty())
- {
- ResumeMode::LatestForAgent
- } else {
- ResumeMode::Never
- },
+ resume: self.turn_resume_mode(),
cancellation,
run_context: context.into_tinyagents(root_config),
};
diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rs
index 1f5cca85c7..47e13927ea 100644
--- a/crates/openhuman-core/src/agent/session_host/types.rs
+++ b/crates/openhuman-core/src/agent/session_host/types.rs
@@ -63,6 +63,31 @@ pub struct TurnOverrides {
pub suppress_transcript_autoload: bool,
}
+impl OpenHumanSessionHost {
+ /// Whether the next turn carries `suppress_transcript_autoload`.
+ ///
+ /// `turn()` reads it to pick the resume mode BEFORE its explicit
+ /// identity-keyed resume runs. `begin_turn_resume` applies the same override
+ /// later, inside the lifecycle's resume hook, which is too late for a
+ /// thread-bound session: that resume has already loaded the thread's own
+ /// transcript into the history, so the override suppressed nothing (#6377).
+ pub(super) fn transcript_autoload_suppressed(&self) -> bool {
+ let suppressed = self
+ .runtime_state
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner())
+ .pending_turn_overrides
+ .suppress_transcript_autoload;
+ if suppressed {
+ tracing::debug!(
+ thread_id = ?self.thread_id,
+ "[session_host] transcript autoload suppressed for this turn"
+ );
+ }
+ suppressed
+ }
+}
+
/// An autonomous or semi-autonomous AI agent.
///
/// The `OpenHumanSessionHost` is the central component that manages conversation state,