Skip to content

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

chore(tools): remove unused ToolPolicy middleware

Steven Enamakel7c53be212c92
diff --git a/crates/openhuman-core/src/tools/README.md b/crates/openhuman-core/src/tools/README.md
index c4dd5c1bc7..f588f4df06 100644
--- a/crates/openhuman-core/src/tools/README.md
+++ b/crates/openhuman-core/src/tools/README.md
@@ -8,7 +8,6 @@ The agent tool layer. Defines the core [`Tool`] trait every agent-callable capab
- Assemble the registry the agent loop runs against: `default_tools[_with_runtime]` (minimal: shell + file read/write) and `all_tools[_with_runtime]` (full, config-gated set).
- Gate registration on config flags / env (`browser.enabled`, `node.enabled`, `runtime_python.enabled`, `learning.*`, `integrations.*`, `[search]` providers, `gitbooks.enabled`, MCP registry presence, `OPENHUMAN_LSP_ENABLED`).
- Own the cross-cutting built-in tool impls under `impl/` (filesystem, browser, generic system, generic network, meta, and the `documents`-gated document/presentation tools).
-- Provide the pre-execution [`ToolPolicy`] middleware (allow/deny gate) and the default allow-all policy.
- Normalize tool JSON schemas for provider compatibility (`SchemaCleanr`).
- Synthesize per-subagent orchestrator tools at agent-build time (`orchestrator_tools`).
- Wrap runtime-generated capability tools (`generated`).
@@ -25,7 +24,6 @@ The agent tool layer. Defines the core [`Tool`] trait every agent-callable capab
| `crates/openhuman-core/src/tools/host_extensions.rs` | OpenHuman-only readers over erased `host_extension` slots: `pack_registry_handle`, `delegation_target`, and `generated_runtime_context`. Import the shared `Tool` vocabulary from `tinytools` directly. |
| `crates/openhuman-core/src/tools/ops.rs` | Registry assembly: `default_tools`, `default_tools_with_runtime`, `all_tools`, `all_tools_with_runtime`, `browser_allowed_domains`. All config-gating logic lives here. |
| `crates/openhuman-core/src/tools/schemas.rs` (thin shell over the `schemas/` submodule: `apify.rs`, `composio.rs`, `registry.rs`, `web_search.rs`) | JSON-RPC `tools` namespace controllers + `handle_*` fns. `all_controller_schemas` / `all_registered_controllers` (re-exported as `all_tools_*`). |
-| `crates/openhuman-core/src/tools/policy.rs` | `ToolPolicy` trait + `PolicyDecision` (`Allow`/`Deny`) + allow-all `DefaultToolPolicy`. Evaluated on the agent hot path before each `execute()`. |
| `crates/openhuman-core/src/tools/schema.rs` | Re-exports `SchemaCleanr`, `CleaningStrategy` and `GEMINI_UNSUPPORTED_KEYWORDS` from `tinyagents_harness::tool` (local `$ref` resolution, provider-rejected keyword stripping, literal-union flattening). The only in-crate caller is `generated.rs`, which runs `SchemaCleanr::validate` on generated tool schemas at admission. |
| `crates/openhuman-core/src/tools/orchestrator_tools.rs` | Synthesizes named per-subagent tools from the orchestrator's `subagents = [...]` definition; expands the skills wildcard into one `Deferred` `ComposioActionTool` per connected action (reached through `tool_search`, no delegate). |
| [`crates/openhuman-core/src/mcp/registry/action_tool.rs`](../mcp/registry/action_tool.rs) | Registers connected MCP server actions as deferred tools for the orchestrator. Their searchable schemas use the same `tool_search` catalogue and JEV ranker as other deferred tools. |
@@ -51,7 +49,6 @@ The agent tool layer. Defines the core [`Tool`] trait every agent-callable capab
- Trait + types: `Tool`, `ToolSpec`, `ToolResult`, `ToolContent`, `ToolExposure`, `PermissionLevel`, `ToolScope`, `ToolCategory`, `ToolCallOptions`.
- Registry constructors: `ops::default_tools`, `ops::default_tools_with_runtime`, `ops::all_tools`, `ops::all_tools_with_runtime`.
-- Policy: `ToolPolicy`, `DefaultToolPolicy`, `PolicyDecision`.
- Schema: `SchemaCleanr`, `CleaningStrategy`.
- Controllers: `all_tools_controller_schemas`, `all_tools_registered_controllers`.
- All built-in tool structs (e.g. `ShellTool`, `FileReadTool`, `EditFileTool`, `GrepTool`, `BrowserTool`, `HttpRequestTool`, `CurlTool`, `DocumentTool`, `PresentationTool`, …) via `pub use implementations::*`, plus every re-exported domain tool set listed in `mod.rs` (agent, config, cron, desktop dashboard, flows, integrations, mcp registry, memory, platform, search, security, skills, threads todos, voice audio toolkit, web3 wallet).
diff --git a/crates/openhuman-core/src/tools/mod.rs b/crates/openhuman-core/src/tools/mod.rs
index df07e81652..2a668d5e41 100644
--- a/crates/openhuman-core/src/tools/mod.rs
+++ b/crates/openhuman-core/src/tools/mod.rs
@@ -4,7 +4,6 @@ pub mod generated;
pub mod host_extensions;
pub mod ops;
pub mod orchestrator_tools;
-pub mod policy;
pub mod registry;
pub mod schema;
mod schemas;
@@ -63,7 +62,6 @@ pub use crate::voice::audio_toolkit::tools::*;
#[cfg(feature = "web3")]
pub use crate::web3::wallet::tools::*;
pub use implementations::*;
-pub use policy::{DefaultToolPolicy, PolicyDecision, ToolPolicy};
#[allow(unused_imports)]
pub use schema::{CleaningStrategy, SchemaCleanr};
pub use schemas::{
diff --git a/crates/openhuman-core/src/tools/policy.rs b/crates/openhuman-core/src/tools/policy.rs
deleted file mode 100644
index 37421a7a98..0000000000
--- a/crates/openhuman-core/src/tools/policy.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-//! Tool-policy middleware — generic allow/deny gate evaluated before tool execution.
-//!
-//! The [`ToolPolicy`] trait provides a single extension point for centrally
-//! governing which tool invocations proceed. The agent's tool loop calls
-//! [`ToolPolicy::evaluate`] before every `tool.execute()`: if the verdict is
-//! [`PolicyDecision::Deny`], the tool is never invoked and the denial reason
-//! is returned as a `ToolResult::error` to the model.
-//!
-//! The shipped [`DefaultToolPolicy`] returns `Allow` unconditionally so
-//! existing behaviour is preserved. Downstream crates and tests can supply
-//! custom policies (rate-limiting, per-tool allow/deny lists, …) by
-//! implementing the trait.
-
-use serde_json::Value;
-
-/// Outcome of a policy evaluation.
-#[derive(Debug, Clone, PartialEq, Eq)]
-pub enum PolicyDecision {
- /// The tool call may proceed.
- Allow,
- /// The tool call is blocked. The `String` is the human-readable reason
- /// surfaced to the model (and logged).
- Deny(String),
-}
-
-/// Trait for tool-execution policies evaluated before every tool invocation.
-///
-/// Implementations MUST be cheap and synchronous — the policy is called on the
-/// agent's hot path. Expensive checks (network, disk) belong in the tool
-/// itself or in an async wrapper around this trait.
-pub trait ToolPolicy: Send + Sync {
- /// Evaluate whether a tool call is allowed.
- ///
- /// * `tool_name` — the registered name of the tool (`Tool::name()`).
- /// * `args` — the JSON arguments the model supplied for this call.
- fn evaluate(&self, tool_name: &str, args: &Value) -> PolicyDecision;
-}
-
-/// Default policy that allows every tool invocation unconditionally.
-///
-/// This is the backward-compatible default wired into the agent loop when no
-/// custom policy is provided.
-#[derive(Debug, Clone, Copy, Default)]
-pub struct DefaultToolPolicy;
-
-impl ToolPolicy for DefaultToolPolicy {
- fn evaluate(&self, _tool_name: &str, _args: &Value) -> PolicyDecision {
- PolicyDecision::Allow
- }
-}
-
-#[cfg(test)]
-#[path = "policy_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/tools/policy_tests.rs b/crates/openhuman-core/src/tools/policy_tests.rs
deleted file mode 100644
index aa1caad617..0000000000
--- a/crates/openhuman-core/src/tools/policy_tests.rs
+++ /dev/null
@@ -1,81 +0,0 @@
-use super::*;
-
-// ── DefaultToolPolicy ─────────────────────────────────────────
-
-#[test]
-fn default_policy_allows_all_tools() {
- let policy = DefaultToolPolicy;
- let decision = policy.evaluate("shell", &serde_json::json!({"command": "ls"}));
- assert_eq!(decision, PolicyDecision::Allow);
-}
-
-#[test]
-fn default_policy_allows_unknown_tool_names() {
- let policy = DefaultToolPolicy;
- assert_eq!(
- policy.evaluate("nonexistent_tool_xyz", &Value::Null),
- PolicyDecision::Allow,
- );
-}
-
-// ── Custom deny policy ────────────────────────────────────────
-
-/// A test-only policy that blocks a specific tool by name.
-struct DenyByNamePolicy {
- blocked: String,
- reason: String,
-}
-
-impl ToolPolicy for DenyByNamePolicy {
- fn evaluate(&self, tool_name: &str, _args: &Value) -> PolicyDecision {
- if tool_name == self.blocked {
- PolicyDecision::Deny(self.reason.clone())
- } else {
- PolicyDecision::Allow
- }
- }
-}
-
-#[test]
-fn custom_deny_policy_blocks_matching_tool() {
- let policy = DenyByNamePolicy {
- blocked: "dangerous_tool".into(),
- reason: "blocked by test policy".into(),
- };
- let decision = policy.evaluate("dangerous_tool", &Value::Null);
- assert_eq!(
- decision,
- PolicyDecision::Deny("blocked by test policy".into()),
- );
-}
-
-#[test]
-fn custom_deny_policy_allows_non_matching_tool() {
- let policy = DenyByNamePolicy {
- blocked: "dangerous_tool".into(),
- reason: "blocked by test policy".into(),
- };
- let decision = policy.evaluate("safe_tool", &Value::Null);
- assert_eq!(decision, PolicyDecision::Allow);
-}
-
-// ── Deny-all policy ───────────────────────────────────────────
-
-struct DenyAllPolicy;
-
-impl ToolPolicy for DenyAllPolicy {
- fn evaluate(&self, _tool_name: &str, _args: &Value) -> PolicyDecision {
- PolicyDecision::Deny("all tools denied".into())
- }
-}
-
-#[test]
-fn deny_all_policy_blocks_every_tool() {
- let policy = DenyAllPolicy;
- for name in &["shell", "file_read", "memory_store", "web_search"] {
- assert_eq!(
- policy.evaluate(name, &Value::Null),
- PolicyDecision::Deny("all tools denied".into()),
- );
- }
-}