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(tinyagents): add tests for tool scope and failure classification
Steven Enamakel19cdcb7bd7af
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rsindex d2119e4073..31264db905 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry_tests.rs@@ -558,3 +558,82 @@ async fn a_session_definition_does_not_shadow_other_ids() {"a session definition must not answer for an unrelated missing id");}++fn handle_mode_config() -> Arc<crate::config::Config> {+ let mut config = crate::config::Config::default();+ config.context.compaction_enabled = true;+ config.tokenjuice.router_enabled = true;+ config.tokenjuice.ccr_enabled = true;+ config.tokenjuice.repl_handle_enabled = true;+ Arc::new(config)+}++/// A curated belt must still be allowed to call the tools a compacted result+/// points at. The session advertises them; the harness allowlist built here is+/// what decides whether a call to them dispatches or is answered as unknown.+#[test]+fn named_scope_admits_the_tinyjuice_tools_a_handle_names() {+ let mut def = synthetic("curated", AgentTier::Worker, &[]);+ def.tools = ToolScope::Named(vec!["file_read".into()]);+ let registered = Arc::new(vec![+ "file_read".to_string(),+ "tinyjuice_retrieve".to_string(),+ "juice_find".to_string(),+ "juice_extract".to_string(),+ "juice_summarize".to_string(),+ ]);+ let tools = registry_of(vec![def.clone()])+ .with_config(handle_mode_config())+ .with_registered_tools(registered)+ .project(&def)+ .tools;+ for name in [+ "tinyjuice_retrieve",+ "juice_find",+ "juice_extract",+ "juice_summarize",+ ] {+ assert!(+ tools.contains(&name.to_string()),+ "{name} missing: {tools:?}"+ );+ }+}++#[test]+fn named_scope_skips_tinyjuice_tools_that_are_off_or_unregistered() {+ let mut def = synthetic("curated", AgentTier::Worker, &[]);+ def.tools = ToolScope::Named(vec!["file_read".into()]);++ // Handle mode off: nothing names the REPL tools, so they stay out.+ let mut off = crate::config::Config::default();+ off.context.compaction_enabled = false;+ off.tokenjuice.repl_handle_enabled = false;+ let tools = registry_of(vec![def.clone()])+ .with_config(Arc::new(off))+ .with_registered_tools(Arc::new(vec!["file_read".into(), "juice_find".into()]))+ .project(&def)+ .tools;+ assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");++ // Active but not registered: an allowlist entry for a tool that does not+ // exist would only widen the surface.+ let tools = registry_of(vec![def.clone()])+ .with_config(handle_mode_config())+ .with_registered_tools(Arc::new(vec!["file_read".into()]))+ .project(&def)+ .tools;+ assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");+}++#[test]+fn zero_tool_scope_stays_zero_tool_with_tinyjuice_active() {+ let mut def = synthetic("silent", AgentTier::Worker, &[]);+ def.tools = ToolScope::Named(Vec::new());+ let tools = registry_of(vec![def.clone()])+ .with_config(handle_mode_config())+ .with_registered_tools(Arc::new(vec!["juice_find".into()]))+ .project(&def)+ .tools;+ assert!(!tools.contains(&"juice_find".to_string()), "{tools:?}");+}diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_tests.rsindex 4242679362..90f8ac93c8 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_tests.rs@@ -317,3 +317,42 @@ fn an_unknown_tool_is_a_correctable_call_not_a_blocker() {Some(("authentication", 0)));}++#[test]+fn a_mistyped_file_path_is_a_correctable_call_not_a_missing_program() {+ let error = "Failed to resolve path 'mailbox/2026-09-18-flight.txt': No such file or directory (os error 2)";+ for tool in ["file_read", "file_write", "apply_patch"] {+ assert_eq!(+ super::super::repeated_failure::recovery_policy(tool, error, false),+ Some(("not_found", 1)),+ "{tool}"+ );+ }+ // A shell that cannot find a program is still unsupported.+ assert_eq!(+ super::super::repeated_failure::recovery_policy(+ "shell",+ "bash: jq: command not found",+ false+ ),+ Some(("unsupported", 0))+ );+}++#[test]+fn a_site_refusing_one_url_does_not_halt_the_run() {+ for tool in ["http_request", "web_fetch"] {+ for error in ["HTTP 403 Forbidden", "status=401 Unauthorized"] {+ assert_eq!(+ super::super::repeated_failure::recovery_policy(tool, error, false),+ Some(("permission", 1)),+ "{tool}: {error}"+ );+ }+ }+ // The same status from a connector action is still a credential problem.+ assert_eq!(+ super::super::repeated_failure::recovery_policy("gmail_send", "HTTP 403 Forbidden", false),+ Some(("authentication", 0))+ );+}