Skip to content

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

feat(tokenjuice): add focus tests for token juice inference

Steven Enamakelcbe511988427
diff --git a/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs
new file mode 100644
index 0000000000..fb3fe91b7d
--- /dev/null
+++ b/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs
@@ -0,0 +1,33 @@
+use super::*;
+
+#[test]
+fn the_focus_is_taken_out_of_the_arguments() {
+ let mut args = json!({ "url": "https://example.com", "summary_focus": " the pricing " });
+ assert_eq!(take_summary_focus(&mut args).as_deref(), Some("the pricing"));
+ assert_eq!(args, json!({ "url": "https://example.com" }));
+}
+
+#[test]
+fn a_blank_or_non_string_focus_is_dropped_and_still_removed() {
+ for value in [json!(" "), json!(42), json!(null)] {
+ let mut args = json!({ "url": "u", "summary_focus": value });
+ assert_eq!(take_summary_focus(&mut args), None);
+ assert_eq!(args, json!({ "url": "u" }));
+ }
+}
+
+#[test]
+fn arguments_without_a_focus_are_untouched() {
+ let mut args = json!({ "url": "u" });
+ assert_eq!(take_summary_focus(&mut args), None);
+ assert_eq!(args, json!({ "url": "u" }));
+ let mut not_an_object = json!("raw");
+ assert_eq!(take_summary_focus(&mut not_an_object), None);
+}
+
+#[test]
+fn the_property_is_an_optional_string() {
+ let property = summary_focus_property();
+ assert_eq!(property["type"], "string");
+ assert!(property["description"].as_str().unwrap().contains("summarized"));
+}