Skip to content

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

feat(subagent): route graph subagent runs through native context

Steven Enamakelc2f805435147
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
index f48b88eb72..249afc34b5 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
@@ -76,6 +76,7 @@ pub(in super::super) async fn run_subagent_via_graph(
// TinyAgents, where there is no config file. `None` yields the safe
// byte-cap-only defaults.
config: Option<&crate::config::Config>,
+ native_subagent: Option<crate::agent::tinyagents::NativeSubagentRunContext>,
) -> Result<
(
String,
@@ -204,7 +205,7 @@ pub(in super::super) async fn run_subagent_via_graph(
child_context.thread_id = thread_id.clone();
child_context.progress = on_progress.clone().or(child_context.progress);
child_context.workspace = workspace_descriptor.clone().or(child_context.workspace);
- let run_result = TurnSpec {
+ let turn_spec = TurnSpec {
run_context: child_context,
turn_models,
provider_id,
@@ -256,9 +257,11 @@ pub(in super::super) async fn run_subagent_via_graph(
// `subagent_scope`, so the seam never emits a top-level `TurnCompleted`
// (they report via `Subagent*` events). Pass `false` for clarity.
defer_turn_completed_to_caller: false,
- }
- .run()
- .await;
+ };
+ let run_result = match native_subagent {
+ Some(native) => turn_spec.run_with_native_subagent(native).await,
+ None => turn_spec.run().await,
+ };
if let Some(config) = config.filter(|config| config.observability.share_usage_data) {
let journal_run_id = child_journal_run_id
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
index adef69fefa..669f2bd3e0 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -113,7 +113,7 @@ pub(crate) async fn run_subagent_direct_with_native_context(
definition: &AgentDefinition,
task_prompt: &str,
options: SubagentRunOptions,
- native: crate::agent::tinyagents::turn_exec::NativeSubagentRunContext,
+ native: crate::agent::tinyagents::NativeSubagentRunContext,
) -> Result<SubagentRunOutcome, SubagentRunError> {
run_subagent_direct_inner(definition, task_prompt, options, Some(native)).await
}
@@ -122,7 +122,7 @@ async fn run_subagent_direct_inner(
definition: &AgentDefinition,
task_prompt: &str,
mut options: SubagentRunOptions,
- native: Option<crate::agent::tinyagents::turn_exec::NativeSubagentRunContext>,
+ native: Option<crate::agent::tinyagents::NativeSubagentRunContext>,
) -> Result<SubagentRunOutcome, SubagentRunError> {
// Unconditionally heap-allocate the entire run_subagent body so
// every caller doesn't have to carry this future's state inline.
diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rs
index bbec92e859..80114d1789 100644
--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs
@@ -69,7 +69,7 @@ pub(crate) use crate::inference::reasoning::{apply_requested_effort, parse_reaso
pub use crate::inference::turn_models::TurnModelSource;
pub(crate) use crate::inference::turn_models::TurnModels;
pub(crate) use observability::SubagentScope;
-pub(crate) use turn_exec::TurnSpec;
+pub(crate) use turn_exec::{NativeSubagentRunContext, TurnSpec};
pub(crate) use turn_outcome::TinyagentsTurnOutcome;
#[cfg(test)]
pub(crate) use turn_policy::is_subagent_spawn_or_delegate_tool;