Skip to content

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

fix(approval): publish domain event when parked approval is cancelled

Steven Enamakel2794a91f94f3
diff --git a/crates/openhuman-core/src/security/approval/gate.rs b/crates/openhuman-core/src/security/approval/gate.rs
index d542bf04b1..8e7abb9ba9 100644
--- a/crates/openhuman-core/src/security/approval/gate.rs
+++ b/crates/openhuman-core/src/security/approval/gate.rs
@@ -271,7 +271,19 @@ impl Drop for WaiterGuard<'_> {
self.gate
.clear_thread_route_if_owned(thread_id, &self.request_id);
}
- let _ = store::decide(&self.gate.config, &self.request_id, ApprovalDecision::Deny);
+ let decided = store::decide(&self.gate.config, &self.request_id, ApprovalDecision::Deny);
+ if let Ok(Some(row)) = decided {
+ let route = self.gate.take_request_route(&self.request_id);
+ BUS.publish(DomainEvent::ApprovalDecided {
+ request_id: row.request_id,
+ tool_name: row.tool_name,
+ 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("cancelled".to_string()),
+ });
+ }
tracing::warn!(
request_id = %self.request_id,
"[approval::gate] parked approval future dropped mid-park (external turn teardown) — \