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
test: add coverage for plan review, composio, and install tools
Steven Enamakel2ac3e0f993a0
diff --git a/crates/openhuman-core/src/agent/plan_review/tool_tests.rs b/crates/openhuman-core/src/agent/plan_review/tool_tests.rsindex eee3ff49f7..7225473564 100644--- a/crates/openhuman-core/src/agent/plan_review/tool_tests.rs+++ b/crates/openhuman-core/src/agent/plan_review/tool_tests.rs@@ -1,6 +1,16 @@use super::*;use crate::agent::turn_origin::with_origin;-use crate::security::approval::{ApprovalChatContext, APPROVAL_CHAT_CONTEXT};+use crate::security::approval::ApprovalChatContext;++/// The execution context the harness hands a tool dispatched inside a turn+/// whose chat is `chat`.+fn chat_tool_context(+ chat: crate::security::approval::ApprovalChatContext,+) -> tinyagents_harness::tool::ToolExecutionContext {+ crate::agent::tinyagents::host::run_context::tool_context_with_approval(+ crate::security::approval::ApprovalTurnContext::chat(chat),+ )+}#[tokio::test]async fn non_interactive_origin_auto_approves() {@@ -31,16 +41,13 @@ async fn interactive_turn_parks_until_resolved() {client_id: "c-int".into(),request_id: Some("req-int".into()),},- APPROVAL_CHAT_CONTEXT.scope(- ApprovalChatContext {+ tool.execute_with_context(json!({ "summary": "plan", "steps": ["one"] }), tinytools::ToolCallOptions::default(), Some(&chat_tool_context(ApprovalChatContext {thread_id: "t-int".into(),client_id: "c-int".into(),request_id: Some("req-int".into()),- },- tool.execute(json!({ "summary": "plan", "steps": ["one"] })),- ),+ }))),);- // The web channel supplies both task locals. One poll reaches the gate+ // The web channel supplies the origin and the chat context. One poll reaches the gate// and must remain pending; no wall-clock timeout is needed to prove park.tokio::pin!(fut);assert!(diff --git a/crates/openhuman-core/src/integrations/composio/tools_metadata_and_sandbox_tests.rs b/crates/openhuman-core/src/integrations/composio/tools_metadata_and_sandbox_tests.rsindex c2fd7ef3da..642301cc9a 100644--- a/crates/openhuman-core/src/integrations/composio/tools_metadata_and_sandbox_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/tools_metadata_and_sandbox_tests.rs@@ -174,9 +174,19 @@ fn canonicalize_toolkit_slug_maps_known_aliases_and_passes_through() {assert_eq!(super::super::canonicalize_toolkit_slug("gmail"), "gmail");}+/// The execution context the harness hands a tool dispatched inside a turn+/// whose chat is `chat`.+fn chat_tool_context(+ chat: crate::security::approval::ApprovalChatContext,+) -> tinyagents_harness::tool::ToolExecutionContext {+ crate::agent::tinyagents::host::run_context::tool_context_with_approval(+ crate::security::approval::ApprovalTurnContext::chat(chat),+ )+}+#[tokio::test]async fn connect_tool_validates_before_gating_in_chat_context() {- use crate::security::approval::{ApprovalChatContext, APPROVAL_CHAT_CONTEXT};+ use crate::security::approval::ApprovalChatContext;// With a chat context the interactive guard passes; with no composio// credentials the client factory errors — so execute canonicalizes the// slug, reloads config, checks connected state, and returns a clean error@@ -188,11 +198,7 @@ async fn connect_tool_validates_before_gating_in_chat_context() {client_id: "c-test".into(),request_id: None,};- let result = APPROVAL_CHAT_CONTEXT- .scope(- ctx,- tool.execute(serde_json::json!({ "toolkit": "google_drive" })),- )+ let result = tool.execute_with_context(serde_json::json!({ "toolkit": "google_drive" }), tinytools::ToolCallOptions::default(), Some(&chat_tool_context(ctx))).await.unwrap();assert!(result.is_error);diff --git a/crates/openhuman-core/src/tools/impl/system/install_tool_tests.rs b/crates/openhuman-core/src/tools/impl/system/install_tool_tests.rsindex fe76ff0cc1..d64089813c 100644--- a/crates/openhuman-core/src/tools/impl/system/install_tool_tests.rs+++ b/crates/openhuman-core/src/tools/impl/system/install_tool_tests.rs@@ -1,5 +1,5 @@use super::*;-use crate::security::approval::{ApprovalChatContext, APPROVAL_CHAT_CONTEXT};+use crate::security::approval::ApprovalChatContext;use crate::security::AutonomyLevel;fn policy(allow_install: bool, autonomy: AutonomyLevel) -> Arc<SecurityPolicy> {@@ -21,11 +21,20 @@ fn chat_ctx() -> ApprovalChatContext {}}+/// The execution context the harness hands a tool dispatched inside a turn+/// whose chat is `chat`.+fn chat_tool_context(+ chat: crate::security::approval::ApprovalChatContext,+) -> tinyagents_harness::tool::ToolExecutionContext {+ crate::agent::tinyagents::host::run_context::tool_context_with_approval(+ crate::security::approval::ApprovalTurnContext::chat(chat),+ )+}+#[tokio::test]async fn blocked_when_install_disabled() {let tool = InstallToolTool::new(policy(false, AutonomyLevel::Full));- let result = APPROVAL_CHAT_CONTEXT- .scope(chat_ctx(), tool.execute(json!({ "package": "jq" })))+ let result = tool.execute_with_context(json!({ "package": "jq" }), tinytools::ToolCallOptions::default(), Some(&chat_tool_context(chat_ctx()))).await.unwrap();assert!(result.is_error);@@ -35,8 +44,7 @@ async fn blocked_when_install_disabled() {#[tokio::test]async fn blocked_when_readonly() {let tool = InstallToolTool::new(policy(true, AutonomyLevel::ReadOnly));- let result = APPROVAL_CHAT_CONTEXT- .scope(chat_ctx(), tool.execute(json!({ "package": "jq" })))+ let result = tool.execute_with_context(json!({ "package": "jq" }), tinytools::ToolCallOptions::default(), Some(&chat_tool_context(chat_ctx()))).await.unwrap();assert!(result.is_error);@@ -46,11 +54,7 @@ async fn blocked_when_readonly() {#[tokio::test]async fn rejects_injection_in_package_name() {let tool = InstallToolTool::new(policy(true, AutonomyLevel::Full));- let result = APPROVAL_CHAT_CONTEXT- .scope(- chat_ctx(),- tool.execute(json!({ "package": "jq; rm -rf /" })),- )+ let result = tool.execute_with_context(json!({ "package": "jq; rm -rf /" }), tinytools::ToolCallOptions::default(), Some(&chat_tool_context(chat_ctx()))).await.unwrap();assert!(result.is_error);@@ -63,7 +67,7 @@ async fn rejects_injection_in_package_name() {#[tokio::test]async fn refuses_in_autonomous_turn_without_chat_context() {- // No APPROVAL_CHAT_CONTEXT scope → background/autonomous turn → refused+ // No chat approval context → background/autonomous turn → refused// by Gate 0 before any install logic runs.let tool = InstallToolTool::new(policy(true, AutonomyLevel::Full));let result = tool.execute(json!({ "package": "jq" })).await.unwrap();