Skip to content

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

refactor(agent): take owned core context in for_core_context

Steven Enamakel79fa00922fd9
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 8986684a84..e3f4cabfa6 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent.rs
@@ -369,7 +369,7 @@ impl ContinueSubagentTool {
let registry = match run_context
.dispatch_ctx()
.into_core()
- .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
+ .and_then(AgentDefinitionRegistry::for_core_context)
{
Some(reg) => reg,
None => {
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 f6a40217f5..ba158e9a2e 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
@@ -227,7 +227,7 @@ impl DelegateGraphTool {
let registry = match run_context
.dispatch_ctx()
.into_core()
- .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
+ .and_then(AgentDefinitionRegistry::for_core_context)
{
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 2c3bb54146..9686b53440 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
@@ -110,7 +110,7 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for D
.data
.dispatch_ctx()
.into_core()
- .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
+ .and_then(AgentDefinitionRegistry::for_core_context)
.and_then(|registry| {
registry.list().into_iter().find_map(|definition| {
let name = definition
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 f8b8b187c9..6c4b1d64aa 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
@@ -51,7 +51,7 @@ impl SpawnAsyncSubagentTool {
let registry = match run_context
.dispatch_ctx()
.into_core()
- .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
+ .and_then(AgentDefinitionRegistry::for_core_context)
{
Some(registry) => registry,
None => {
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 adfe0c6e44..a283df6fad 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
@@ -130,7 +130,7 @@ impl SpawnSubagentTool {
.data
.dispatch_ctx()
.into_core()
- .and_then(|core| AgentDefinitionRegistry::for_core_context(&core))
+ .and_then(AgentDefinitionRegistry::for_core_context)
{
Some(reg) => reg,
None => {
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
index 0cf3b2f078..2e79fecd5a 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
@@ -554,9 +554,12 @@ async fn delegate_graph_runs_every_stage_through_shared_driver_jobs() {
ContextOverlay::new(config, DomainSet::full(), ToolGroups::none())
.definitions(definitions),
);
+ // `OpenHumanRunContext::with_core` retains a weak handle; keep this strong
+ // owner alive through the graph execution so the scoped definition
+ // catalogue is the one the live parent carries.
let live = Arc::new(
crate::agent::tinyagents::host::OpenHumanRunContext::new()
- .with_core(Some(core))
+ .with_core(Some(Arc::clone(&core)))
.with_parent(parent)
.into_tinyagents(tinyagents_harness::context::RunConfig::new(
"delegate-graph-jobs-e2e",
diff --git a/crates/openhuman-core/src/agent_registry/host_definition.rs b/crates/openhuman-core/src/agent_registry/host_definition.rs
index aa03db8c69..f07797e0f7 100644
--- a/crates/openhuman-core/src/agent_registry/host_definition.rs
+++ b/crates/openhuman-core/src/agent_registry/host_definition.rs
@@ -286,8 +286,11 @@ impl AgentDefinitionRegistry {
/// back to the process registry. Execution paths with a live parent must
/// pass that parent's core so concurrent tenant/run contexts cannot read
/// another invocation's ambient catalogue.
- pub fn for_core_context(core: &crate::core::runtime::CoreContext) -> Option<Arc<Self>> {
- core.definitions().or_else(Self::global_arc)
+ pub fn for_core_context(
+ core: Option<Arc<crate::core::runtime::CoreContext>>,
+ ) -> Option<Arc<Self>> {
+ core.and_then(|core| core.definitions())
+ .or_else(Self::global_arc)
}
/// The catalogue sub-agent lookups resolve through: the ambient agent