Skip to content

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

fix(security_gate): keep the refusal text out of the policy failure class

M3gA-Mindfa6ec012cd08
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
index 7a9d6cfc84..d3ea6aba8a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
@@ -90,7 +90,6 @@ use crate::security::policy::{CommandClass, GateDecision as PolicyGateDecision,
use crate::security::prompt_injection::{
enforce_prompt_input, PromptEnforcementAction, PromptEnforcementContext,
};
-use crate::security::POLICY_DENIED_MARKER;
use crate::tools::agent_policy::{ToolPolicyAction, ToolPolicySession};
use tinytools::{PermissionLevel, Tool};
@@ -368,6 +367,12 @@ impl OpenHumanSecurityGate {
/// refusal reads the same — and rules out other routes explicitly, because
/// `shell` never prompts while autonomy is disabled (`[autonomy] enabled =
/// false`, the default) and was used to redo a refused call.
+///
+/// The text carries no `[policy-denied]` marker on purpose. The marker
+/// classifies as a policy failure with a zero recovery budget
+/// (`middleware::repeated_failure`), which pauses the turn before the model can
+/// answer. The model must get this turn to tell the user the action was not
+/// done, as it did with the harness's unmarked fallback text.
fn decision_for_outcome(tool_name: &str, outcome: GateOutcome) -> GateDecision {
match outcome {
GateOutcome::Allow => GateDecision::Prompted { approved: true },
@@ -378,11 +383,11 @@ fn decision_for_outcome(tool_name: &str, outcome: GateOutcome) -> GateDecision {
reason = %reason,
"[tinyagents::host::security] approval flow declined the tool call"
);
- GateDecision::deny(format!(
- "{POLICY_DENIED_MARKER} This action was refused and must not be performed this \
- turn — do not retry this call and do not achieve the same result another way \
- (shell, CLI, another tool). Tell the user it was not done."
- ))
+ GateDecision::deny(
+ "This action was refused and must not be performed this turn — do not retry this \
+ call and do not achieve the same result another way (shell, CLI, another tool). \
+ Tell the user it was not done.",
+ )
}
}
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs
index 3012bd8e52..ae11fdb7f3 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs
@@ -473,7 +473,12 @@ fn a_refused_approval_is_a_deny_the_model_can_read() {
let reason = decision
.denial_reason()
.expect("a refused approval carries a reason for the model");
- assert!(reason.starts_with(crate::security::POLICY_DENIED_MARKER));
+ // A policy-class failure pauses the turn before the model can reply.
+ assert_eq!(
+ crate::tools::status::classify(reason, false).class,
+ crate::tools::status::ToolFailureClass::Unknown,
+ "{reason}"
+ );
assert!(reason.contains("must not be performed"), "{reason}");
assert!(reason.contains("another way"), "{reason}");
let lower = reason.to_lowercase();