Skip to content

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

refactor(flows): reuse shared close_audit helper in memory host

Steven Enamakele8b2875cc564
diff --git a/crates/openhuman-core/src/flows/authoring_host.rs b/crates/openhuman-core/src/flows/authoring_host.rs
index 456ecc2b43..4e4e968c9f 100644
--- a/crates/openhuman-core/src/flows/authoring_host.rs
+++ b/crates/openhuman-core/src/flows/authoring_host.rs
@@ -239,13 +239,13 @@ impl DraftPromotionCallbacks {
.await;
Ok(match response {
Ok(response) => response,
- Err(message) => catalog::SavePromotedDraftResponse::Error(
- catalog::DraftPromotionFailure {
+ Err(message) => {
+ catalog::SavePromotedDraftResponse::Error(catalog::DraftPromotionFailure {
code: "workflow_save_failed".into(),
message,
details: None,
- },
- ),
+ })
+ }
})
}
}
diff --git a/crates/openhuman-core/src/flows/authoring_host_tests.rs b/crates/openhuman-core/src/flows/authoring_host_tests.rs
index 5a58e9e502..e4939de6dc 100644
--- a/crates/openhuman-core/src/flows/authoring_host_tests.rs
+++ b/crates/openhuman-core/src/flows/authoring_host_tests.rs
@@ -29,7 +29,7 @@ fn nested_conditional_fan_in() -> Value {
#[tokio::test]
async fn saved_workflow_callback_uses_its_captured_profile_over_the_bus() {
use crate::core::runtime::{ContextOverlay, CoreContext, DispatchCtx, DomainSet};
- use crate::integrations::composio::catalog::{seed_live_catalog_cache, ToolContract};
+ use crate::integrations::composio::catalog::{ToolContract, seed_live_catalog_cache};
use crate::tools::toolpacks::ToolGroups;
let tmp = tempfile::tempdir().expect("temporary workspace");
diff --git a/crates/openhuman-core/src/flows/caps_host/memory.rs b/crates/openhuman-core/src/flows/caps_host/memory.rs
index 90bd57447d..3cd81b24cb 100644
--- a/crates/openhuman-core/src/flows/caps_host/memory.rs
+++ b/crates/openhuman-core/src/flows/caps_host/memory.rs
@@ -33,10 +33,7 @@
use std::sync::Arc;
-use async_trait::async_trait;
use serde_json::{json, Value};
-use tinyflows::caps::MemoryProvider;
-use tinyflows::error::{EngineError, Result};
#[cfg(test)]
use crate::agent::turn_origin;
@@ -178,40 +175,6 @@ impl OpenHumanMemory {
Ok(audit_id)
}
- /// Closes out the approval audit row opened by [`Self::tier_gate_write`]
- /// (E-m1): unlike the http/code/Composio node paths, this used to
- /// discard the request id (`_audit_id`) and never call
- /// `record_execution`, so an approved `remember`/`forget` left its audit
- /// row stuck open with no terminal Success/Failure outcome. A no-op when
- /// `audit_id` is `None` (no gate installed, or the decision never
- /// prompted). Takes `success`/`error` rather than a `Result` so callers
- /// don't need `EngineError: Clone` to both record the outcome and
- /// propagate the original error.
- fn record_write_execution(
- op: &str,
- audit_id: Option<&str>,
- success: bool,
- error: Option<&str>,
- ) {
- let Some(id) = audit_id else { return };
- let Some(gate) = ApprovalGate::try_global() else {
- return;
- };
- let exec = if success {
- ExecutionOutcome::Success
- } else {
- ExecutionOutcome::Failure
- };
- tracing::debug!(
- target: "flows",
- op,
- audit_id = %id,
- success,
- "{LOG_PREFIX} write: recording execution outcome on the approval audit trail"
- );
- gate.record_execution(id, exec, error);
- }
-
/// Shapes one result row. Text that did not come from a plain agent
/// learning (a synced source, a conversation, or any flow's own
/// automation output) passes through [`wrap_untrusted_for_agent`], so it
@@ -403,16 +366,7 @@ impl MemoryProvider for OpenHumanMemory {
remember_keyed(&self.config, &flow_id, key, &content, LearningKind::Fact)
.await
.map_err(|e| capability_error("remember", &e));
- Self::record_write_execution(
- "remember",
- audit_id.as_deref(),
- store_result.is_ok(),
- store_result
- .as_ref()
- .err()
- .map(ToString::to_string)
- .as_deref(),
- );
+ super::close_audit(audit_id.as_deref(), &store_result);
store_result?;
tracing::debug!(
@@ -455,16 +409,7 @@ impl MemoryProvider for OpenHumanMemory {
let forget_result = forget_matching(&self.config, filter)
.await
.map_err(|e| capability_error("forget", &e));
- Self::record_write_execution(
- "forget",
- audit_id.as_deref(),
- forget_result.is_ok(),
- forget_result
- .as_ref()
- .err()
- .map(ToString::to_string)
- .as_deref(),
- );
+ super::close_audit(audit_id.as_deref(), &forget_result);
let removed = forget_result?;
tracing::debug!(