Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(agent): simplify agent definition registry lookups

Steven Enamakel83c59f240e99
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs
index e3f4cabfa6..e8d3497e6a 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs
@@ -366,11 +366,9 @@ impl ContinueSubagentTool {
}
// Look up the agent definition
- let registry = match run_context
- .dispatch_ctx()
- .into_core()
- .and_then(AgentDefinitionRegistry::for_core_context)
- {
+ let registry = match AgentDefinitionRegistry::for_core_context(
+ run_context.dispatch_ctx().into_core(),
+ ) {
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.rs
index ba158e9a2e..0854fc62bc 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
@@ -224,11 +224,9 @@ impl DelegateGraphTool {
// catalogue (or none at all) when callers execute the typed tool with
// an explicit parent carrier. Keep the process registry as the legacy
// fallback for contexts that do not carry an agent-local catalogue.
- let registry = match run_context
- .dispatch_ctx()
- .into_core()
- .and_then(AgentDefinitionRegistry::for_core_context)
- {
+ let registry = match AgentDefinitionRegistry::for_core_context(
+ run_context.dispatch_ctx().into_core(),
+ ) {
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.rs
index 9686b53440..a126f5fa06 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
@@ -106,12 +106,10 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for D
.await
}
DelegationDispatchKind::Archetype => {
- let Some(agent_id) = parent
- .data
- .dispatch_ctx()
- .into_core()
- .and_then(AgentDefinitionRegistry::for_core_context)
- .and_then(|registry| {
+ let Some(agent_id) = AgentDefinitionRegistry::for_core_context(
+ parent.data.dispatch_ctx().into_core(),
+ )
+ .and_then(|registry| {
registry.list().into_iter().find_map(|definition| {
let name = definition
.delegate_name
@@ -172,11 +170,9 @@ 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 run_context
- .dispatch_ctx()
- .into_core()
- .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
- {
+ let registry = match AgentDefinitionRegistry::for_core_context(
+ run_context.dispatch_ctx().into_core(),
+ ) {
Some(reg) => reg,
None => {
return Ok(ToolResult::error(
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.rs
index 6c4b1d64aa..a8640fd448 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
@@ -48,11 +48,9 @@ impl SpawnAsyncSubagentTool {
)));
}
- let registry = match run_context
- .dispatch_ctx()
- .into_core()
- .and_then(AgentDefinitionRegistry::for_core_context)
- {
+ let registry = match AgentDefinitionRegistry::for_core_context(
+ run_context.dispatch_ctx().into_core(),
+ ) {
Some(registry) => registry,
None => {
return Ok(ToolResult::error(
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.rs
index a283df6fad..206d61e2ab 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
@@ -126,12 +126,9 @@ impl SpawnSubagentTool {
if prompt.is_empty() {
return Ok(ToolResult::error("spawn_subagent: `prompt` is required"));
}
- let registry = match parent
- .data
- .dispatch_ctx()
- .into_core()
- .and_then(AgentDefinitionRegistry::for_core_context)
- {
+ let registry = match AgentDefinitionRegistry::for_core_context(
+ parent.data.dispatch_ctx().into_core(),
+ ) {
Some(reg) => reg,
None => {
return Ok(ToolResult::error(