Skip to content

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

refactor(caps_host): route tool audit recording through close_audit

Steven Enamakeldb92b426aaf5
diff --git a/crates/openhuman-core/src/flows/caps_host/ops_schema_and_structured_output_tests.rs b/crates/openhuman-core/src/flows/caps_host/ops_schema_and_structured_output_tests.rs
index 6ee1a55ee6..fcb389b9bb 100644
--- a/crates/openhuman-core/src/flows/caps_host/ops_schema_and_structured_output_tests.rs
+++ b/crates/openhuman-core/src/flows/caps_host/ops_schema_and_structured_output_tests.rs
@@ -1,5 +1,6 @@
use super::*;
use crate::inference::provider::is_raw_passthrough_model;
+use serde_json::json;
#[test]
fn raw_provider_models_override_the_role_default() {
diff --git a/crates/openhuman-core/src/flows/caps_host/tools/composio.rs b/crates/openhuman-core/src/flows/caps_host/tools/composio.rs
index b26deaa408..6c183131e8 100644
--- a/crates/openhuman-core/src/flows/caps_host/tools/composio.rs
+++ b/crates/openhuman-core/src/flows/caps_host/tools/composio.rs
@@ -50,18 +50,11 @@ impl FlowCallPolicy for FlowPolicy {
}
}
fn record(&self, audit_id: &str, result: &std::result::Result<Value, String>) {
- if let Some(gate) = crate::security::approval::ApprovalGate::try_global() {
- let outcome = if result.is_ok() {
- crate::security::approval::ExecutionOutcome::Success
- } else {
- crate::security::approval::ExecutionOutcome::Failure
- };
- let display_error = result
- .as_ref()
- .err()
- .map(|message| capability_error_display(message));
- gate.record_execution(audit_id, outcome, display_error.as_deref());
- }
+ let audit_result = result
+ .as_ref()
+ .map(|_| ())
+ .map_err(|message| capability_error_display(message));
+ super::super::close_audit(Some(audit_id), &audit_result);
}
}
diff --git a/crates/openhuman-core/src/flows/caps_host/tools/native.rs b/crates/openhuman-core/src/flows/caps_host/tools/native.rs
index 581706c10a..d6e55255c7 100644
--- a/crates/openhuman-core/src/flows/caps_host/tools/native.rs
+++ b/crates/openhuman-core/src/flows/caps_host/tools/native.rs
@@ -90,27 +90,16 @@ impl crate::tools::native_ops::flow_backend::FlowPolicyHooks for NativeFlowPolic
audit_id: Option<&str>,
result: &std::result::Result<Value, String>,
) {
- let Some(id) = audit_id else {
- return;
- };
- let Some(gate) = crate::security::approval::ApprovalGate::try_global() else {
- return;
- };
- let execution = if result.is_ok() {
- crate::security::approval::ExecutionOutcome::Success
- } else {
- crate::security::approval::ExecutionOutcome::Failure
- };
- let error = result
+ let audit_result = result
.as_ref()
- .err()
- .map(|body| EngineError::Capability(body.clone()).to_string());
+ .map(|_| ())
+ .map_err(|body| EngineError::Capability(body.clone()));
tracing::debug!(
target: "flows",
- audit_id = %id,
+ audit_id = ?audit_id,
success = result.is_ok(),
"[flows] recording native tool execution outcome on the approval audit trail"
);
- gate.record_execution(id, execution, error.as_deref());
+ super::super::close_audit(audit_id, &audit_result);
}
}