Skip to content

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

fix(triage): label the turn origin at every triage dispatch site\n\nThe six `apply_decision` call sites scoped no `AgentTurnOrigin`, so every\nproactive escalation reached the approval gate as `Unknown` and was refused\nwith "agent turn has no origin label". `AGENT_TURN_ORIGIN` is a\n`tokio::task_local` and does not cross `tokio::spawn`, and these callers are\nfresh entry points with nothing to inherit, so propagation cannot fix it —\neach site has to state a label.\n\nWhich label is decided by provenance of the payload, per the approval-gate\nowner's decision on #5634:\n\n local (desktop notification RPC, agent RPC surface) -> Cli\n remote (composio bus, both webhook paths, task sources)\n -> TrustedAutomation { Workflow { require_approval: true } }\n\nThe remote label parks, publishes ApprovalRequested and writes the\npending_approvals audit row rather than granting a trust root to\nattacker-influenceable content.\n\nThis does not restore remote escalation. With no surface able to decide a\npark raised from a background trigger these still TTL-deny — the same\noutcome, now reached with an audit trail instead of silently as `Unknown`.\nThe decider surface is #5746.\n\nThe two constructors live in one module so the distinction is greppable, and\na source tripwire fails if a seventh dispatch site appears unlabelled.\n

M3gA-Mind6967aae16993
diff --git a/src/openhuman/agent/schemas.rs b/src/openhuman/agent/schemas.rs
index a17c896d91..398df7da18 100644
--- a/src/openhuman/agent/schemas.rs
+++ b/src/openhuman/agent/schemas.rs
@@ -401,9 +401,17 @@ fn handle_triage_evaluate(params: Map<String, Value>) -> ControllerFuture {
match outcome {
crate::openhuman::agent::triage::TriageOutcome::Decision(run) => {
if !dry_run {
- crate::openhuman::agent::triage::apply_decision(run.clone(), &envelope)
- .await
- .map_err(|e| format!("apply_decision failed: {e}"))?;
+ // Locally initiated: this is the desktop's own RPC surface,
+ // so the dispatch keeps the authority its caller already
+ // had. The envelope it builds may name a remote *source*,
+ // but the request itself is local (#5634).
+ let origin = crate::openhuman::agent::triage::local_trigger_origin();
+ crate::openhuman::agent::turn_origin::with_origin(
+ origin,
+ crate::openhuman::agent::triage::apply_decision(run.clone(), &envelope),
+ )
+ .await
+ .map_err(|e| format!("apply_decision failed: {e}"))?;
}
Ok(serde_json::json!({
diff --git a/src/openhuman/agent/triage/mod.rs b/src/openhuman/agent/triage/mod.rs
index 28a2f3e5ab..aff5f24154 100644
--- a/src/openhuman/agent/triage/mod.rs
+++ b/src/openhuman/agent/triage/mod.rs
@@ -36,10 +36,12 @@ pub mod envelope;
pub mod escalation;
pub mod evaluator;
pub mod events;
+pub mod origin;
pub mod routing;
pub use decision::{parse_triage_decision, ParseError, TriageAction, TriageDecision};
pub use envelope::{TriggerEnvelope, TriggerSource};
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, resolve_provider, ResolvedProvider};
diff --git a/src/openhuman/agent/triage/origin.rs b/src/openhuman/agent/triage/origin.rs
new file mode 100644
index 0000000000..d28c517707
--- /dev/null
+++ b/src/openhuman/agent/triage/origin.rs
@@ -0,0 +1,75 @@
+//! The turn origin a triage dispatch runs under.
+//!
+//! [`apply_decision`](super::apply_decision) reaches the approval gate, and the
+//! gate decides what an escalation may do from the [`AgentTurnOrigin`] scoped
+//! around the call. `AGENT_TURN_ORIGIN` is a `tokio::task_local`, and every
+//! triage caller either spawns or is itself a fresh entry point, so there is no
+//! ambient origin to inherit — an unscoped call reads `Unknown` and the gate
+//! fails closed (openhuman#5634). Propagation helpers cannot fix that: there is
+//! nothing to propagate, so inheriting would stay `Unknown`.
+//!
+//! Which label a caller scopes is decided by **provenance of the payload**, not
+//! by how the code got there, and the two answers live here so the distinction
+//! is one grep rather than six judgement calls:
+//!
+//! - [`local_trigger_origin`] — the caller and the payload are both local.
+//! - [`remote_trigger_origin`] — the payload arrived from outside and is
+//! attacker-influenceable.
+//!
+//! Deliberately *not* offered: a single blanket label. A webhook body and a
+//! desktop notification are not the same trust proposition, and one label for
+//! both would have to be the weaker of the two.
+
+use crate::openhuman::agent::turn_origin::{AgentTurnOrigin, TrustedAutomationSource};
+
+use super::envelope::TriggerEnvelope;
+
+/// The origin for a triage dispatch the local machine initiated.
+///
+/// [`AgentTurnOrigin::Cli`] is a trust root: the gate allows without prompting
+/// and persists no audit row. That is correct here and only here — these
+/// callers are the desktop's own RPC surface acting on data the machine already
+/// holds, so the escalation gets exactly the authority the caller already had.
+/// A payload that came in over the network must not use this; see
+/// [`remote_trigger_origin`].
+#[must_use]
+pub fn local_trigger_origin() -> AgentTurnOrigin {
+ AgentTurnOrigin::Cli
+}
+
+/// The origin for a triage dispatch driven by a payload from outside.
+///
+/// `TrustedAutomation { source: Workflow { require_approval: true } }`: the
+/// dispatch itself is legitimate automation, but the content steering it is
+/// remote, so the gate must not auto-allow. That variant parks every
+/// external-effect call, publishes `ApprovalRequested`, and writes the
+/// `pending_approvals` audit row.
+///
+/// **This does not restore remote escalation.** With no surface able to decide
+/// a park raised from a background trigger, these parks TTL-deny — the same
+/// outcome as before, now reached with an audit trail and a visible pending
+/// approval instead of silently as `Unknown`. The decider surface is
+/// openhuman#5746.
+///
+/// Explicitly not [`AgentTurnOrigin::Cli`]: that would hand a full trust root,
+/// with no audit row, to attacker-influenceable content — the posture
+/// [`TrustedAutomationSource::SubconsciousTainted`] exists to prevent.
+///
+/// `job_id` is the envelope's kind slug and correlation id, which is what an
+/// operator reading a pending row needs to find the trigger. Both are
+/// system-generated (Composio's `metadata.uuid`, a webhook tunnel id, a task
+/// source id) — never payload text, which the gate would otherwise surface at
+/// `info` as `flow_id`.
+#[must_use]
+pub fn remote_trigger_origin(envelope: &TriggerEnvelope) -> AgentTurnOrigin {
+ AgentTurnOrigin::TrustedAutomation {
+ job_id: format!("{}:{}", envelope.source.slug(), envelope.external_id),
+ source: TrustedAutomationSource::Workflow {
+ require_approval: true,
+ },
+ }
+}
+
+#[cfg(test)]
+#[path = "origin_tests.rs"]
+mod tests;
diff --git a/src/openhuman/agent/triage/origin_tests.rs b/src/openhuman/agent/triage/origin_tests.rs
new file mode 100644
index 0000000000..9e0dfc7316
--- /dev/null
+++ b/src/openhuman/agent/triage/origin_tests.rs
@@ -0,0 +1,144 @@
+//! The two labels are a security decision (openhuman#5634), so they are pinned
+//! by identity rather than by "is not `Unknown`" — a future edit that swapped
+//! the remote label for `Cli` would still satisfy the weaker assertion while
+//! handing a trust root to remote content.
+
+use super::*;
+use crate::openhuman::agent::triage::envelope::TriggerEnvelope;
+
+fn composio_envelope() -> TriggerEnvelope {
+ TriggerEnvelope::from_composio(
+ "gmail",
+ "new_message",
+ "ti_meta_id",
+ "ti_bCCTKZlajKi4",
+ serde_json::json!({ "subject": "hello" }),
+ )
+}
+
+#[test]
+fn a_local_dispatch_is_the_trust_root() {
+ assert!(
+ matches!(local_trigger_origin(), AgentTurnOrigin::Cli),
+ "local triage keeps the authority the caller already had"
+ );
+}
+
+#[test]
+fn a_remote_dispatch_parks_instead_of_being_trusted() {
+ let origin = remote_trigger_origin(&composio_envelope());
+ match origin {
+ AgentTurnOrigin::TrustedAutomation { source, .. } => assert_eq!(
+ source,
+ TrustedAutomationSource::Workflow {
+ require_approval: true
+ },
+ "remote payloads must force a park, not auto-allow"
+ ),
+ other => panic!("remote triage must not run as {}", other.class()),
+ }
+}
+
+#[test]
+fn a_remote_dispatch_is_never_the_trust_root() {
+ // The rejected option, pinned so reintroducing it fails here first.
+ assert!(
+ !matches!(
+ remote_trigger_origin(&composio_envelope()),
+ AgentTurnOrigin::Cli
+ ),
+ "`Cli` grants a full trust root with no audit row — never for remote content"
+ );
+}
+
+#[test]
+fn the_job_id_identifies_the_trigger_without_quoting_it() {
+ let envelope = composio_envelope();
+ let AgentTurnOrigin::TrustedAutomation { job_id, .. } = remote_trigger_origin(&envelope) else {
+ panic!("remote triage must be trusted automation");
+ };
+ assert_eq!(job_id, "composio:ti_bCCTKZlajKi4");
+ // The gate renders `job_id` as `flow_id` at `info`, so payload text must
+ // not reach it.
+ assert!(
+ !job_id.contains("hello"),
+ "job_id must not carry payload content, got {job_id:?}"
+ );
+}
+
+/// A tripwire, not a style check.
+///
+/// The labels above are only worth anything if every dispatch site actually
+/// scopes one, and the failure mode is silent: a seventh caller that forgets
+/// reads `Unknown`, the gate fails closed, and the symptom is a denied
+/// escalation in a staging log weeks later — which is precisely how
+/// openhuman#5634 was found. `AGENT_TURN_ORIGIN` is a task-local, so the
+/// compiler cannot enforce this.
+///
+/// Adding a call site is therefore meant to fail here. Fix it by scoping the
+/// label its provenance calls for and adding the path below — not by deleting
+/// the entry.
+#[test]
+fn every_dispatch_site_scopes_an_origin() {
+ const KNOWN_SITES: &[(&str, &str)] = &[
+ // Remote payloads — park and audit.
+ ("src/openhuman/memory/sync/composio/bus.rs", "remote"),
+ ("src/openhuman/integrations/task_sources/route.rs", "remote"),
+ ("src/openhuman/skills/webhooks/ops.rs", "remote"),
+ ("src/openhuman/skills/webhooks/bus.rs", "remote"),
+ // Locally initiated — trust root.
+ ("src/openhuman/desktop/notifications/rpc.rs", "local"),
+ ("src/openhuman/agent/schemas.rs", "local"),
+ ];
+
+ let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
+ let mut found: Vec<String> = Vec::new();
+ let mut stack = vec![root.join("src")];
+ while let Some(dir) = stack.pop() {
+ let Ok(entries) = std::fs::read_dir(&dir) else {
+ continue;
+ };
+ for entry in entries.flatten() {
+ let path = entry.path();
+ if path.is_dir() {
+ stack.push(path);
+ continue;
+ }
+ if path.extension().is_none_or(|ext| ext != "rs") {
+ continue;
+ }
+ let rel = path
+ .strip_prefix(root)
+ .unwrap_or(&path)
+ .to_string_lossy()
+ .replace('\\', "/");
+ // The triage module defines and tests `apply_decision`; it is the
+ // callee, not a call site. Test files model callers rather than
+ // being them.
+ if rel.starts_with("src/openhuman/agent/triage/") || rel.ends_with("_tests.rs") {
+ continue;
+ }
+ let Ok(text) = std::fs::read_to_string(&path) else {
+ continue;
+ };
+ if text.contains("apply_decision(") {
+ assert!(
+ text.contains("with_origin("),
+ "{rel} dispatches triage without scoping an origin, so it reaches the \
+ approval gate as `Unknown` and is denied (openhuman#5634). Scope \
+ `remote_trigger_origin` or `local_trigger_origin` by provenance."
+ );
+ found.push(rel);
+ }
+ }
+ }
+
+ found.sort();
+ let mut expected: Vec<String> = KNOWN_SITES.iter().map(|(p, _)| (*p).to_string()).collect();
+ expected.sort();
+ assert_eq!(
+ found, expected,
+ "the set of triage dispatch sites changed; label the new one by provenance \
+ and record it in KNOWN_SITES"
+ );
+}
diff --git a/src/openhuman/desktop/notifications/rpc.rs b/src/openhuman/desktop/notifications/rpc.rs
index e3a62302ce..2f61f125fc 100644
--- a/src/openhuman/desktop/notifications/rpc.rs
+++ b/src/openhuman/desktop/notifications/rpc.rs
@@ -15,8 +15,9 @@ use uuid::Uuid;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
use crate::openhuman::agent::triage::{
- apply_decision, run_triage, TriageOutcome, TriggerEnvelope, TriggerSource,
+ apply_decision, local_trigger_origin, run_triage, TriageOutcome, TriggerEnvelope, TriggerSource,
};
+use crate::openhuman::agent::turn_origin::with_origin;
use crate::openhuman::config::rpc as config_rpc;
use crate::rpc::RpcOutcome;
@@ -176,7 +177,15 @@ pub async fn handle_ingest(params: Map<String, Value>) -> Result<Value, String>
if score >= latest_settings.importance_threshold
&& latest_settings.route_to_orchestrator
{
- if let Err(e) = apply_decision(triage_run, &envelope).await {
+ // Locally initiated: a desktop notification the machine
+ // already holds, escalated by the user's own routing
+ // setting. Scoped inside the spawned task because
+ // `AGENT_TURN_ORIGIN` does not cross `tokio::spawn`
+ // (#5634).
+ let origin = local_trigger_origin();
+ if let Err(e) =
+ with_origin(origin, apply_decision(triage_run, &envelope)).await
+ {
tracing::warn!(
id = %id_for_triage,
error = %e,
diff --git a/src/openhuman/integrations/task_sources/route.rs b/src/openhuman/integrations/task_sources/route.rs
index 9d6ed28624..c60f57e326 100644
--- a/src/openhuman/integrations/task_sources/route.rs
+++ b/src/openhuman/integrations/task_sources/route.rs
@@ -12,7 +12,10 @@
use serde_json::json;
-use crate::openhuman::agent::triage::{apply_decision, run_triage, TriageOutcome, TriggerEnvelope};
+use crate::openhuman::agent::triage::{
+ apply_decision, remote_trigger_origin, run_triage, TriageOutcome, TriggerEnvelope,
+};
+use crate::openhuman::agent::turn_origin::with_origin;
use crate::openhuman::config::Config;
use crate::openhuman::threads::todos::ops::{
add as todo_add, remove as todo_remove, BoardLocation, CardPatch,
@@ -249,7 +252,10 @@ async fn dispatch_triage(
match outcome {
TriageOutcome::Decision(run) => {
- apply_decision(run, &envelope)
+ // Remote payload: the task arrived from an external board, so the
+ // dispatch parks rather than running on a trust root (#5634).
+ let origin = remote_trigger_origin(&envelope);
+ with_origin(origin, apply_decision(run, &envelope))
.await
.map_err(|e| format!("[task_sources:route] apply_decision failed: {e}"))?;
tracing::debug!(
diff --git a/src/openhuman/memory/sync/composio/bus.rs b/src/openhuman/memory/sync/composio/bus.rs
index bc5b4211d2..18eb1c0657 100644
--- a/src/openhuman/memory/sync/composio/bus.rs
+++ b/src/openhuman/memory/sync/composio/bus.rs
@@ -55,7 +55,10 @@ use async_trait::async_trait;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
-use crate::openhuman::agent::triage::{apply_decision, run_triage, TriageOutcome, TriggerEnvelope};
+use crate::openhuman::agent::triage::{
+ apply_decision, remote_trigger_origin, run_triage, TriageOutcome, TriggerEnvelope,
+};
+use crate::openhuman::agent::turn_origin::with_origin;
use crate::openhuman::config::rpc as config_rpc;
use crate::openhuman::integrations::composio::trigger_history;
use tinybus::EventHandler;
@@ -347,7 +350,13 @@ impl EventHandler<DomainEvent> for ComposioTriggerSubscriber {
tokio::spawn(async move {
match run_triage(&envelope).await {
Ok(TriageOutcome::Decision(run)) => {
- if let Err(e) = apply_decision(run, &envelope).await {
+ // Remote payload: a Composio trigger body is
+ // attacker-influenceable, so the dispatch parks rather than
+ // running on a trust root (#5634). Scoped here, inside the
+ // spawned task, because `AGENT_TURN_ORIGIN` is a task-local
+ // and does not cross `tokio::spawn`.
+ let origin = remote_trigger_origin(&envelope);
+ if let Err(e) = with_origin(origin, apply_decision(run, &envelope)).await {
tracing::error!(
label = %envelope.display_label,
error = %e,
diff --git a/src/openhuman/security/approval/gate.rs b/src/openhuman/security/approval/gate.rs
index 8df23eb37d..b01f66be0f 100644
--- a/src/openhuman/security/approval/gate.rs
+++ b/src/openhuman/security/approval/gate.rs
@@ -2474,6 +2474,85 @@ mod tests {
}
}
+ /// openhuman#5634: the six triage dispatch sites scoped no origin, so every
+ /// proactive escalation reached this gate as `Unknown` and was refused —
+ /// `intercept_with_unknown_origin_denies` below is that behaviour.
+ ///
+ /// A remote trigger now carries
+ /// `TrustedAutomation { Workflow { require_approval: true } }`, which parks
+ /// and persists the `pending_approvals` row instead. This asserts the park
+ /// and the row, not a successful escalation: with no surface able to decide
+ /// a background park these still TTL-deny (openhuman#5746). The gain is the
+ /// audit trail, not restored function.
+ #[tokio::test]
+ async fn a_remote_triage_escalation_parks_with_an_audit_row_rather_than_an_unknown_denial() {
+ use crate::openhuman::agent::triage::{remote_trigger_origin, TriggerEnvelope};
+
+ let (gate, _dir) = test_gate();
+ let envelope = TriggerEnvelope::from_composio(
+ "gmail",
+ "new_message",
+ "ti_meta",
+ "ti_bCCTKZlajKi4",
+ serde_json::json!({ "subject": "hello" }),
+ );
+
+ // `Box::pin` + a short timeout drives the future into the park without
+ // waiting out the TTL; nothing decides it, so it must still be pending.
+ let mut fut = Box::pin(turn_origin::with_origin(
+ remote_trigger_origin(&envelope),
+ gate.intercept(
+ "triage.escalate",
+ "escalate to orchestrator",
+ serde_json::json!({}),
+ ),
+ ));
+ let parked = tokio::time::timeout(Duration::from_millis(300), &mut fut).await;
+ assert!(
+ parked.is_err(),
+ "a remote escalation must park for a decision, not resolve immediately \
+ (an immediate Deny here is the `Unknown` regression this pins)"
+ );
+
+ let pending = gate.list_pending().unwrap();
+ assert_eq!(
+ pending.len(),
+ 1,
+ "the park must persist exactly one pending_approvals row, got {pending:?}"
+ );
+ assert_eq!(pending[0].tool_name, "triage.escalate");
+ }
+
+ /// The counterpart: a locally initiated triage dispatch keeps the authority
+ /// its caller already had, so it is allowed without a prompt and writes no
+ /// row. Pinned alongside the remote case because the security decision on
+ /// openhuman#5634 is that these two are *different*, and a later
+ /// simplification to one blanket label would have to break one of them.
+ #[tokio::test]
+ async fn a_local_triage_escalation_is_allowed_without_a_prompt() {
+ use crate::openhuman::agent::triage::local_trigger_origin;
+
+ let (gate, _dir) = test_gate();
+ let outcome = turn_origin::with_origin(
+ local_trigger_origin(),
+ gate.intercept(
+ "triage.escalate",
+ "escalate to orchestrator",
+ serde_json::json!({}),
+ ),
+ )
+ .await;
+
+ assert!(
+ matches!(outcome, GateOutcome::Allow),
+ "a locally initiated escalation must not be gated, got {outcome:?}"
+ );
+ assert!(
+ gate.list_pending().unwrap().is_empty(),
+ "a trust-root origin persists no pending row"
+ );
+ }
+
#[tokio::test]
async fn intercept_with_unknown_origin_denies() {
// Unlabelled call site (no origin scope) maps to `Unknown` and is
diff --git a/src/openhuman/skills/webhooks/bus.rs b/src/openhuman/skills/webhooks/bus.rs
index 75a1c33b08..d8aaded80c 100644
--- a/src/openhuman/skills/webhooks/bus.rs
+++ b/src/openhuman/skills/webhooks/bus.rs
@@ -310,9 +310,16 @@ async fn run_agent_trigger(
match outcome {
crate::openhuman::agent::triage::TriageOutcome::Decision(run) => {
- crate::openhuman::agent::triage::apply_decision(run.clone(), envelope)
- .await
- .map_err(|e| format!("apply_decision failed: {e}"))?;
+ // Remote payload: an inbound webhook body is
+ // attacker-influenceable, so the dispatch parks rather than running
+ // on a trust root (#5634).
+ let origin = crate::openhuman::agent::triage::remote_trigger_origin(envelope);
+ crate::openhuman::agent::turn_origin::with_origin(
+ origin,
+ crate::openhuman::agent::triage::apply_decision(run.clone(), envelope),
+ )
+ .await
+ .map_err(|e| format!("apply_decision failed: {e}"))?;
Ok(format!(
"Triage decision: {} (agent: {:?})",
diff --git a/src/openhuman/skills/webhooks/ops.rs b/src/openhuman/skills/webhooks/ops.rs
index d54b438cd8..6d837943cc 100644
--- a/src/openhuman/skills/webhooks/ops.rs
+++ b/src/openhuman/skills/webhooks/ops.rs
@@ -190,9 +190,15 @@ pub async fn trigger_agent(
match outcome {
crate::openhuman::agent::triage::TriageOutcome::Decision(run) => {
+ // Remote payload: a webhook body is attacker-influenceable, so the
+ // dispatch parks rather than running on a trust root (#5634).
+ let origin = crate::openhuman::agent::triage::remote_trigger_origin(&envelope);
tokio::time::timeout(
std::time::Duration::from_secs(60),
- crate::openhuman::agent::triage::apply_decision(run.clone(), &envelope),
+ crate::openhuman::agent::turn_origin::with_origin(
+ origin,
+ crate::openhuman::agent::triage::apply_decision(run.clone(), &envelope),
+ ),
)
.await
.map_err(|_| "apply_decision timed out after 60s".to_string())?