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): resolve the sub-agent catalogue through the agent context (#7032)
oxoxDevf16b76ddd54e
diff --git a/crates/openhuman-core/src/agent/bus.rs b/crates/openhuman-core/src/agent/bus.rsindex 000d4242f9..c18f3842ab 100644--- a/crates/openhuman-core/src/agent/bus.rs+++ b/crates/openhuman-core/src/agent/bus.rs@@ -272,8 +272,10 @@ async fn handle_agent_run_turn(req: AgentTurnRequest) -> Result<AgentTurnRespons// the bus without bootstrapping definitions).let sandbox_mode = target_agent_id.as_deref()- .and_then(|id| AgentDefinitionRegistry::global().and_then(|reg| reg.get(id)))- .map(|def| def.sandbox_mode)+ .and_then(|id| {+ AgentDefinitionRegistry::current()+ .and_then(|reg| reg.get(id).map(|def| def.sandbox_mode))+ }).unwrap_or(SandboxMode::None);// Scope the caller-supplied origin around the tool loop sodiff --git a/crates/openhuman-core/src/agent/debug/mod.rs b/crates/openhuman-core/src/agent/debug/mod.rsindex 19df0b49f9..9e2e20eace 100644--- a/crates/openhuman-core/src/agent/debug/mod.rs+++ b/crates/openhuman-core/src/agent/debug/mod.rs@@ -119,7 +119,7 @@ pub async fn dump_all_agent_prompts(AgentDefinitionRegistry::init_global(&config.workspace_dir).context("initialising AgentDefinitionRegistry for prompt dump")?;- let registry = AgentDefinitionRegistry::global()+ let registry = AgentDefinitionRegistry::current().ok_or_else(|| anyhow!("AgentDefinitionRegistry missing after init"))?;let ids: Vec<String> = registrydiff --git a/crates/openhuman-core/src/agent/harness/definition/registry.rs b/crates/openhuman-core/src/agent/harness/definition/registry.rsindex 460f2e4258..f1e67ea27b 100644--- a/crates/openhuman-core/src/agent/harness/definition/registry.rs+++ b/crates/openhuman-core/src/agent/harness/definition/registry.rs@@ -151,4 +151,25 @@ impl AgentDefinitionRegistry {pub fn global_arc() -> Option<Arc<Self>> {GLOBAL.get().cloned()}++ /// The catalogue sub-agent lookups resolve through: the ambient agent+ /// context's own registry when it carries one, else the process registry.+ pub fn current() -> Option<Arc<Self>> {+ crate::core::runtime::CoreContext::current()+ .and_then(|ctx| ctx.definitions())+ .or_else(Self::global_arc)+ }++ /// A copy of this registry with `definitions` added, replacing any+ /// definition with the same id.+ pub fn with_definitions(&self, definitions: impl IntoIterator<Item = AgentDefinition>) -> Self {+ let mut registry = Self::default();+ for definition in self.list() {+ registry.insert(definition.clone());+ }+ for definition in definitions {+ registry.insert(definition);+ }+ registry+ }}diff --git a/crates/openhuman-core/src/agent/library/ops.rs b/crates/openhuman-core/src/agent/library/ops.rsindex 2879b7c5ba..92a89073d2 100644--- a/crates/openhuman-core/src/agent/library/ops.rs+++ b/crates/openhuman-core/src/agent/library/ops.rs@@ -13,7 +13,7 @@ pub async fn list_definition_metadata() -> Result<Vec<AgentDefinitionDisplay>, SAgentDefinitionRegistry::init_global(&config.workspace_dir).map_err(|e| format!("failed to initialise AgentDefinitionRegistry: {e}"))?;}- let registry = AgentDefinitionRegistry::global()+ let registry = AgentDefinitionRegistry::current().ok_or_else(|| "AgentDefinitionRegistry not initialised".to_string())?;let definitions = registry.list()diff --git a/crates/openhuman-core/src/agent/orchestration/command_center/schemas.rs b/crates/openhuman-core/src/agent/orchestration/command_center/schemas.rsindex 2b2b377b91..9b6c44d0c8 100644--- a/crates/openhuman-core/src/agent/orchestration/command_center/schemas.rs+++ b/crates/openhuman-core/src/agent/orchestration/command_center/schemas.rs@@ -147,9 +147,11 @@ fn handle_agent_work_control(params: Map<String, Value>) -> ControllerFuture {/// Resolve an agent id to its registry display name, if the registry is up and/// the agent is known. Returns `None` otherwise (e.g. custom/removed agents).fn resolve_display_name(agent_id: &str) -> Option<String> {- AgentDefinitionRegistry::global()- .and_then(|registry| registry.get(agent_id))- .map(|definition| definition.display_name().to_string())+ AgentDefinitionRegistry::current().and_then(|registry| {+ registry+ .get(agent_id)+ .map(|definition| definition.display_name().to_string())+ })}fn to_json<T: serde::Serialize>(value: T) -> Result<Value, String> {diff --git a/crates/openhuman-core/src/agent/orchestration/fleet_tools.rs b/crates/openhuman-core/src/agent/orchestration/fleet_tools.rsindex 1d01d9f9e7..b4e34920da 100644--- a/crates/openhuman-core/src/agent/orchestration/fleet_tools.rs+++ b/crates/openhuman-core/src/agent/orchestration/fleet_tools.rs@@ -44,7 +44,7 @@ impl FleetToolSet {/// Resolve the set for `agent_definition_id` from the global registry.pub(crate) fn for_parent(agent_definition_id: &str) -> Self {- let Some(registry) = AgentDefinitionRegistry::global() else {+ let Some(registry) = AgentDefinitionRegistry::current() else {return Self::all();};let Some(definition) = registry.get(agent_definition_id) else {diff --git a/crates/openhuman-core/src/agent/orchestration/ops.rs b/crates/openhuman-core/src/agent/orchestration/ops.rsindex eb03c1a018..299f8af01b 100644--- a/crates/openhuman-core/src/agent/orchestration/ops.rs+++ b/crates/openhuman-core/src/agent/orchestration/ops.rs@@ -338,9 +338,8 @@ impl AgentOrchestrationSession {let progress_sink = parent.on_progress.clone();if let Some(progress) = progress_sink.clone() {- let resolved_display_name = AgentDefinitionRegistry::global()- .and_then(|reg| reg.get(&agent_id))- .map(|def| def.display_name().to_string());+ let resolved_display_name = AgentDefinitionRegistry::current()+ .and_then(|reg| reg.get(&agent_id).map(|def| def.display_name().to_string()));let _ = progress.send(AgentProgress::SubagentSpawned {agent_id: agent_id.clone(),@@ -664,7 +663,7 @@ fn resolve_definition(request: &SpawnAgentRequest) -> Result<AgentDefinition, Orreturn Err(OrchestrationError::InvalidSpawnRequest);}let registry =- AgentDefinitionRegistry::global().ok_or(OrchestrationError::RegistryUnavailable)?;+ AgentDefinitionRegistry::current().ok_or(OrchestrationError::RegistryUnavailable)?;registry.get(agent_id).cloned()diff --git a/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rs b/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rsindex 63a5fd7390..8349ea765f 100644--- a/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rs+++ b/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rs@@ -47,7 +47,7 @@ pub(crate) async fn run_spawn_parallel_tasks_with_cancellation_and_workspace(max_parallel,"[spawn_parallel_agents] validated_parent_context");- let registry = match AgentDefinitionRegistry::global() {+ let registry = match AgentDefinitionRegistry::current() {Some(registry) => registry,None => {tracing::debug!("[spawn_parallel_agents] registry_unavailable");@@ -62,7 +62,7 @@ pub(crate) async fn run_spawn_parallel_tasks_with_cancellation_and_workspace(let progress_sink = parent.on_progress.clone();let action_root =resolve_spawn_parallel_action_root(parent_workspace_descriptor.as_ref()).await;- let definitions = snapshot_agent_definitions(registry);+ let definitions = snapshot_agent_definitions(®istry);if cancel.is_cancelled() {return Ok(SpawnParallelGraphOutcome::Cancelled("spawn_parallel_agents cancelled at validate".to_string(),diff --git a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rsindex a14e87b74d..04255ca5c8 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs@@ -372,7 +372,7 @@ impl ContinueSubagentTool {}// Look up the agent definition- let registry = match AgentDefinitionRegistry::global() {+ let registry = match AgentDefinitionRegistry::current() {Some(reg) => reg,None => {return Ok(ToolResult::error(diff --git a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rsindex 0208746795..46e18e27b0 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs@@ -111,7 +111,7 @@ impl Tool for DelegateGraphTool {}fn parameters_schema(&self) -> serde_json::Value {- let agent_ids: Vec<String> = AgentDefinitionRegistry::global()+ let agent_ids: Vec<String> = AgentDefinitionRegistry::current().map(|reg| reg.list().iter().map(|d| d.id.clone()).collect()).unwrap_or_default();@@ -212,7 +212,7 @@ impl DelegateGraphTool {.map(|n| (n as usize).min(MAX_MAX_REVISIONS)).unwrap_or(DEFAULT_MAX_REVISIONS);- let registry = match AgentDefinitionRegistry::global() {+ let registry = match AgentDefinitionRegistry::current() {Some(reg) => reg,None => {return Ok(ToolResult::error(diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rsindex e1c09cac96..357e2d3744 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs@@ -48,7 +48,7 @@ impl DelegationDispatch {// `delegate_graph` is a concrete durable graph tool with its own// typed dispatcher, and arbitrary `delegate_*` tools must not be// mistaken for an agent target merely because of their spelling.- name if AgentDefinitionRegistry::global().is_some_and(|registry| {+ name if AgentDefinitionRegistry::current().is_some_and(|registry| {registry.list().into_iter().any(|definition| {definition.delegate_name@@ -102,7 +102,7 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for D.await}DelegationDispatchKind::Archetype => {- let Some(agent_id) = AgentDefinitionRegistry::global().and_then(|registry| {+ let Some(agent_id) = AgentDefinitionRegistry::current().and_then(|registry| {registry.list().into_iter().find_map(|definition| {let name = definition.delegate_name@@ -163,7 +163,7 @@ pub(crate) async fn dispatch_subagent_with_live_parent(let parent_workspace_descriptor = tool_context.and_then(|ctx| ctx.workspace().cloned()).or_else(|| run_context.workspace.clone());- let registry = match AgentDefinitionRegistry::global() {+ let registry = match AgentDefinitionRegistry::current() {Some(reg) => reg,None => {return Ok(ToolResult::error(diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rsindex 5dde5cba7d..6c3cdc93de 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rs@@ -168,7 +168,7 @@ impl Tool for SpawnAsyncSubagentTool {let agent_ids: Vec<String> = if scoped {self.advertised_ids.clone()} else {- AgentDefinitionRegistry::global()+ AgentDefinitionRegistry::current().map(|reg| reg.list().iter().map(|d| d.id.clone()).collect()).unwrap_or_default()};diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rsindex df843ca633..084813b73e 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs@@ -46,7 +46,7 @@ impl SpawnAsyncSubagentTool {}};- let registry = match AgentDefinitionRegistry::global() {+ let registry = match AgentDefinitionRegistry::current() {Some(registry) => registry,None => {return Ok(ToolResult::error(diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents.rsindex 2b5e5fbcdb..17c7a79218 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents.rs@@ -168,7 +168,7 @@ impl Tool for SpawnParallelAgentsTool {}fn parameters_schema(&self) -> serde_json::Value {- let agent_ids: Vec<String> = AgentDefinitionRegistry::global()+ let agent_ids: Vec<String> = AgentDefinitionRegistry::current().map(|reg| reg.list().iter().map(|d| d.id.clone()).collect()).unwrap_or_default();let agent_id_schema = if agent_ids.is_empty() {diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_parameters.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_parameters.rsindex a8d9d59b15..9f0a1a6cac 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_parameters.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_parameters.rs@@ -16,7 +16,7 @@ fn spawn_subagent_parameters_schema() -> serde_json::Value {// Build the agent_id enum dynamically from the global registry// when it's been initialised. Falls back to a string-with-hint// when the registry hasn't been set up yet (e.g. early tests).- let agent_ids: Vec<String> = AgentDefinitionRegistry::global()+ let agent_ids: Vec<String> = AgentDefinitionRegistry::current().map(|reg| reg.list().iter().map(|d| d.id.clone()).collect()).unwrap_or_default();diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rsindex f51aece529..3180ef9023 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs@@ -131,7 +131,7 @@ impl SpawnSubagentTool {if prompt.is_empty() {return Ok(ToolResult::error("spawn_subagent: `prompt` is required"));}- let registry = match AgentDefinitionRegistry::global() {+ let registry = match AgentDefinitionRegistry::current() {Some(reg) => reg,None => {return Ok(ToolResult::error(diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rsindex 58f4a3eee7..7980043627 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs@@ -88,7 +88,7 @@ impl Tool for SpawnWorkerThreadTool {}fn parameters_schema(&self) -> serde_json::Value {- let agent_ids: Vec<String> = AgentDefinitionRegistry::global()+ let agent_ids: Vec<String> = AgentDefinitionRegistry::current().map(|reg| reg.list().iter().map(|d| d.id.clone()).collect()).unwrap_or_default();@@ -269,7 +269,7 @@ impl SpawnWorkerThreadTool {}}- let registry = AgentDefinitionRegistry::global()+ let registry = AgentDefinitionRegistry::current().ok_or_else(|| anyhow::anyhow!("AgentDefinitionRegistry not initialised"))?;let definition = registrydiff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/host.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/host.rsindex c5e80a08e4..82e4361095 100644--- a/crates/openhuman-core/src/agent/orchestration/workflow_runs/host.rs+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/host.rs@@ -68,7 +68,7 @@ impl OpenHumanWorkflowExecutor {fn admit_child(&self, agent_id: &str) -> Result<(), OrchestrationError> {match self.safety_tier {WorkflowSafetyTier::ReadOnly => {- let registry = AgentDefinitionRegistry::global().ok_or_else(|| {+ let registry = AgentDefinitionRegistry::current().ok_or_else(|| {OrchestrationError("workflow safety admission requires the agent registry".to_owned(),)diff --git a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rsindex db153a9621..56713425bf 100644--- a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs+++ b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs@@ -153,13 +153,13 @@ fn render_withheld_specialists(ctx: &PromptContext<'_>) -> String {);return String::new();}- let Some(registry) = AgentDefinitionRegistry::global() else {+ let Some(registry) = AgentDefinitionRegistry::current() else {tracing::debug!("[orchestrator-prompt] no agent registry; withheld-specialist section omitted");return String::new();};- let Some(definition) = resolve_definition(registry, ctx.agent_id) else {+ let Some(definition) = resolve_definition(®istry, ctx.agent_id) else {tracing::debug!(agent = ctx.agent_id,"[orchestrator-prompt] agent id does not resolve to a registry entry"@@ -237,8 +237,8 @@ fn render_withheld_specialists(ctx: &PromptContext<'_>) -> String {/// visible set exactly like [`render_withheld_specialists`], never hand-written,/// so a pack or allowlist change moves the prose with it (#6302).fn hand_off_route(ctx: &PromptContext<'_>, specialist: &str) -> Option<String> {- let registry = AgentDefinitionRegistry::global()?;- let definition = resolve_definition(registry, ctx.agent_id)?;+ let registry = AgentDefinitionRegistry::current()?;+ let definition = resolve_definition(®istry, ctx.agent_id)?;let listed = definition.subagents.iter()@@ -297,10 +297,10 @@ fn run_workflow_route(ctx: &PromptContext<'_>) -> Option<String> {/// is callable for an agent only when its belt mentions one of the pack's tools.fn belt_lists(ctx: &PromptContext<'_>, tool: &str) -> bool {use crate::agent::harness::definition::ToolScope;- let Some(registry) = AgentDefinitionRegistry::global() else {+ let Some(registry) = AgentDefinitionRegistry::current() else {return false;};- let Some(definition) = resolve_definition(registry, ctx.agent_id) else {+ let Some(definition) = resolve_definition(®istry, ctx.agent_id) else {return false;};match &definition.tools {diff --git a/crates/openhuman-core/src/agent/schemas.rs b/crates/openhuman-core/src/agent/schemas.rsindex 5a2c7b13e7..2d242c8085 100644--- a/crates/openhuman-core/src/agent/schemas.rs+++ b/crates/openhuman-core/src/agent/schemas.rs@@ -318,7 +318,7 @@ struct GetDefinitionParams {fn handle_get_definition(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let p = deserialize_params::<GetDefinitionParams>(params)?;- let registry = crate::agent::harness::AgentDefinitionRegistry::global()+ let registry = crate::agent::harness::AgentDefinitionRegistry::current().ok_or_else(|| "AgentDefinitionRegistry not initialised".to_string())?;match registry.get(p.id.trim()) {Some(def) => Ok(serde_json::json!({ "definition": def })),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 f03f331fb6..06e97db625 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@@ -356,12 +356,12 @@ impl SessionHostBuilder {let hosted_config = Arc::new(hosted_config);#[cfg(test)]let definitions = Some(- crate::agent::harness::AgentDefinitionRegistry::global_arc().unwrap_or_else(|| {+ crate::agent::harness::AgentDefinitionRegistry::current().unwrap_or_else(|| {Arc::new(crate::agent::harness::AgentDefinitionRegistry::builtins_only())}),);#[cfg(not(test))]- let definitions = crate::agent::harness::AgentDefinitionRegistry::global_arc();+ let definitions = crate::agent::harness::AgentDefinitionRegistry::current();// A caller that brought its own definition is the authority for this// session, so it does not need a process registry to exist before it// may run a turn. The stand-in is deliberately *empty* rather thandiff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rsindex 60703c80ea..ed0ba917b6 100644--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs@@ -114,7 +114,7 @@ impl OpenHumanSessionHost {}/// Build a session agent from a definition the caller already holds,- /// rather than an id resolved through `AgentDefinitionRegistry::global()`+ /// rather than an id resolved through `AgentDefinitionRegistry::current()`/// or `config.agent_registry`.////// The definition is authoritative for this agent's prompt, tool scope,@@ -437,13 +437,13 @@ impl OpenHumanSessionHost {Option<std::collections::HashSet<String>>,) = match (target_def,- crate::agent::harness::definition::AgentDefinitionRegistry::global(),+ crate::agent::harness::definition::AgentDefinitionRegistry::current(),) {(Some(def), Some(reg)) => {let synthed = if should_synthesize_delegation_tools(def) {tools::orchestrator_tools::collect_orchestrator_tools(def,- reg,+ ®,prewarmed_integrations_slice,)} else {@@ -506,7 +506,7 @@ impl OpenHumanSessionHost {let synthed = match reg.get("orchestrator") {Some(orch_def) => tools::orchestrator_tools::collect_orchestrator_tools(orch_def,- reg,+ ®,prewarmed_integrations_slice,),None => {@@ -525,7 +525,7 @@ impl OpenHumanSessionHost {// existed, or — the common case today — a `CustomRegistry`// definition `resolve_target_definition` synthesizes// straight from `config.agent_registry.entries` without- // ever consulting `AgentDefinitionRegistry::global()`, see+ // ever consulting `AgentDefinitionRegistry::current()`, see// `agent_registry::find_custom_in_config`). Delegation-tool// synthesis needs the registry (to resolve named// subagents), so it's skipped here, but `def.tools` is a@@ -712,7 +712,7 @@ impl OpenHumanSessionHost {let payload_summarizer: Option<std::sync::Arc<dyn crate::agent::tinyagents::payload_summarizer::PayloadSummarizer>,> = if super::summarizes_tool_output(agent_id, config) {- match crate::agent::harness::definition::AgentDefinitionRegistry::global() {+ match crate::agent::harness::definition::AgentDefinitionRegistry::current() {Some(reg) => match reg.get("summarizer") {Some(summarizer_def) => {log::info!(@@ -829,7 +829,7 @@ impl OpenHumanSessionHost {// second resident copy of a 95-field struct with nested `Vec`s// (openhuman#6218).agent.runtime_config = Some(Arc::clone(&base_config));- agent.hosted_base = AgentDefinitionRegistry::global_arc().map(|definitions| {+ agent.hosted_base = AgentDefinitionRegistry::current().map(|definitions| {Arc::new(crate::agent::tinyagents::host::OpenHumanHostBase {config: Arc::clone(&base_config),definitions,@@ -883,9 +883,9 @@ fn resolve_target_definition(config: &Config,agent_id: &str,) -> Result<Option<crate::agent::harness::definition::AgentDefinition>> {- let registry = AgentDefinitionRegistry::global();+ let registry = AgentDefinitionRegistry::current();- if let Some(reg) = registry {+ if let Some(reg) = registry.as_deref() {if let Some(def) = reg.get(agent_id) {return Ok(Some(def.clone()));}diff --git a/crates/openhuman-core/src/agent/session_host/builder/mod.rs b/crates/openhuman-core/src/agent/session_host/builder/mod.rsindex e4c8661e6b..62d4a30231 100644--- a/crates/openhuman-core/src/agent/session_host/builder/mod.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/mod.rs@@ -276,7 +276,7 @@ pub(super) fn should_synthesize_delegation_tools(def: &AgentDefinition) -> bool/// the name extends at an `_` boundary. Empty when the registry is not up or/// the id resolves to nothing, which leaves the schema untouched.fn allowed_subagent_ids_for(agent_id: &str) -> Vec<String> {- let Some(registry) = crate::agent::harness::AgentDefinitionRegistry::global() else {+ let Some(registry) = crate::agent::harness::AgentDefinitionRegistry::current() else {return Vec::new();};let definition = registry.get(agent_id).or_else(|| {diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rsindex 7a2a7cac75..6c2a9e6363 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs@@ -141,7 +141,7 @@ impl OpenHumanSessionHost {/// the factory had one, else the process registry's entry for/// `agent_definition_id`.///- /// Prefer this over a bare `AgentDefinitionRegistry::global().get(..)` in+ /// Prefer this over a bare `AgentDefinitionRegistry::current().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.@@ -149,9 +149,8 @@ impl OpenHumanSessionHost {&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()+ crate::agent::harness::definition::AgentDefinitionRegistry::current()+ .and_then(|registry| registry.get(&self.agent_definition_id).cloned()).map(Arc::new)})}diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex 8733f6e367..92a307442b 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -368,7 +368,7 @@ impl OpenHumanTurnPrelude {use crate::tools::agent_policy::ToolPolicyEngine;use crate::tools::orchestrator_tools::collect_orchestrator_tools;- let Some(registry) = AgentDefinitionRegistry::global() else {+ let Some(registry) = AgentDefinitionRegistry::current() else {return Ok(());};let Some(definition) = registry.get(&self.agent_definition_id).cloned() else {@@ -393,7 +393,7 @@ impl OpenHumanTurnPrelude {.tool_surface.lock().unwrap_or_else(std::sync::PoisonError::into_inner);- let mut collected = collect_orchestrator_tools(&definition, registry, &integrations);+ let mut collected = collect_orchestrator_tools(&definition, ®istry, &integrations);#[cfg(feature = "mcp")]collected.extend(mcp_tools);let rebuilt = self.rebuilt_recorded_tools(diff --git a/crates/openhuman-core/src/agent/session_host/turn/tools.rs b/crates/openhuman-core/src/agent/session_host/turn/tools.rsindex e55a00975e..5e3a0948b0 100644--- a/crates/openhuman-core/src/agent/session_host/turn/tools.rs+++ b/crates/openhuman-core/src/agent/session_host/turn/tools.rs@@ -103,7 +103,7 @@ impl OpenHumanSessionHost {use crate::agent::harness::definition::AgentDefinitionRegistry;use crate::tools::orchestrator_tools::collect_orchestrator_tools;- let Some(reg) = AgentDefinitionRegistry::global() else {+ let Some(reg) = AgentDefinitionRegistry::current() else {// No registry — there's nothing we can do until the// registry is initialised. The agent's surface stays at// whatever the builder produced.@@ -125,7 +125,7 @@ impl OpenHumanSessionHost {// `retain` can never withdraw a durable tool's spec.let synthed = super::super::builder::drop_synthesized_name_collisions(&self.tools,- collect_orchestrator_tools(&def, reg, &self.connected_integrations),+ collect_orchestrator_tools(&def, ®, &self.connected_integrations),);let synthed_names: std::collections::HashSet<String> =synthed.iter().map(|t| t.name().to_string()).collect();diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex e6f4da3e1e..1dcafc655b 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -280,8 +280,10 @@ pub(crate) async fn run_subagent_direct(// through that walk. Resolve the parent's tier from the registry by its// definition id; `tier_gate_decision` rejects (and logs) any forbidden// chat/reasoning hop while exempting unresolved + worker parents.- let parent_def =- AgentDefinitionRegistry::global().and_then(|reg| reg.get(&parent.agent_definition_id));+ let parent_registry = AgentDefinitionRegistry::current();+ let parent_def = parent_registry+ .as_deref()+ .and_then(|reg| reg.get(&parent.agent_definition_id));tier_gate_decision(parent_def, definition, &parent.agent_definition_id, &task_id)?;// Configured `subagentStart` hooks — the last gate before a spawn costsdiff --git a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rsindex 2a19dc6929..eef4ddc486 100644--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs@@ -75,7 +75,7 @@ pub(super) fn is_subagent_spawn_tool(name: &str) -> bool {// which let wildcard-scoped children inherit the orchestrator's spawn// surface. Resolve the override names via the registry so the strip// stays in lockstep with `collect_orchestrator_tools`'s naming.- if let Some(registry) = crate::agent::harness::definition::AgentDefinitionRegistry::global() {+ if let Some(registry) = crate::agent::harness::definition::AgentDefinitionRegistry::current() {return registry.list().iter()diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs b/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rsindex 938fd73391..88351d45d9 100644--- a/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs+++ b/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs@@ -233,7 +233,7 @@ pub(super) fn register_turn_tools_and_agents(// remains the deferred follow-up.let mut registered_agents: HashSet<String> = HashSet::new();let mut runtime_agent_count = 0usize;- if let Some(runtime) = crate::agent::harness::definition::AgentDefinitionRegistry::global() {+ if let Some(runtime) = crate::agent::harness::definition::AgentDefinitionRegistry::current() {for def in runtime.list() {if registered_agents.insert(def.id.clone()) {let _ =diff --git a/crates/openhuman-core/src/agent/triage/escalation.rs b/crates/openhuman-core/src/agent/triage/escalation.rsindex 3c995bb7f3..53f72804be 100644--- a/crates/openhuman-core/src/agent/triage/escalation.rs+++ b/crates/openhuman-core/src/agent/triage/escalation.rs@@ -248,7 +248,7 @@ async fn dispatch_target_agent(agent_id: &str, prompt: &str) -> anyhow::Result<S// `build_root_parent` (inside `build_triage_parent`) guarantees the registry// is initialised, so this lookup for the target definition is safe here.- let registry = AgentDefinitionRegistry::global()+ let registry = AgentDefinitionRegistry::current().ok_or_else(|| anyhow!("AgentDefinitionRegistry not initialised"))?;let definition = registry.get(agent_id)diff --git a/crates/openhuman-core/src/agent/triage/evaluator/arm.rs b/crates/openhuman-core/src/agent/triage/evaluator/arm.rsindex 3d67988858..fac7bd7e4c 100644--- a/crates/openhuman-core/src/agent/triage/evaluator/arm.rs+++ b/crates/openhuman-core/src/agent/triage/evaluator/arm.rs@@ -80,7 +80,7 @@ pub(super) async fn try_arm("[triage::evaluator] starting triage turn");- let registry = AgentDefinitionRegistry::global().ok_or_else(|| {+ let registry = AgentDefinitionRegistry::current().ok_or_else(|| {ArmError::Fatal(anyhow!("AgentDefinitionRegistry not initialised — did startup wiring \skip `init_global`?"diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs b/crates/openhuman-core/src/channels/runtime/dispatch/routing.rsindex d2f7f5afd0..7a41460140 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/routing.rs@@ -79,7 +79,7 @@ pub(super) async fn resolve_target_agent(channel: &str) -> AgentScoping {"[dispatch::routing] selected target agent");- let registry = match AgentDefinitionRegistry::global() {+ let registry = match AgentDefinitionRegistry::current() {Some(reg) => reg,None => {tracing::warn!(@@ -154,7 +154,7 @@ pub(super) async fn resolve_target_agent(channel: &str) -> AgentScoping {connected_integration_count = connected.len(),"[dispatch::routing] fetched connected integrations for delegation expansion");- orchestrator_tools::collect_orchestrator_tools(definition, registry, &connected)+ orchestrator_tools::collect_orchestrator_tools(definition, ®istry, &connected)} else {Vec::new()};diff --git a/crates/openhuman-core/src/cron/scheduler/agent_run.rs b/crates/openhuman-core/src/cron/scheduler/agent_run.rsindex bf91eeb13a..cbae4fb0ea 100644--- a/crates/openhuman-core/src/cron/scheduler/agent_run.rs+++ b/crates/openhuman-core/src/cron/scheduler/agent_run.rs@@ -48,7 +48,8 @@ pub(super) async fn run_agent_job_for_run(let selected_agent_id = job.agent_id.as_deref().unwrap_or("orchestrator");{let agent_id = selected_agent_id;- if let Some(registry) = crate::agent::harness::definition::AgentDefinitionRegistry::global()+ if let Some(registry) =+ crate::agent::harness::definition::AgentDefinitionRegistry::current(){if let Some(def) = registry.get(agent_id) {tracing::debug!(diff --git a/crates/openhuman-core/src/flows/ops/inference_readiness.rs b/crates/openhuman-core/src/flows/ops/inference_readiness.rsindex c94bceba26..424a932b3a 100644--- a/crates/openhuman-core/src/flows/ops/inference_readiness.rs+++ b/crates/openhuman-core/src/flows/ops/inference_readiness.rs@@ -177,7 +177,7 @@ pub(super) fn agent_node_role(config: &Config, node: &tinyflows::model::Node) ->tracing::debug!(target: "flows", %error,"[flows] readiness: agent definition registry unavailable; using registry fallback");}- let definition = AgentDefinitionRegistry::global().and_then(|r| r.get(agent_ref));+ let definition = AgentDefinitionRegistry::current().and_then(|r| r.get(agent_ref).cloned());let custom = crate::agent::registry::find_custom_in_config(config, agent_ref);if definition.is_some() || custom.is_some() {let entry_model = if definition.is_some() {@@ -193,7 +193,7 @@ pub(super) fn agent_node_role(config: &Config, node: &tinyflows::model::Node) ->override_model.as_deref().or(config.default_model.as_deref()),- definition,+ definition.as_ref(),);}}diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rsindex 693f0dacb3..8ec8484795 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs@@ -127,7 +127,7 @@ pub(crate) enum AgentRoute {/// custom-registry fallback. Pure over the global registry so the selection is/// unit-testable with `init_global_builtins`.pub(crate) fn route_for_agent_ref(agent_ref: &str) -> AgentRoute {- let has_definition = crate::agent::harness::definition::AgentDefinitionRegistry::global()+ let has_definition = crate::agent::harness::definition::AgentDefinitionRegistry::current().map(|reg| reg.get(agent_ref).is_some()).unwrap_or(false);if has_definition {diff --git a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs b/crates/openhuman-core/src/mcp/server/tools/dispatch.rsindex eaa7992aa5..c069da386f 100644--- a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs+++ b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs@@ -268,7 +268,7 @@ async fn core_tool_instructions() -> Result<Value, ToolCallError> {async fn list_subagents() -> Result<Value, ToolCallError> {let config = load_config_and_init_registry().await?;- let registry = AgentDefinitionRegistry::global().ok_or_else(|| {+ let registry = AgentDefinitionRegistry::current().ok_or_else(|| {ToolCallError::Internal("AgentDefinitionRegistry missing after init".to_string())})?;