The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(tinyagents): block shell commands that escape the workspace
Steven Enamakel72531def1010
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rsindex ae94e97e58..eb1043edb0 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs@@ -414,6 +414,26 @@ impl SecurityGate for OpenHumanSecurityGate {/// choice. A refusal at any stage is still terminal, and `channel_approved`/// is carried forward so a later prompting stage does not ask twice.async fn authorize_tool(&self, call: &ToolCallRequest) -> TaResult<GateDecision> {+ // A nested call (made by a running tool, not the model) can never be+ // parked for a human, and the stages below prompt. Fail closed rather+ // than prompt or guess which stages would have: nested calls are off+ // (`RunLimits::max_nested_depth = 0`) and stay refused here until the+ // host decides how to authorize them.+ if call.is_nested() {+ tracing::warn!(+ target: "tinyagents",+ tool = %call.tool_name,+ "[tinyagents::host::security] nested tool call refused (fail closed)"+ );+ return Ok(GateDecision::deny(+ PolicyDenial::PolicyDenied {+ tool: &call.tool_name,+ policy: "nested tool calls",+ reason: "Tools may not call other tools in this session.",+ }+ .render(),+ ));+ }let policy = self.effective_policy();#[cfg(feature = "modules")]let desktop_approval_disabled = match self.resolve_tool(&call.tool_name) {diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rsindex 2d0de3cfca..830f665626 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate_tests.rs@@ -492,3 +492,26 @@ fn an_approved_park_is_still_prompted_and_allowed() {));assert!(decision.is_allowed());}++#[tokio::test]+async fn a_nested_call_is_refused_even_for_a_read_only_tool() {+ let nested = req("read_file", json!({ "path": "notes.md" })).with_parent_call_id("parent-1");+ let decision = gate(AutonomyLevel::Full)+ .authorize_tool(&nested)+ .await+ .unwrap();+ assert!(!decision.is_allowed());+ assert!(decision+ .denial_reason()+ .expect("denial reason")+ .contains("may not call other tools"));+}++#[tokio::test]+async fn a_plain_call_is_unaffected_by_the_nested_refusal() {+ let decision = gate(AutonomyLevel::Full)+ .authorize_tool(&req("read_file", json!({ "path": "notes.md" })))+ .await+ .unwrap();+ assert_eq!(decision, GateDecision::Allow);+}diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/embedder_hooks.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/embedder_hooks.rsindex 3a307f72eb..aca6086b22 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/embedder_hooks.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/embedder_hooks.rs@@ -109,6 +109,60 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>Ok(())}+ /// Nested-call form of the `before_tool` enforcement above.+ ///+ /// `before_tool` never runs for a call a tool makes through+ /// `ToolExecutionContext::call_tool`, so without this a `Deny` hook could+ /// be bypassed by any tool that calls another. Mirrors `before_tool`:+ /// `Deny` and `Ask` refuse (a nested call can never be parked for a human).+ /// A `ProceedWith` rewrite cannot be applied to a call the middleware may+ /// not mutate, so it refuses too rather than letting the un-narrowed+ /// arguments through.+ async fn check_nested_tool(+ &self,+ _ctx: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,+ _state: &(),+ call: &TaToolCall,+ ) -> TaResult<()> {+ let context = crate::agent::hooks::ToolHookContext {+ event: crate::agent::hooks::ToolHookEvent::PreToolUse,+ call_id: call.id.clone(),+ tool_name: call.name.clone(),+ arguments: call.arguments.clone(),+ success: None,+ duration_ms: None,+ output: None,+ error: None,+ session_id: None,+ agent_id: None,+ };+ for hook in &self.hooks {+ let refusal = match hook.before_tool_decision(&context).await {+ crate::agent::hooks::ToolHookDecision::Proceed => continue,+ crate::agent::hooks::ToolHookDecision::ProceedWith(_) => {+ "rewrites the call, which a nested call cannot apply".to_string()+ }+ crate::agent::hooks::ToolHookDecision::Deny(reason) => {+ format!("denied: {reason}")+ }+ crate::agent::hooks::ToolHookDecision::Ask(reason) => {+ format!("requires approval, unavailable for a nested call: {reason}")+ }+ };+ tracing::info!(+ hook = hook.name(),+ tool = context.tool_name,+ "[tinyagents::mw] nested tool call refused by tool hook"+ );+ return Err(tinyagents_harness::error::TinyAgentsError::Tool(format!(+ "tool hook '{}' refused nested call to {}: {refusal}",+ hook.name(),+ context.tool_name+ )));+ }+ Ok(())+ }+async fn after_tool(&self,_ctx: &mut RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,diff --git a/crates/openhuman-core/src/tools/README.md b/crates/openhuman-core/src/tools/README.mdindex c8989c7c7a..b953efcddd 100644--- a/crates/openhuman-core/src/tools/README.md+++ b/crates/openhuman-core/src/tools/README.md@@ -125,6 +125,6 @@ None. No `store.rs`; the module holds no persisted state. Tools that persist (me- Node tools are co-gated: `shell`, `node_exec`, and `npm_exec` share one memoised `NodeBootstrap`; with `node.enabled = false` (or the `runtime-node` feature off), node/npm tools are not registered and shell skips PATH injection.- `external_effect_with_args` is the hook the harness checks at the gate-decision point, not the arg-less variant. Override it for per-call gating (e.g. composio `execute` vs `list`).- `PermissionLevel` ordering is load-bearing: the runtime compares `<` to reject tools above a channel's max; `permission_level()` should return the *minimum* level across a multi-action tool, with `permission_level_with_args` doing the per-call check.-- `is_concurrency_safe` is still advisory in practice: it is mapped to `ToolRuntime.idempotent` in `agent/tinyagents/tools.rs`, and tinyagents only runs a multi-call batch concurrently when no tool-wrap middleware is registered. OpenHuman's approval and scope gates are `wrap_tool` middlewares, so its turns take the serial path.+- `is_concurrency_safe` is mapped to `ToolRuntime.idempotent` in `agent/tinyagents/tools.rs`. Tool-wrap middlewares take `&RunContext` and declare `concurrent_safe()` (default `true`), so a multi-call batch runs concurrently when the tools are concurrency-safe and every registered wrap is; one wrap returning `false` serializes all batches. OpenHuman's wraps (`cli_rpc_only`, `tool_policy`, and the library `ApprovalGateMiddleware`, which serializes its own prompts) are all concurrency-safe. Nested tool calls (`call_tool`) stay off (`max_nested_depth = 0`); the security gate and embedder hooks refuse them if enabled.- RPC surface is intentionally tiny (6 methods): anything not in `schemas.rs`/`schemas/` is agent-only.- Search is configured with providers and per-role provider order in `[search]`: `search.providers` controls each provider's enabled state and route (`managed` or `direct`), while `search.roles` orders providers for search, grounded answers, and page contents. The first usable provider handles a call, with module fallback on balance, rate-limit, and availability errors. Single-engine settings are migrated when configuration is loaded; see [`search/README.md`](../search/README.md) for the host model and [`web-search.md`](../../../../gitbooks/features/native-tools/web-search.md) for user-facing setup.