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
chore: files changed crates/openhuman-core/src/agent/host_agents.rs,crates/openhuman-core/src/agent/
Steven Enamakel2a644d1afe44
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rsindex 3b791f142f..469b75e68d 100644--- a/crates/openhuman-core/src/agent/host_agents.rs+++ b/crates/openhuman-core/src/agent/host_agents.rs@@ -93,6 +93,7 @@ impl HostAgent {// the learning sink.session.set_host_env(crate::agent::turn_env::HostTurnEnv {hooks: self.hooks.clone(),+ core: Some(Arc::clone(&self.context)),..Default::default()});Ok(session)diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rsindex 0d02903552..c732cad534 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs@@ -29,6 +29,11 @@ impl OpenHumanSessionHost {) -> Result<String> {self.ensure_runtime_session()?;let staged = super::attachment_input::stage_turn(self, user_message, origin).await?;+ // The turn's context is bound once, here: the one ambient read at the+ // turn boundary for a host that did not hand a context over.+ if self.host_env.core.is_none() {+ self.host_env.core = crate::core::runtime::DispatchCtx::ambient().into_core();+ }let mut context = OpenHumanRunContext::new().with_host_env(&self.host_env);context.untrusted_input_turn = self.untrusted_input;context.origin = origin.cloned();diff --git a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rsindex 903eda75f7..c1a73e7c4d 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs@@ -20,6 +20,29 @@ pub(crate) struct HostOperationContext {/// Who the run acts as on memory; see/// [`OpenHumanRunContext::memory_identity`](super::OpenHumanRunContext::memory_identity).pub(crate) memory_identity: Option<crate::memory::scope::MemoryIdentity>,+ /// The context the run acts under; see+ /// [`OpenHumanRunContext::core`](super::OpenHumanRunContext::core).+ pub(crate) core: Option<std::sync::Arc<crate::core::runtime::CoreContext>>,+}++/// The dispatch context of the run a tool executes in, from the explicit tool+/// carrier. Direct tool dispatch (CLI, JSON-RPC, tests) has no run, so it+/// answers with the calling task's own context, which is what such a call has+/// always acted under.+pub(crate) fn dispatch_ctx_for_tool(+ context: Option<&dyn tinytools::ToolRunContext>,+) -> crate::core::runtime::DispatchCtx {+ let core = 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.core.clone());+ match core {+ Some(core) => crate::core::runtime::DispatchCtx::new(core),+ None => crate::core::runtime::DispatchCtx::ambient(),+ }}/// Reads the spawning agent's definition id from the explicit tool carrier.diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rsindex b8ba24bc21..39d11d65b9 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs@@ -309,6 +309,11 @@ pub struct OpenHumanRunContext {pub prepared_context_sources: Arc<Vec<AgentContextPreparedSource>>,/// Who the run acts as on memory; `None` is the root identity.pub memory_identity: Option<crate::memory::scope::MemoryIdentity>,+ /// The context the turn runs under. Tools, middleware and the provider+ /// factory read it from here ([`dispatch_ctx_for_tool`]) instead of the+ /// calling task's ambient scope. Inherited by children and detached+ /// children: a sub-agent acts for the same tenant as its parent.+ pub core: Option<Arc<crate::core::runtime::CoreContext>>,/// File-state identity used to detect stale parent reads after child writes.pub file_state_agent_id: Option<String>,/// Host-owned artifact index for tool-result references.@@ -410,7 +415,7 @@ pub(crate) struct HarnessHostPolicy {}pub(crate) use super::operation_context::{- approval_for_tool, memory_identity_for_tool, parent_agent_id_for_tool, sandbox_mode_for_tool,+ approval_for_tool, dispatch_ctx_for_tool, memory_identity_for_tool, parent_agent_id_for_tool, sandbox_mode_for_tool,HostOperationContext,};#[cfg(test)]@@ -472,6 +477,7 @@ impl OpenHumanRunContext {parent: None,prepared_context_sources: Arc::new(Vec::new()),memory_identity: None,+ core: None,file_state_agent_id: None,tool_result_artifact_index: None,attachment_placeholders: Arc::new(Vec::new()),@@ -512,6 +518,22 @@ impl OpenHumanRunContext {self}+ /// Binds the context this run acts under.+ #[must_use]+ pub fn with_core(mut self, core: Option<Arc<crate::core::runtime::CoreContext>>) -> Self {+ self.core = core;+ self+ }++ /// The dispatch context this run's readers (config, tenant stores) use:+ /// the run's own context, else unbound.+ pub fn dispatch_ctx(&self) -> crate::core::runtime::DispatchCtx {+ match &self.core {+ Some(core) => crate::core::runtime::DispatchCtx::new(Arc::clone(core)),+ None => crate::core::runtime::DispatchCtx::unbound(),+ }+ }+/// Sets the direct TinyTools workspace descriptor for this run.pub fn with_workspace(mut self, workspace: tinytools::WorkspaceDescriptor) -> Self {self.workspace = Some(workspace);@@ -593,6 +615,7 @@ impl OpenHumanRunContext {self.turn_deadline = env.turn_deadline.or(self.turn_deadline);self.tool_call_limit = env.tool_call_limit.or(self.tool_call_limit);self.memory_identity = env.memory_identity.clone().or(self.memory_identity);+ self.core = env.core.clone().or(self.core);self.stop_hooks.extend(env.hooks.stop_hooks().iter().cloned());self.tool_hooks@@ -684,6 +707,7 @@ impl OpenHumanRunContext {.as_ref().map(|parent| parent.agent_definition_id.clone()),memory_identity: self.memory_identity.clone(),+ core: self.core.clone(),});let context = tinyagents_harness::context::RunContext::new(config, self).with_cancellation(cancellation)diff --git a/crates/openhuman-core/src/agent/turn_env.rs b/crates/openhuman-core/src/agent/turn_env.rsindex 95fce2f79b..9d9a926126 100644--- a/crates/openhuman-core/src/agent/turn_env.rs+++ b/crates/openhuman-core/src/agent/turn_env.rs@@ -57,6 +57,12 @@ pub struct HostTurnEnv {/// root identity. Unlike `approval` it follows delegation, so runs started/// from a parent snapshot keep the parent's team.pub memory_identity: Option<crate::memory::scope::MemoryIdentity>,+ /// The [`CoreContext`](crate::core::runtime::CoreContext) the turn runs+ /// under (the tenant's, an embedded agent's, or the host's own). The+ /// session copies it onto the turn's run context, from which tools,+ /// middleware and the provider factory read it; `None` leaves the session+ /// to bind the calling task's context when the turn starts.+ pub core: Option<std::sync::Arc<crate::core::runtime::CoreContext>>,}impl std::fmt::Debug for HostTurnEnv {@@ -71,6 +77,7 @@ impl std::fmt::Debug for HostTurnEnv {.field("fresh_tool_snapshot", &self.fresh_tool_snapshot).field("approval", &self.approval).field("memory_identity", &self.memory_identity)+ .field("core", &self.core.is_some()).finish()}}