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 context for subagent sessions

Steven Enamakel1ec91eed4b53
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 a2188513cb..673ff88c39 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -482,7 +482,11 @@ impl OpenHumanTurnPrelude {
mutable.last_memory_context = (!context.is_empty()).then_some(context);
}
run_context.response_shape = turn.response_shape.clone();
- run_context.attach_parent(self.parent_context());
+ let inherited_workspace = run_context
+ .parent
+ .as_ref()
+ .and_then(|parent| parent.workspace_descriptor.clone());
+ run_context.attach_parent(self.parent_context(inherited_workspace));
self.apply_pending_announcements(&mut enriched);
run_context.attachment_placeholders = Arc::new(
crate::agent::multimodal::extract_image_placeholders_in_text(original_user_message),
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
index d4a915abbe..0f761cbee3 100644
--- 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
@@ -3,8 +3,12 @@
use super::*;
impl OpenHumanTurnPrelude {
+ /// `inherited_workspace` is the workspace descriptor of the parent this
+ /// turn itself runs under (`run_context.parent`), when the turn is a
+ /// sub-agent's; it takes precedence over the session's own descriptor.
pub(in crate::agent::session_host) fn parent_context(
&self,
+ inherited_workspace: Option<tinytools::WorkspaceDescriptor>,
) -> crate::agent::harness::ParentExecutionContext {
let surface = self
.tool_surface
@@ -33,8 +37,7 @@ impl OpenHumanTurnPrelude {
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)
+ workspace_descriptor: inherited_workspace
.or_else(|| self.workspace_descriptor.clone()),
agent_config: self.config.clone(),
workflows: Arc::new(workflows),
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index 5f7f35ee42..8d093aacd5 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -36,15 +36,9 @@ use super::{
fn root_context_from_options(
options: &SubagentRunOptions,
) -> crate::agent::tinyagents::host::OpenHumanRunContext {
- let mut context = options.run_context.clone();
- // The public convenience entrypoint is also used inside a parent turn by
- // legacy callers and test fixtures. Preserve that parent lineage when the
- // explicit carrier has not already supplied one; an explicit value always
- // wins so a caller cannot be silently re-bound to an ambient turn.
- if context.parent.is_none() {
- context.parent = crate::agent::harness::current_parent();
- }
- context
+ // The parent lineage is exactly what the caller put on the explicit
+ // carrier (`run_context.parent`); nothing is re-bound from an ambient turn.
+ options.run_context.clone()
}
/// Runs one host subagent through a neutral driver using a real direct child.