Skip to content

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

feat(session_host): snapshot parent session state for child sessions

Steven Enamakel85fa2fc73c4a
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 db0d070594..11109eecab 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -510,52 +510,6 @@ impl OpenHumanTurnPrelude {
format!("{}\n\n{enriched}", turn.preamble())
}
- fn parent_context(&self) -> crate::agent::harness::ParentExecutionContext {
- let surface = self
- .tool_surface
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner);
- let (workflows, memory_context, connected_integrations) = {
- let mutable = self
- .mutable
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner);
- (
- mutable.workflows.clone(),
- mutable.last_memory_context.clone(),
- mutable.connected_integrations.clone(),
- )
- };
- crate::agent::harness::ParentExecutionContext {
- agent_definition_id: self.agent_definition_id.clone(),
- allowed_subagent_ids: self.allowed_subagent_ids.clone(),
- turn_model_source: self.turn_model_source.clone(),
- all_tools: surface.tools.clone(),
- all_tool_specs: surface.durable_tool_specs.clone(),
- visible_tool_names: surface.visible_tool_names.clone(),
- visible_tool_specs: surface.visible_tool_specs.clone(),
- subagent_tool_ceiling_names: self.subagent_tool_ceiling_names.clone(),
- model_name: self.model_name.clone(),
- temperature: self.temperature,
- workspace_dir: self.workspace_dir.clone(),
- workspace_descriptor: crate::agent::harness::current_parent()
- .and_then(|parent| parent.workspace_descriptor)
- .or_else(|| self.workspace_descriptor.clone()),
- agent_config: self.config.clone(),
- workflows: Arc::new(workflows),
- memory_context: Arc::new(memory_context),
- session_id: self.event_session_id.clone(),
- channel: self.event_channel.clone(),
- connected_integrations,
- tool_call_format: self.tool_dispatcher.tool_call_format(),
- session_key: self.session_key.clone(),
- session_parent_prefix: self.session_parent_prefix.clone(),
- on_progress: self.on_progress.clone(),
- run_queue: self.run_queue.clone(),
- host_env: self.host_env.clone(),
- }
- }
-
fn apply_pending_announcements(&self, enriched: &mut String) {
let mut mutable = self
.mutable
@@ -1122,6 +1076,7 @@ mod tool_surface;
mod juice_tests;
#[path = "prelude_integrations.rs"]
+mod parent_snapshot;
mod prelude_integrations;
#[cfg(test)]
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/parent_snapshot.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/parent_snapshot.rs
new file mode 100644
index 0000000000..36877cc068
--- /dev/null
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/parent_snapshot.rs
@@ -0,0 +1,51 @@
+//! The parent-execution snapshot a turn hands to the sub-agents it spawns.
+
+use super::*;
+
+impl OpenHumanTurnPrelude {
+ pub(in crate::agent::session_host) fn parent_context(&self) -> crate::agent::harness::ParentExecutionContext {
+ let surface = self
+ .tool_surface
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
+ let (workflows, memory_context, connected_integrations) = {
+ let mutable = self
+ .mutable
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
+ (
+ mutable.workflows.clone(),
+ mutable.last_memory_context.clone(),
+ mutable.connected_integrations.clone(),
+ )
+ };
+ crate::agent::harness::ParentExecutionContext {
+ agent_definition_id: self.agent_definition_id.clone(),
+ allowed_subagent_ids: self.allowed_subagent_ids.clone(),
+ turn_model_source: self.turn_model_source.clone(),
+ all_tools: surface.tools.clone(),
+ all_tool_specs: surface.durable_tool_specs.clone(),
+ visible_tool_names: surface.visible_tool_names.clone(),
+ visible_tool_specs: surface.visible_tool_specs.clone(),
+ subagent_tool_ceiling_names: self.subagent_tool_ceiling_names.clone(),
+ model_name: self.model_name.clone(),
+ temperature: self.temperature,
+ workspace_dir: self.workspace_dir.clone(),
+ workspace_descriptor: crate::agent::harness::current_parent()
+ .and_then(|parent| parent.workspace_descriptor)
+ .or_else(|| self.workspace_descriptor.clone()),
+ agent_config: self.config.clone(),
+ workflows: Arc::new(workflows),
+ memory_context: Arc::new(memory_context),
+ session_id: self.event_session_id.clone(),
+ channel: self.event_channel.clone(),
+ connected_integrations,
+ tool_call_format: self.tool_dispatcher.tool_call_format(),
+ session_key: self.session_key.clone(),
+ session_parent_prefix: self.session_parent_prefix.clone(),
+ on_progress: self.on_progress.clone(),
+ run_queue: self.run_queue.clone(),
+ host_env: self.host_env.clone(),
+ }
+ }
+}