Skip to content

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

fix(agent): resolve agent definitions from the run context instead of global state

Steven Enamakel9786ddb6ea11
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 46c45729e2..f6a40217f5 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
@@ -227,8 +227,7 @@ impl DelegateGraphTool {
let registry = match run_context
.dispatch_ctx()
.into_core()
- .and_then(|core| core.definitions())
- .or_else(AgentDefinitionRegistry::global_arc)
+ .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
{
Some(reg) => reg,
None => {
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
index fd3b0f8ae5..2c3bb54146 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
@@ -106,7 +106,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for D
.await
}
DelegationDispatchKind::Archetype => {
- let Some(agent_id) = AgentDefinitionRegistry::current().and_then(|registry| {
+ let Some(agent_id) = parent
+ .data
+ .dispatch_ctx()
+ .into_core()
+ .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
+ .and_then(|registry| {
registry.list().into_iter().find_map(|definition| {
let name = definition
.delegate_name
@@ -167,7 +172,11 @@ 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::current() {
+ let registry = match run_context
+ .dispatch_ctx()
+ .into_core()
+ .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
+ {
Some(reg) => reg,
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 2490e19abe..adfe0c6e44 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,7 +126,12 @@ impl SpawnSubagentTool {
if prompt.is_empty() {
return Ok(ToolResult::error("spawn_subagent: `prompt` is required"));
}
- let registry = match AgentDefinitionRegistry::current() {
+ let registry = match parent
+ .data
+ .dispatch_ctx()
+ .into_core()
+ .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
+ {
Some(reg) => reg,
None => {
return Ok(ToolResult::error(