Skip to content

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

refactor(triage): clarify agent execution context for escalation

Steven Enamakel73da8d2aa368
diff --git a/crates/openhuman-core/src/triage/escalation.rs b/crates/openhuman-core/src/triage/escalation.rs
index 57ebe0697c..ea8fa67fdc 100644
--- a/crates/openhuman-core/src/triage/escalation.rs
+++ b/crates/openhuman-core/src/triage/escalation.rs
@@ -5,23 +5,19 @@
//! - **`drop`** — log only, publish `TriggerEvaluated`.
//! - **`acknowledge`** — log + publish `TriggerEvaluated`. (Memory-write
//! for ack is a future addition.)
-//! - **`react`** — dispatch the `trigger_reactor` sub-agent via
-//! [`run_subagent`], publish `TriggerEvaluated` + `TriggerEscalated`.
-//! - **`escalate`** — dispatch the `orchestrator` sub-agent, same
-//! events.
+//! - **`react`** — run one direct `trigger_reactor` agent turn and publish
+//! `TriggerEvaluated` + `TriggerEscalated`.
+//! - **`escalate`** — run one direct `orchestrator` agent turn, same events.
//!
-//! `react`/`escalate` build a full [`Agent`] from config so they have
-//! a real provider, tool registry, and memory backing — the same
-//! construction path `agent_chat` uses. A [`ParentExecutionContext`] is
-//! carried explicitly into [`run_subagent`] so it can inherit the provider
-//! and tools.
+//! `react`/`escalate` run the target definition through the in-process agent
+//! chat path, preserving its configured model, tools, and memory without
+//! creating child-task lifecycle records.
use crate::core::runtime::DispatchCtx;
use anyhow::{anyhow, Context};
use crate::agent::harness::fork_context::ParentExecutionContext;
use crate::agent::orchestration::parent_context::build_root_parent;
-use crate::agent::subagent_host::{self, SubagentRunOptions};
use crate::agent_registry::host_definition::AgentDefinitionRegistry;
use crate::config::Config;
@@ -209,15 +205,6 @@ pub async fn apply_decision(
Ok(())
}
-/// Build a full [`Agent`] from config, install a [`ParentExecutionContext`]
-/// on the task-local, and call [`run_subagent`] with the named definition
-/// and prompt.
-///
-/// This is heavier than a simple `agent.run_turn` bus call — it creates a
-/// provider, memory store, tool registry, and all the machinery `Agent`
-/// normally needs. The cost is acceptable because `react`/`escalate`
-/// triggers are relatively rare (most triggers are `drop`/`acknowledge`)
-/// and the construction is the same O(1) code path `agent_chat` uses.
/// Build the triage root parent: the shared [`build_root_parent`] context with
/// nested spawns scoped to the single dispatched target agent.
///
@@ -253,7 +240,7 @@ async fn dispatch_target_agent(
));
}
- let config = crate::config::ops::load_current_or_init(ctx)
+ let mut config = crate::config::ops::load_current_or_init(ctx)
.await
.context("loading config for sub-agent dispatch")?;