Skip to content

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

feat(subagent_runner): add scope-based filtering for cached toolkit actions

Steven Enamakel4dea0e631cf1
diff --git a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs
index 4bd4744de5..11d41ed213 100644
--- a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs
@@ -820,6 +820,38 @@ type LoadedConfig = Result<std::sync::Arc<crate::config::Config>, String>;
// Typed mode — narrow prompt, filtered tools, cheaper model
// ─────────────────────────────────────────────────────────────────────────────
+async fn filter_cached_toolkit_actions_with_current_scope(
+ agent_id: &str,
+ toolkit: &str,
+ config: &crate::config::Config,
+ actions: &[crate::agent::context::prompt::ConnectedIntegrationTool],
+) -> Vec<crate::agent::context::prompt::ConnectedIntegrationTool> {
+ let pref = crate::integrations::composio::ops::load_user_scope_pref(config, toolkit).await;
+ let before = actions.len();
+ let filtered: Vec<_> = actions
+ .iter()
+ .filter(|action| {
+ crate::integrations::composio::providers::is_action_visible_with_pref(
+ &action.name,
+ &pref,
+ )
+ })
+ .cloned()
+ .collect();
+ tracing::debug!(
+ agent_id = %agent_id,
+ toolkit = %toolkit,
+ cached_actions = before,
+ visible_actions = filtered.len(),
+ hidden_actions = before.saturating_sub(filtered.len()),
+ read = pref.read,
+ write = pref.write,
+ admin = pref.admin,
+ "[subagent_runner:typed] re-filtered cached toolkit catalogue with current user scope"
+ );
+ filtered
+}
+
/// Execute a sub-agent in "Typed" mode.
///
/// This mode builds a brand-new, minimized system prompt specifically for the