Skip to content

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

fix(shell): the shell audit row no longer claims a human approval

M3gA-Mindeb2f8178284f
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rs
index 1b55fd9c7f..3a92a14f21 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -309,14 +309,12 @@ impl ShellTool {
)
.await;
let duration_ms = u64::try_from(start.elapsed().as_millis()).unwrap_or(u64::MAX);
- // `allowed` = passed the in-tool security checks. `approved` = the command
- // is Prompt-class (required human approval) and thus went through the
- // harness ApprovalGate to reach here — distinct from `allowed`. Reads and
- // Full-mode writes run without a prompt, so they audit as approved=false
- // rather than over-claiming a human approval that never happened. (The
- // gate's exact yes/no isn't threaded into tools; this is the accurate
- // "required approval" proxy.)
- let approved = self.external_effect_with_args(&args);
+ // `allowed` = passed the in-tool security checks. Whether a human
+ // approved the call is the harness ApprovalGate's decision, kept in its
+ // own approval record; that yes/no is not threaded into tools, so this
+ // row never claims an approval (`approved=false`). Read the gate's
+ // record for the human decision.
+ let approved = false;
// emit_audit signature is (command, approved, allowed, …) — keep that order.
self.emit_audit(command, approved, allowed, !result.is_error, duration_ms);
Ok(result)
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs
index 6fea3ab8c9..219f70bd2e 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs
@@ -114,6 +114,28 @@ async fn shell_emits_audit_line_on_denial() {
);
}
+/// Full autonomy runs a write with no prompt, so no human approved it. The
+/// tool never learns the gate's decision; its audit row must not claim one.
+#[tokio::test]
+async fn shell_audit_never_claims_a_human_approval() {
+ use crate::security::AuditEvent;
+ let (audit, tmp) = audit_with_tempdir();
+ let tool = ShellTool::new(test_security(AutonomyLevel::Full), test_runtime(), audit);
+ let _ = tool
+ .execute(json!({"command": "echo hello"}))
+ .await
+ .unwrap();
+ let log =
+ std::fs::read_to_string(tmp.path().join("audit.log")).expect("audit log file should exist");
+ let parsed: AuditEvent = serde_json::from_str(log.trim()).expect("audit event JSON parses");
+ let action = parsed.action.expect("action present");
+ assert!(action.allowed, "the command ran");
+ assert!(
+ !action.approved,
+ "the audit row claimed a human approval that never happened"
+ );
+}
+
#[test]
fn shell_tool_name() {
let tool = ShellTool::new(