Skip to content

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

feat(security): publish approval decision event on timeout

Steven Enamakel1d239f393c72
diff --git a/crates/openhuman-core/src/flows/ops/streaming.rs b/crates/openhuman-core/src/flows/ops/streaming.rs
index a99fe6d407..4646522875 100644
--- a/crates/openhuman-core/src/flows/ops/streaming.rs
+++ b/crates/openhuman-core/src/flows/ops/streaming.rs
@@ -111,6 +111,10 @@ pub(super) async fn finalize_flow_stream(
// stays the only persister of a flow turn's reply — unchanged
// from before #6034, which covered the chat surfaces.
None,
+ // `attach_flow_progress_bridge` discards its
+ // `ProgressBridgeHandle`, so there is no timing snapshot to
+ // forward here.
+ None,
)
.await;
}
diff --git a/crates/openhuman-core/src/security/approval/gate_intercept.rs b/crates/openhuman-core/src/security/approval/gate_intercept.rs
index 93ba09d83c..65281a5803 100644
--- a/crates/openhuman-core/src/security/approval/gate_intercept.rs
+++ b/crates/openhuman-core/src/security/approval/gate_intercept.rs
@@ -722,6 +722,26 @@ impl ApprovalGate {
ttl_secs = effective_ttl.as_secs(),
"[approval::gate] approval timed out, denying"
);
+ // Only publish when THIS call is the one that actually
+ // committed the terminal `Deny` (`denied == Ok(Some(_))`).
+ // When `denied` is `Ok(None)` a concurrent `decide()` (or
+ // an `expire_stale` sweep) already resolved and published
+ // this request — publishing again here would double-fire
+ // the socket bridge for a request that already reported
+ // its outcome once, and `take_request_route` would have
+ // nothing left to hand back anyway.
+ if let Ok(Some(row)) = &denied {
+ let route = self.take_request_route(&request_id);
+ BUS.publish(DomainEvent::ApprovalDecided {
+ request_id: row.request_id.clone(),
+ tool_name: row.tool_name.clone(),
+ decision: ApprovalDecision::Deny.as_str().to_string(),
+ thread_id: route.as_ref().and_then(|r| r.thread_id.clone()),
+ client_id: route.as_ref().and_then(|r| r.client_id.clone()),
+ tool_call_id: route.and_then(|r| r.tool_call_id),
+ resolution: Some("expired".to_string()),
+ });
+ }
(
GateOutcome::Deny {
reason: format!(