Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/openhuman/agent/triage/escalation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::openhuman::agent::orchestration::parent_context::build_root_parent;
use crate::openhuman::config::Config;

use super::decision::TriageAction;
use super::envelope::{TaskCardLink, TriggerEnvelope};
use super::envelope::{TaskCardLink, TriggerEnvelope, TriggerSource};
use super::evaluator::TriageRun;
use super::events;

Expand All @@ -50,8 +50,10 @@ pub async fn apply_decision(run: TriageRun, envelope: &TriggerEnvelope) -> anyho
match run.decision.action {
TriageAction::Drop => {
tracing::debug!(
source = %envelope.source.slug(),
label = %envelope.display_label,
external_id = %envelope.external_id,
card_linked = envelope.card_link.is_some(),
reason = %run.decision.reason,
"[triage::escalation] DROP — no downstream work"
);
Expand All @@ -64,11 +66,31 @@ pub async fn apply_decision(run: TriageRun, envelope: &TriggerEnvelope) -> anyho
gate_linked_card_terminal(envelope, "drop").await;
}
TriageAction::Acknowledge => {
// Acknowledge is a classification, not a write. What the trigger
// *was* is already durable in the composio trigger-history JSONL,
// and what it was *judged to be* went out as `TriggerEvaluated`
// above. Copying a summary into the memory store on top of that
// would duplicate a document the connector sync already ingested —
// same mail, second copy, competing for the same recall slots — so
// this arm deliberately writes nothing.
//
// What survives differs by source, so the log says which — only the
// composio path archives its input, and claiming otherwise sends an
// operator looking for a record that was never written.
//
// What is genuinely missing is not a copy of the input but a record
// of what happened *after* the verdict, for every action and every
// source, not just this one. That belongs in a progress surface of
// its own rather than bolted onto the acknowledge branch (#5408).
tracing::info!(
source = %envelope.source.slug(),
label = %envelope.display_label,
external_id = %envelope.external_id,
card_linked = envelope.card_link.is_some(),
retained = %retained_input_note(&envelope.source),
reason = %run.decision.reason,
"[triage::escalation] ACKNOWLEDGE — logged (memory-write is a future addition)"
"[triage::escalation] ACKNOWLEDGE — no autonomous action; \
recorded as TriggerEvaluated"
);
// Acknowledge means "seen, no autonomous action needed" — same as
// drop, the linked card must not be picked up by the board poller.
Expand Down Expand Up @@ -325,6 +347,21 @@ async fn dispatch_linked_card(
crate::openhuman::agent::task_dispatcher::dispatch_card(link.location.clone(), card).await
}

/// What survives an acknowledged trigger, for the source it actually came from.
///
/// The composio webhook path archives every event to a daily JSONL before the
/// triage gates, so its input is durable whatever the verdict. No other source
/// has an equivalent: a webhook, cron, webview, or external trigger leaves only
/// the `TriggerEvaluated` event. Saying "retained in trigger history" for all
/// of them would tell an operator to go looking for a record that was never
/// written.
fn retained_input_note(source: &TriggerSource) -> &'static str {
match source {
TriggerSource::Composio { .. } => "trigger-history archive",
_ => "none — verdict only",
}
}

/// Terminally gate a card-linked trigger that triage decided to `drop` /
/// `acknowledge`, so the board poller (which dispatches any pending
/// `Todo`/`Ready` card) won't re-run it. Only a still-pending card is gated;
Expand Down
37 changes: 37 additions & 0 deletions src/openhuman/agent/triage/escalation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,40 @@ async fn apply_decision_escalate_failure_publishes_failed_event() {
if external_id == "esc-escalate-fail"
)));
}

/// Only the composio path archives its input before triage. Naming a
/// trigger-history record for a webhook or cron acknowledge would send an
/// operator looking for a file that was never written.
#[test]
fn only_composio_claims_a_retained_input() {
assert_eq!(
retained_input_note(&TriggerSource::Composio {
toolkit: "gmail".into(),
trigger: "GMAIL_NEW_GMAIL_MESSAGE".into(),
}),
"trigger-history archive"
);

for source in [
TriggerSource::Webhook {
tunnel_id: "t".into(),
method: "POST".into(),
path: "/x".into(),
},
TriggerSource::Cron {
job_id: "j".into(),
job_name: "nightly".into(),
},
TriggerSource::WebviewIntegration {
provider: "gmail".into(),
account_id: "a".into(),
},
] {
assert_eq!(
retained_input_note(&source),
"none — verdict only",
"{} has no archive to point at",
source.slug()
);
}
}
Loading