Skip to content

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

refactor(tinyflows): centralize native tool prefix constant

Steven Enamakelf80c3f4da4a3
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/tools/mod.rs b/crates/openhuman-core/src/flows/tinyflows/caps/tools/mod.rs
index 8e9ad5c6a8..4a94a86f8b 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/tools/mod.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/tools/mod.rs
@@ -40,7 +40,8 @@ pub(crate) use native::NativeToolBackend;
/// `oh:web_search`. Native tools run through the same agent tool registry the
/// assistant uses (`tools::native_ops::execute_tool`), so a flow can call
/// search / media generation / file / shell / etc. — the full toolset.
-pub(crate) const NATIVE_TOOL_PREFIX: &str = "oh:";
+pub(crate) const NATIVE_TOOL_PREFIX: &str =
+ crate::tools::native_ops::flow_backend::NATIVE_TOOL_PREFIX;
/// What a backend needs to service one call.
///
diff --git a/crates/openhuman-core/src/tools/native_ops/flow_backend.rs b/crates/openhuman-core/src/tools/native_ops/flow_backend.rs
index a190d913b3..d17cd549fc 100644
--- a/crates/openhuman-core/src/tools/native_ops/flow_backend.rs
+++ b/crates/openhuman-core/src/tools/native_ops/flow_backend.rs
@@ -11,6 +11,8 @@ use tinytools::ToolResult;
use crate::{config::Config, security::SecurityPolicy};
+pub(crate) const NATIVE_TOOL_PREFIX: &str = "oh:";
+
/// Flow-specific policy and approval operations supplied by the host adapter.
#[async_trait]
pub(crate) trait FlowPolicyHooks: Send + Sync {
@@ -35,7 +37,7 @@ pub(crate) async fn invoke(
args: Value,
hooks: &dyn FlowPolicyHooks,
) -> Result<Value, String> {
- let tool_name = slug.strip_prefix("oh:").unwrap_or(slug).trim();
+ let tool_name = slug.strip_prefix(NATIVE_TOOL_PREFIX).unwrap_or(slug).trim();
if tool_name.is_empty() {
return Err("tool_call node: native tool slug is empty (expected `oh:<tool_name>`)".into());
}
@@ -46,7 +48,6 @@ pub(crate) async fn invoke(
tracing::debug!(target: "flows", %tool_name, ?class, "[flows] dispatching NATIVE OpenHuman tool");
let result = super::execute_tool_with_security(config, policy, tool_name, args, false)
.await
- .map_err(|error| format!("{error}"))
.and_then(|outcome| {
reject_failed_native_tool_result(slug, &outcome.result)
.map(|()| native_tool_payload(&outcome.result))