Skip to content

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

chore: files changed crates/openhuman-core/src/triage/mod.rs,crates/openhuman-core/src/triage/runner

Steven Enamakel8f93fab7e647
diff --git a/crates/openhuman-core/src/triage/mod.rs b/crates/openhuman-core/src/triage/mod.rs
index 1796e15ec1..f101b61b37 100644
--- a/crates/openhuman-core/src/triage/mod.rs
+++ b/crates/openhuman-core/src/triage/mod.rs
@@ -38,6 +38,7 @@ pub mod evaluator;
pub mod events;
pub mod origin;
pub mod routing;
+pub mod runner;
pub mod trigger_reactor_prompt;
pub mod trigger_triage_prompt;
@@ -47,3 +48,4 @@ pub use escalation::apply_decision;
pub use evaluator::{run_triage, TriageOutcome, TriageResolutionPath, TriageRun};
pub use origin::{local_trigger_origin, remote_trigger_origin};
pub use routing::{build_local_provider_with_config, ResolvedProvider};
+pub use runner::{LiveTriage, TriageRunner};
diff --git a/crates/openhuman-core/src/triage/runner.rs b/crates/openhuman-core/src/triage/runner.rs
new file mode 100644
index 0000000000..1819847ab1
--- /dev/null
+++ b/crates/openhuman-core/src/triage/runner.rs
@@ -0,0 +1,72 @@
+//! [`TriageRunner`]: the two triage steps a caller runs on a trigger, behind
+//! one seam.
+//!
+//! Every inbound path classifies a [`TriggerEnvelope`] ([`run_triage`]) and,
+//! on a decision, applies it ([`apply_decision`]) under the remote-trigger
+//! turn origin, because a trigger body is attacker-influenceable (#5634). The
+//! direct paths (the Composio trigger subscriber and agent webhooks) and the
+//! inbound event queues' `Deliver` callback all go through this trait, so
+//! their behavior is testable without a model: tests script the outcomes, and
+//! production uses [`LiveTriage`].
+
+use async_trait::async_trait;
+
+use super::{
+ apply_decision, remote_trigger_origin, run_triage, TriageOutcome, TriageRun, TriggerEnvelope,
+};
+use crate::core::runtime::DispatchCtx;
+use crate::security::turn_origin::with_origin;
+
+/// Classify a trigger and apply a decision.
+#[async_trait]
+pub trait TriageRunner: Send + Sync {
+ /// Classify `envelope` (the triage evaluator chain).
+ ///
+ /// # Errors
+ ///
+ /// The evaluator's own failure (provider, parse, budget).
+ async fn run(
+ &self,
+ ctx: &DispatchCtx,
+ envelope: &TriggerEnvelope,
+ ) -> anyhow::Result<TriageOutcome>;
+
+ /// Apply a decision for `envelope` under the remote-trigger turn origin.
+ ///
+ /// # Errors
+ ///
+ /// The escalation's failure (approval denied is not an error).
+ async fn apply(
+ &self,
+ ctx: &DispatchCtx,
+ run: TriageRun,
+ envelope: &TriggerEnvelope,
+ ) -> anyhow::Result<()>;
+}
+
+/// The production runner: [`run_triage`] and [`apply_decision`].
+#[derive(Debug, Clone, Copy, Default)]
+pub struct LiveTriage;
+
+#[async_trait]
+impl TriageRunner for LiveTriage {
+ async fn run(
+ &self,
+ ctx: &DispatchCtx,
+ envelope: &TriggerEnvelope,
+ ) -> anyhow::Result<TriageOutcome> {
+ run_triage(ctx, envelope).await
+ }
+
+ async fn apply(
+ &self,
+ ctx: &DispatchCtx,
+ run: TriageRun,
+ envelope: &TriggerEnvelope,
+ ) -> anyhow::Result<()> {
+ // `AGENT_TURN_ORIGIN` is a task-local: scope it here, in whichever
+ // task applies the decision, so a caller that spawned cannot lose it.
+ let origin = remote_trigger_origin(envelope);
+ with_origin(origin, apply_decision(ctx, run, envelope)).await
+ }
+}