Skip to content

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

feat(user_agents): add surface tests for user agent behavior

Steven Enamakel2456eac6e657
diff --git a/crates/openhuman-core/src/user_agents/surface_tests.rs b/crates/openhuman-core/src/user_agents/surface_tests.rs
new file mode 100644
index 0000000000..c2db376556
--- /dev/null
+++ b/crates/openhuman-core/src/user_agents/surface_tests.rs
@@ -0,0 +1,53 @@
+use super::*;
+
+#[test]
+fn only_a_saas_user_scope_is_narrowed() {
+ let unlisted = "openhuman.config_update_autonomy_settings";
+ assert!(visible_in(false, false, unlisted), "single-user core");
+ assert!(visible_in(false, true, unlisted), "embedded agent");
+ assert!(visible_in(true, false, unlisted), "operator plane");
+ assert!(!visible_in(true, true, unlisted), "SaaS user");
+ assert!(visible_in(true, true, "openhuman.threads_list"));
+}
+
+#[test]
+fn turn_starting_thread_methods_stay_closed_for_now() {
+ for method in [
+ "openhuman.threads_generate_title",
+ "openhuman.threads_edit_message",
+ "openhuman.threads_regenerate",
+ ] {
+ assert!(!visible_in(true, true, method), "{method}");
+ }
+}
+
+#[test]
+fn every_listed_method_is_registered() {
+ let registered: std::collections::HashSet<String> =
+ crate::core::all::all_registered_controllers()
+ .iter()
+ .map(|c| c.rpc_method_name())
+ .collect();
+ for method in USER_METHODS {
+ assert!(registered.contains(*method), "{method} is not a registered method");
+ }
+}
+
+#[test]
+fn user_thread_ids() {
+ for ok in ["thread-1", "abc_DEF-9", &"x".repeat(128)] {
+ validate_user_thread_id(ok).unwrap();
+ }
+ for bad in [
+ "",
+ "channel:telegram/1",
+ "proactive:job",
+ "subagent:x",
+ "a/b",
+ "a:b",
+ "../x",
+ &"x".repeat(129),
+ ] {
+ assert!(validate_user_thread_id(bad).is_err(), "{bad:?}");
+ }
+}