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): store resolved definition on session for in-turn access
Steven Enamakel0d967dafdae9
diff --git a/crates/openhuman-core/src/agent/harness/session/builder/builder_build.rs b/crates/openhuman-core/src/agent/harness/session/builder/builder_build.rsindex 131e7d761f..ccee073672 100644--- a/crates/openhuman-core/src/agent/harness/session/builder/builder_build.rs+++ b/crates/openhuman-core/src/agent/harness/session/builder/builder_build.rs@@ -281,6 +281,7 @@ impl AgentBuilder {connected_integrations: Vec::new(),connected_integrations_initialized: false,runtime_config: None,+ definition: None,// Default to `true` (omit) so legacy / custom agents built// without a definition stay lean. Opt-in agents thread their// `omit_profile = false` through the builder.diff --git a/crates/openhuman-core/src/agent/harness/session/builder/factory.rs b/crates/openhuman-core/src/agent/harness/session/builder/factory.rsindex 1712541329..9d521454d9 100644--- a/crates/openhuman-core/src/agent/harness/session/builder/factory.rs+++ b/crates/openhuman-core/src/agent/harness/session/builder/factory.rs@@ -123,6 +123,38 @@ impl Agent {)}+ /// Build a session agent from a definition the caller already holds,+ /// rather than an id resolved through `AgentDefinitionRegistry::global()`+ /// or `config.agent_registry`.+ ///+ /// The definition is authoritative for this agent's prompt, tool scope,+ /// sandbox mode and delegation allowlist; it is stamped on the session so+ /// in-turn readers ([`Agent::resolved_definition`]) never fall back to a+ /// registry entry that happens to share its id. This is the constructor a+ /// library host uses to run many independently specified agents on one+ /// booted core.+ pub fn from_config_with_definition(+ config: &Config,+ definition: &crate::agent::harness::definition::AgentDefinition,+ profile: Option<&crate::agent::profiles::AgentProfile>,+ profile_prompt_suffix: Option<String>,+ ) -> Result<Self> {+ log::debug!(+ "[agent] from_config_with_definition id={} sandbox={:?} profile={:?}",+ definition.id,+ definition.sandbox_mode,+ profile.map(|p| p.id.as_str())+ );+ Self::build_session_agent_inner(+ config,+ &definition.id,+ Some(definition),+ profile_prompt_suffix,+ false,+ profile,+ )+ }+/// Internal constructor that consumes the optionally-resolved agent/// definition. Split out from [`Agent::from_config_for_agent`] so/// the lookup + logging live in one place and the heavy-lifting@@ -1275,6 +1307,7 @@ impl Agent {// second resident copy of a 95-field struct with nested `Vec`s// (openhuman#6218).agent.runtime_config = Some(Arc::clone(&base_config));+ agent.definition = target_def.cloned().map(Arc::new);agent.last_seen_integrations_hash =crate::integrations::composio::connected_set_hash(&agent.connected_integrations);Ok(agent)diff --git a/crates/openhuman-core/src/agent/harness/session/runtime/accessors.rs b/crates/openhuman-core/src/agent/harness/session/runtime/accessors.rsindex 13335e82fc..836b7a815f 100644--- a/crates/openhuman-core/src/agent/harness/session/runtime/accessors.rs+++ b/crates/openhuman-core/src/agent/harness/session/runtime/accessors.rs@@ -147,6 +147,25 @@ impl Agent {self.runtime_config.clone()}+ /// The definition this session runs under: the one it was built from when+ /// the factory had one, else the process registry's entry for+ /// `agent_definition_id`.+ ///+ /// Prefer this over a bare `AgentDefinitionRegistry::global().get(..)` in+ /// turn-path code that needs the agent's *own* settings (`sandbox_mode`,+ /// `subagents`): a session built from an explicit definition must not have+ /// them replaced by a same-id registry entry.+ pub(crate) fn resolved_definition(+ &self,+ ) -> Option<Arc<crate::agent::harness::definition::AgentDefinition>> {+ self.definition.clone().or_else(|| {+ crate::agent::harness::definition::AgentDefinitionRegistry::global()+ .and_then(|registry| registry.get(&self.agent_definition_id))+ .cloned()+ .map(Arc::new)+ })+ }+/// Whether the config-dependent capability adapters can be built from this/// session.///diff --git a/crates/openhuman-core/src/agent/harness/session/turn/core/harness_turn.rs b/crates/openhuman-core/src/agent/harness/session/turn/core/harness_turn.rsindex 4921821c3b..de1469c525 100644--- a/crates/openhuman-core/src/agent/harness/session/turn/core/harness_turn.rs+++ b/crates/openhuman-core/src/agent/harness/session/turn/core/harness_turn.rs@@ -185,11 +185,10 @@ impl Agent {// Scope direct Master-Agent calls under its declared// sandbox. `agent_definition_name` can carry a thread// suffix, so resolve with the stable definition id.- sandbox_mode:- crate::agent::harness::definition::AgentDefinitionRegistry::global()- .and_then(|registry| registry.get(&self.agent_definition_id))- .map(|definition| definition.sandbox_mode)- .unwrap_or(crate::agent::harness::definition::SandboxMode::None),+ sandbox_mode: self+ .resolved_definition()+ .map(|definition| definition.sandbox_mode)+ .unwrap_or(crate::agent::harness::definition::SandboxMode::None),}),),);diff --git a/crates/openhuman-core/src/agent/harness/session/turn/tools.rs b/crates/openhuman-core/src/agent/harness/session/turn/tools.rsindex 4bb2921eb8..686513620a 100644--- a/crates/openhuman-core/src/agent/harness/session/turn/tools.rs+++ b/crates/openhuman-core/src/agent/harness/session/turn/tools.rs@@ -42,10 +42,9 @@ impl Agent {"[agent_loop] snapshotting workspace descriptor for parent context (ambient or own)");}- let allowed_subagent_ids =- crate::agent::harness::definition::AgentDefinitionRegistry::global()- .and_then(|registry| registry.get(&self.agent_definition_id))- .map(|definition| {+ let allowed_subagent_ids = self+ .resolved_definition()+ .map(|definition| {definition.subagents.iter()@@ -576,7 +575,7 @@ impl Agent {// whatever the builder produced.return;};- let Some(def) = reg.get(&self.agent_definition_id) else {+ let Some(def) = self.resolved_definition() else {log::debug!("[agent] refresh_delegation_tools: definition '{}' not in registry — skipping",self.agent_definition_iddiff --git a/crates/openhuman-core/src/agent/harness/session/types.rs b/crates/openhuman-core/src/agent/harness/session/types.rsindex 7200edd293..e860e6d266 100644--- a/crates/openhuman-core/src/agent/harness/session/types.rs+++ b/crates/openhuman-core/src/agent/harness/session/types.rs@@ -370,6 +370,14 @@ pub struct Agent {/// re-run `Config::load_or_init()` on the hot path just to key into/// the Composio cache.pub(super) runtime_config: Option<Arc<crate::config::Config>>,+ /// The definition this session was built from, when the factory had one.+ ///+ /// Read back through [`Agent::resolved_definition`] by the in-turn sites+ /// that need the definition's `sandbox_mode` or `subagents` — so an agent+ /// built from an explicit definition (a library host's per-agent spec)+ /// keeps those settings instead of having them silently replaced by+ /// whatever the process-global registry holds under the same id.+ pub(super) definition: Option<Arc<crate::agent::harness::definition::AgentDefinition>>,/// Mirrors the agent definition's `omit_profile` flag. Threaded into/// [`PromptContext::include_profile`] in `turn::build_system_prompt`/// so only user-facing agents (welcome, orchestrator, triggers)