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
fix(core): resolve a caller-supplied agent definition by its own id
M3gA-Mind9d99648e3d78
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rsindex 7ef862982f..8d27fc8806 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs@@ -296,6 +296,9 @@ impl SessionHostBuilder {definitions,memory: Arc::clone(&memory),post_turn_hooks: self.post_turn_hooks.clone(),+ // This path names a registry id; it never carries a+ // caller-supplied definition.+ session_definition: None,})});diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rsindex 1b14220b44..2f86ad0306 100644--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs@@ -1036,6 +1036,14 @@ impl OpenHumanSessionHost {security_policy: security,memory: agent.memory_arc(),post_turn_hooks: agent.post_turn_hooks.clone(),+ // The caller's own definition, when this session was built from+ // one rather than from a registry id. `AgentSpec::into_core`+ // re-stamps the built-in orchestrator under the caller's id, so+ // ids like `harness`/`alpha`/`beta` reach hosted resolution as+ // names no registry holds; without handing the definition over+ // here the lookup misses and the turn is rejected as a policy+ // failure before any provider call (#6404/#6392/#6393).+ session_definition: target_def.cloned().map(Arc::new),})});if agent.hosted_base.is_none() {diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rsindex a5ab3817c8..0924545c24 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs@@ -40,6 +40,8 @@ pub struct OpenHumanHostBundleInputs {pub tool_policy: Option<Arc<ToolPolicySession>>,pub memory: Arc<dyn Memory>,pub post_turn_hooks: Vec<Arc<dyn PostTurnHook>>,+ /// See [`OpenHumanHostBase::session_definition`].+ pub session_definition: Option<Arc<crate::agent::harness::definition::AgentDefinition>>,}/// Process/session-owned dependencies shared by hosted invocations.@@ -54,6 +56,13 @@ pub struct OpenHumanHostBase {pub security_policy: Arc<SecurityPolicy>,pub memory: Arc<dyn Memory>,pub post_turn_hooks: Vec<Arc<dyn PostTurnHook>>,+ /// The session's own caller-supplied definition, when it was built from one+ /// rather than from a registry id — see+ /// [`OpenHumanDefinitionRegistry::with_session_definition`]. Lives here, beside+ /// the registry it outranks, because it is fixed for the session's lifetime:+ /// one `Runtime` hosts several independently defined agents, but each gets+ /// its own session and therefore its own base.+ pub session_definition: Option<Arc<crate::agent::harness::definition::AgentDefinition>>,}/// Explicit inputs which vary for every hosted agent invocation.@@ -103,6 +112,7 @@ impl OpenHumanHostBundleFactory {tool_policy: inputs.tool_policy,memory: inputs.base.memory.clone(),post_turn_hooks: inputs.base.post_turn_hooks.clone(),+ session_definition: inputs.base.session_definition.clone(),},turn,);@@ -140,12 +150,14 @@ impl OpenHumanHostBundleFactory {.map(|tool| tool.name().to_string()).collect(),);- let definitions = Arc::new(- OpenHumanDefinitionRegistry::new(inputs.definitions)- .with_config(Arc::clone(&inputs.config))- .with_registered_tools(registered_tools)- .with_session_delegation_tools(session_delegation_tools),- );+ let mut definitions_adapter = OpenHumanDefinitionRegistry::new(inputs.definitions)+ .with_config(Arc::clone(&inputs.config))+ .with_registered_tools(registered_tools)+ .with_session_delegation_tools(session_delegation_tools);+ if let Some(definition) = inputs.session_definition {+ definitions_adapter = definitions_adapter.with_session_definition(definition);+ }+ let definitions = Arc::new(definitions_adapter);let mut security = OpenHumanSecurityGate::new(inputs.security_policy, inputs.tool_sets);if let Some(policy) = inputs.tool_policy {security = security.with_tool_policy(policy);diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle_tests.rsindex da857a9103..5a37a78b94 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle_tests.rs@@ -24,6 +24,7 @@ fn inputs() -> (OpenHumanHostBundleInputs, OpenHumanRunContext) {tool_policy: None,memory,post_turn_hooks: Vec::new(),+ session_definition: None,},turn,)diff --git a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rsindex 97b9237526..52a529dc17 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs@@ -143,6 +143,24 @@ pub struct OpenHumanDefinitionRegistry {/// tool registry. They must augment a named root scope so the hosted loop/// authorizes the same hand-off routes it advertises.session_delegation_tools: Option<Arc<Vec<String>>>,+ /// The session's own caller-supplied definition, when it has one.+ ///+ /// A library host builds its agent from a definition it owns and passes by+ /// value (`AgentChatTarget::Definition`), which `from_config_with_definition`+ /// stamps on the session and inserts into no registry. `AgentSpec::into_core`+ /// re-stamps the built-in orchestrator under the caller's own id, so ids like+ /// `harness`, `alpha` and `beta` are names no registry has ever held — the+ /// hosted lookup below missed every time, the harness raised+ /// `TinyAgentsError::Validation`, and `hosted_error` sanitized that into+ /// "hosted agent invocation was rejected by policy" with zero provider calls+ /// (#6404, #6392, #6393).+ ///+ /// Consulted BEFORE the registry, which is the precedence+ /// `OpenHumanSessionHost::resolved_definition` already documents and+ /// `resolved_definition_prefers_the_sessions_own_over_a_same_id_registry_entry`+ /// already pins: a library host may legitimately reuse an id the process+ /// registry also knows, and its own definition must win.+ session_definition: Option<Arc<HostAgentDefinition>>,}/// Outcome of resolving a definition's own scope.@@ -166,6 +184,7 @@ impl OpenHumanDefinitionRegistry {config: None,registered_tools: None,session_delegation_tools: None,+ session_definition: None,}}@@ -181,6 +200,7 @@ impl OpenHumanDefinitionRegistry {config: None,registered_tools: None,session_delegation_tools: None,+ session_definition: None,})}@@ -213,6 +233,15 @@ impl OpenHumanDefinitionRegistry {self}+ /// Attaches the session's own definition, which outranks the registry.+ ///+ /// See [`Self::session_definition`] — without this a caller-supplied+ /// definition is unresolvable by the id it was stamped with.+ pub fn with_session_definition(mut self, definition: Arc<HostAgentDefinition>) -> Self {+ self.session_definition = Some(definition);+ self+ }+/// Resolves `id` to a **host** definition: harness registry first, then the/// enabled custom-agent config fallback.///@@ -223,6 +252,13 @@ impl OpenHumanDefinitionRegistry {/// deliberately not re-implemented here.fn host_definition(&self, id: &str) -> Option<HostAgentDefinition> {let id = id.trim();+ if let Some(def) = self+ .session_definition+ .as_deref()+ .filter(|def| def.id.trim() == id)+ {+ return Some(def.clone());+ }if let Some(def) = self.registry.get().get(id) {return Some(def.clone());}diff --git a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rsindex f19cb8bc39..57871683cc 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs@@ -434,3 +434,93 @@ async fn an_empty_catalogue_misses_everything_without_erroring() {.expect("delegates").is_empty());}++/// The defect behind #6404 / #6392 / #6393, at the layer that caused it.+///+/// A library host builds its agent from a definition it owns and never+/// registers: `AgentSpec::into_core` re-stamps the built-in orchestrator under+/// the caller's id, so `harness` / `alpha` / `beta` reach hosted resolution as+/// ids no registry holds. Before the session-definition seam this lookup+/// missed, `prepare_agent_turn` raised `TinyAgentsError::Validation`, and the+/// harness's `hosted_error` sanitized that into "hosted agent invocation was+/// rejected by policy" — reported with zero provider calls, because the miss+/// happens during turn preparation, before the loop runs.+#[tokio::test]+async fn a_caller_supplied_definition_resolves_under_its_own_unregistered_id() {+ // Exactly the shape the embed harness produces: an id no registry knows.+ let caller = synthetic("harness", AgentTier::Worker, &[]);+ let registry = registry_of(vec![synthetic("orchestrator", AgentTier::Chat, &[])]);++ // Without the session definition the id is simply absent — this is the+ // miss that became "rejected by policy".+ assert!(+ registry.resolve("harness").await.unwrap().is_none(),+ "precondition: an unregistered caller id must not resolve from the registry alone"+ );++ let with_session = registry_of(vec![synthetic("orchestrator", AgentTier::Chat, &[])])+ .with_session_definition(Arc::new(caller));+ let resolved = with_session+ .resolve("harness")+ .await+ .unwrap()+ .expect("the session's own definition must resolve under its own id");+ assert_eq!(resolved.id, "harness");+}++/// The session's own definition outranks a same-id registry entry.+///+/// This is the precedence `OpenHumanSessionHost::resolved_definition` already+/// documents and `resolved_definition_prefers_the_sessions_own_over_a_same_id_registry_entry`+/// pins for the session's own reads; hosted resolution must not disagree with+/// it, or a library host reusing a built-in id would silently run the+/// built-in's definition instead of its own.+#[tokio::test]+async fn the_sessions_own_definition_outranks_a_same_id_registry_entry() {+ let mut caller = synthetic("orchestrator", AgentTier::Worker, &[]);+ caller.display_name = Some("the caller's own".to_string());++ let registry = registry_of(vec![synthetic("orchestrator", AgentTier::Chat, &[])])+ .with_session_definition(Arc::new(caller));++ let resolved = registry+ .resolve("orchestrator")+ .await+ .unwrap()+ .expect("orchestrator resolves");+ // `project` maps `name` from `display_name()`, which only the caller's copy+ // sets — had the registry entry won, this would be its own display name.+ assert_eq!(+ resolved.name, "the caller's own",+ "the session's own definition must win over the same-id registry entry"+ );+ // And the tier travels with it: the registry entry is Chat-tier (what the+ // real `orchestrator` is), the caller's copy is a Worker, so a stale+ // registry hit would show up here too.+ assert_eq!(+ resolved.role.as_deref(),+ Some(AgentTier::Worker.to_string()).as_deref(),+ "the winning definition's tier must be the caller's"+ );+}++/// A session definition must not answer for an id that is not its own.+#[tokio::test]+async fn a_session_definition_does_not_shadow_other_ids() {+ let registry = registry_of(vec![synthetic("orchestrator", AgentTier::Chat, &[])])+ .with_session_definition(Arc::new(synthetic("harness", AgentTier::Worker, &[])));++ assert_eq!(+ registry+ .resolve("orchestrator")+ .await+ .unwrap()+ .map(|def| def.id),+ Some("orchestrator".to_string()),+ "a session definition must not capture lookups for other ids"+ );+ assert!(+ registry.resolve("no-such-agent").await.unwrap().is_none(),+ "a session definition must not answer for an unrelated missing id"+ );+}diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rsindex 6669d9c202..1e5ff31aa7 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs@@ -12,6 +12,7 @@ fn hosted_base() -> Arc<crate::agent::tinyagents::host::OpenHumanHostBase> {security_policy: Arc::new(crate::security::policy::SecurityPolicy::default()),memory: crate::memory::test_support::noop_memory(),post_turn_hooks: Vec::new(),+ session_definition: None,})}diff --git a/crates/openhuman-embed/tests/harness_embed.rs b/crates/openhuman-embed/tests/harness_embed.rsindex c418221f9f..9bc9e41e53 100644--- a/crates/openhuman-embed/tests/harness_embed.rs+++ b/crates/openhuman-embed/tests/harness_embed.rs@@ -28,7 +28,6 @@ use wiremock::{Mock, MockServer, ResponseTemplate};const REPLY: &str = "harness-embed-ok";#[test]-#[ignore = "TODO(#6392): TinyAgents policy migration rejects the caller-supplied mock provider in CI"]fn a_harness_runs_a_turn_against_the_provider_it_was_given() {let _ = env_logger::builder().is_test(true).try_init();diff --git a/crates/openhuman-embed/tests/runtime_agents.rs b/crates/openhuman-embed/tests/runtime_agents.rsindex 8a432756b4..4dcbbf3673 100644--- a/crates/openhuman-embed/tests/runtime_agents.rs+++ b/crates/openhuman-embed/tests/runtime_agents.rs@@ -37,7 +37,6 @@ fn skills_fixture() -> tempfile::TempDir {}#[test]-#[ignore = "TODO(#6393): TinyAgents policy migration rejects caller-provided agent providers"]fn one_runtime_hosts_independently_configured_agents() {let _ = env_logger::builder().is_test(true).try_init();