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
feat(tools): cache tool schemas to avoid repeated rebuilds
Steven Enamakelcfd34bbf9013
diff --git a/crates/openhuman-core/src/desktop/control/tools_schema_tests.rs b/crates/openhuman-core/src/desktop/control/tools_schema_tests.rsindex b91d675e76..3c87d759bb 100644--- a/crates/openhuman-core/src/desktop/control/tools_schema_tests.rs+++ b/crates/openhuman-core/src/desktop/control/tools_schema_tests.rs@@ -44,3 +44,17 @@ fn expected_schemas() -> Vec<(DesktopToolKind, serde_json::Value)> {"required":["confirmation_id"]})),]}++#[test]+fn desktop_static_schemas_match_json_literals() {+ let config = std::sync::Arc::new(crate::config::Config::default());+ for (kind, expected) in expected_schemas() {+ let tool = DesktopTool::new(config.clone(), kind);+ assert_eq!(+ tinytools::Tool::parameters_schema(&tool),+ expected,+ "{}",+ tinytools::Tool::name(&tool)+ );+ }+}diff --git a/crates/openhuman-core/src/tools/schema_cache.rs b/crates/openhuman-core/src/tools/schema_cache.rsindex 622336f8a3..56278fe15a 100644--- a/crates/openhuman-core/src/tools/schema_cache.rs+++ b/crates/openhuman-core/src/tools/schema_cache.rs@@ -39,3 +39,7 @@ macro_rules! static_schema {}pub(crate) use static_schema;++#[cfg(test)]+#[path = "schema_cache_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/tools/schema_cache_tests.rs b/crates/openhuman-core/src/tools/schema_cache_tests.rsnew file mode 100644index 0000000000..5d5bfd2fe8--- /dev/null+++ b/crates/openhuman-core/src/tools/schema_cache_tests.rs@@ -0,0 +1,21 @@+use super::*;++#[test]+fn parse_embedded_returns_the_parsed_value() {+ let value = parse_embedded("test", r#"{"type":"object","properties":{}}"#);+ assert_eq!(value["type"], "object");+}++#[test]+#[should_panic(expected = "not valid JSON")]+fn parse_embedded_panics_with_site_on_malformed_json() {+ parse_embedded("test:1", "{ nope");+}++#[test]+fn static_schema_clones_independently() {+ let mut first = static_schema!(r#"{"a":1}"#);+ first["a"] = serde_json::json!(2);+ let second = static_schema!(r#"{"a":1}"#);+ assert_eq!(second["a"], 1);+}