Skip to content

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

feat(security): add approval gate intercept and setup

Steven Enamakel3120b0d36e9d
diff --git a/crates/openhuman-core/src/security/approval/gate_intercept.rs b/crates/openhuman-core/src/security/approval/gate_intercept.rs
index 621e786be2..bb8ff9e956 100644
--- a/crates/openhuman-core/src/security/approval/gate_intercept.rs
+++ b/crates/openhuman-core/src/security/approval/gate_intercept.rs
@@ -110,7 +110,7 @@ impl ApprovalGate {
tracing::debug!(
tool = tool_name,
?origin,
- auto_approve_all = self.is_auto_approve_all_enabled(),
+ auto_approve_all = self.is_auto_approve_all_enabled(&turn_ctx),
bypass_auto = matches!(
&origin,
AgentTurnOrigin::TrustedAutomation {
@@ -206,7 +206,7 @@ impl ApprovalGate {
// below pins that outcome, so a change to this exclusion list has to
// confront the decision rather than discover it.
let auto_all =
- self.is_auto_approve_all_enabled() && !matches!(&origin, AgentTurnOrigin::Unknown);
+ self.is_auto_approve_all_enabled(&turn_ctx) && !matches!(&origin, AgentTurnOrigin::Unknown);
if auto_all && !forced {
// `origin_class` is the sanitized variant label (no thread/client
@@ -247,7 +247,7 @@ impl ApprovalGate {
// live policy) takes effect on the very next tool call; fall back to the
// gate's boot-time config when no live policy is installed (e.g. a CLI
// invocation that never started a session runtime, or a unit test).
- if !forced && !bypass_auto_approve_shortcut && self.tool_is_auto_approved(tool_name) {
+ if !forced && !bypass_auto_approve_shortcut && self.tool_is_auto_approved(&turn_ctx, tool_name) {
tracing::debug!(
tool = tool_name,
"[approval::gate] auto_approve allowlist hit, skipping prompt"
diff --git a/crates/openhuman-core/src/security/approval/gate_setup.rs b/crates/openhuman-core/src/security/approval/gate_setup.rs
index 6585b81738..77a027b4cc 100644
--- a/crates/openhuman-core/src/security/approval/gate_setup.rs
+++ b/crates/openhuman-core/src/security/approval/gate_setup.rs
@@ -93,8 +93,8 @@ impl ApprovalGate {
/// Whether `tool_name` is on the user's "Always allow" list. Prefers the agent or
/// process-global live policy (so a grant made this session is seen
/// immediately) and falls back to the gate's boot-time config snapshot.
- fn tool_is_auto_approved(&self, tool_name: &str) -> bool {
- if let Some(policy) = crate::security::live_policy::effective() {
+ fn tool_is_auto_approved(&self, ctx: &crate::core::runtime::DispatchCtx, tool_name: &str) -> bool {
+ if let Some(policy) = crate::security::live_policy::effective_in(ctx) {
return policy.auto_approve.iter().any(|t| t == tool_name);
}
self.config
@@ -113,8 +113,8 @@ impl ApprovalGate {
/// Callers MUST still exclude `AgentTurnOrigin::Unknown` before trusting
/// this flag — see the `matches!` guard at the call site below. This method only reports the
/// user's setting; it does not know about origin.
- fn is_auto_approve_all_enabled(&self) -> bool {
- if let Some(policy) = crate::security::live_policy::effective() {
+ fn is_auto_approve_all_enabled(&self, ctx: &crate::core::runtime::DispatchCtx) -> bool {
+ if let Some(policy) = crate::security::live_policy::effective_in(ctx) {
return policy.auto_approve_all;
}
self.config.autonomy.auto_approve_all