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
feat(agent): add parent snapshot to runtime session
Steven Enamakel7957d66920c3
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex e53efe2194..210dc17ac7 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -484,11 +484,7 @@ impl OpenHumanTurnPrelude {mutable.last_memory_context = (!context.is_empty()).then_some(context);}run_context.response_shape = turn.response_shape.clone();- let inherited_workspace = run_context- .parent- .as_ref()- .and_then(|parent| parent.workspace_descriptor.clone());- run_context.attach_parent(self.parent_context(inherited_workspace));+ run_context.attach_parent(self.parent_context(run_context.parent.as_ref()));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.rsindex 018ced1ee0..26c646940f 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,12 +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.+ /// `inherited` is the parent this turn itself runs under+ /// (`run_context.parent`), when the turn is a sub-agent's; its workspace+ /// descriptor takes precedence over the session's own.pub(in crate::agent::session_host) fn parent_context(&self,- inherited_workspace: Option<tinytools::WorkspaceDescriptor>,+ inherited: Option<&crate::agent::harness::ParentExecutionContext>,) -> crate::agent::harness::ParentExecutionContext {let surface = self.tool_surfacediff --git a/crates/openhuman-core/src/agent/tinyagents/host/mod.rs b/crates/openhuman-core/src/agent/tinyagents/host/mod.rsindex c9d2e1c341..11b11d6f89 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/mod.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/mod.rs@@ -34,6 +34,7 @@ pub mod definition_registry;pub mod delegation;pub mod learning_sink;pub mod model_resolver;+mod operation_context;pub mod progress_sink;pub mod run_context;pub mod security_gate;diff --git a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rsnew file mode 100644index 0000000000..377a8fce3c--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs@@ -0,0 +1,45 @@+//! The immutable authority view the run exposes to shared tools through the+//! harness's typed state-view seam, and the readers tools use on it.++use crate::agent::turn_origin::AgentTurnOrigin;+use tinyagents_definition::SandboxMode;++/// Minimal immutable authority view exposed to shared tools through the+/// harness's typed state-view seam.+#[derive(Clone, Debug, Default)]+pub(crate) struct HostOperationContext {+ pub(crate) origin: Option<AgentTurnOrigin>,+ pub(crate) sandbox_mode: Option<SandboxMode>,+ /// The agent definition the run's parent execution context belongs to, for+ /// tools that act on behalf of the spawning agent when no memory identity+ /// is scoped (see `memory::tools::CallFacts::gather`).+ pub(crate) parent_agent_id: Option<String>,+}++/// Reads the spawning agent's definition id from the explicit tool carrier.+/// Direct tool dispatch has no parent.+pub(crate) fn parent_agent_id_for_tool(+ context: Option<&dyn tinytools::ToolRunContext>,+) -> Option<String> {+ context+ .and_then(tinytools::ToolRunContext::host_extension)+ .and_then(|extension| {+ extension.downcast_ref::<tinyagents_harness::tool::ToolExecutionContext>()+ })+ .and_then(|context| context.state::<HostOperationContext>())+ .and_then(|host| host.parent_agent_id.clone())+}++/// Reads the calling agent's sandbox policy from the explicit tool carrier.+/// Direct tool dispatch has no agent-specific mode.+pub(crate) fn sandbox_mode_for_tool(+ context: Option<&dyn tinytools::ToolRunContext>,+) -> Option<SandboxMode> {+ context+ .and_then(tinytools::ToolRunContext::host_extension)+ .and_then(|extension| {+ extension.downcast_ref::<tinyagents_harness::tool::ToolExecutionContext>()+ })+ .and_then(|context| context.state::<HostOperationContext>())+ .and_then(|host| host.sandbox_mode)+}diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rsindex 7264e5ff98..24ed24171b 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs@@ -402,45 +402,9 @@ pub(crate) struct HarnessHostPolicy {pub(crate) tool_call_cap: Option<usize>,}-/// Minimal immutable authority view exposed to shared tools through the-/// harness's typed state-view seam.-#[derive(Clone, Debug, Default)]-pub(crate) struct HostOperationContext {- pub(crate) origin: Option<AgentTurnOrigin>,- pub(crate) sandbox_mode: Option<SandboxMode>,- /// The agent definition the run's parent execution context belongs to, for- /// tools that act on behalf of the spawning agent when no memory identity- /// is scoped (see `memory::tools::CallFacts::gather`).- pub(crate) parent_agent_id: Option<String>,-}--/// Reads the spawning agent's definition id from the explicit tool carrier.-/// Direct tool dispatch has no parent.-pub(crate) fn parent_agent_id_for_tool(- context: Option<&dyn tinytools::ToolRunContext>,-) -> Option<String> {- context- .and_then(tinytools::ToolRunContext::host_extension)- .and_then(|extension| {- extension.downcast_ref::<tinyagents_harness::tool::ToolExecutionContext>()- })- .and_then(|context| context.state::<HostOperationContext>())- .and_then(|host| host.parent_agent_id.clone())-}--/// Reads the calling agent's sandbox policy from the explicit tool carrier.-/// Direct tool dispatch has no agent-specific mode.-pub(crate) fn sandbox_mode_for_tool(- context: Option<&dyn tinytools::ToolRunContext>,-) -> Option<SandboxMode> {- context- .and_then(tinytools::ToolRunContext::host_extension)- .and_then(|extension| {- extension.downcast_ref::<tinyagents_harness::tool::ToolExecutionContext>()- })- .and_then(|context| context.state::<HostOperationContext>())- .and_then(|host| host.sandbox_mode)-}+pub(crate) use super::operation_context::{+ parent_agent_id_for_tool, sandbox_mode_for_tool, HostOperationContext,+};/// OpenHuman product values that tools read from the run through/// `ToolExecutionContext::host::<OpenHumanRunExt>()`, installed bydiff --git a/scripts/ci/check-openhuman-rust-layout.mjs b/scripts/ci/check-openhuman-rust-layout.mjsindex fe443fdaed..2a03479cc1 100644--- a/scripts/ci/check-openhuman-rust-layout.mjs+++ b/scripts/ci/check-openhuman-rust-layout.mjs@@ -35,7 +35,7 @@ const LEGACY_LIMIT_ENTRIES = [// state moved to tinyagents-runtime; this remaining composition is split in// a follow-up without reintroducing an old harness/session exception.["crates/openhuman-core/src/agent/session_host/builder/factory.rs", 974],- ["crates/openhuman-core/src/agent/subagent_host/lifecycle.rs", 1247],+ ["crates/openhuman-core/src/agent/subagent_host/lifecycle.rs", 1241],["crates/openhuman-core/src/agent/subagent_host/ops/runner.rs", 1045],["crates/openhuman-core/src/web_chat/progress_bridge.rs", 1209],// These established external test modules grew with upstream coverage. Pin