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
refactor(tools): remove static schema cache helper
Steven Enamakel92f82f50669e
diff --git a/crates/openhuman-core/src/tools/schema_cache.rs b/crates/openhuman-core/src/tools/schema_cache.rsdeleted file mode 100644index a4ccd94894..0000000000--- a/crates/openhuman-core/src/tools/schema_cache.rs+++ /dev/null@@ -1,42 +0,0 @@-//! Static, parse-once parameter schemas for agent tools.-//!-//! A tool whose `parameters_schema` is constant keeps the schema as a JSON-//! file next to its module and returns it through [`static_schema!`] instead-//! of rebuilding a large `json!` literal on every call. The file is embedded-//! with `include_str!`, parsed once into a `LazyLock<Value>`, and each call-//! returns a clone.--use serde_json::Value;--/// Parse an embedded schema. Panics with the call site on malformed JSON;-/// every converted tool has a test that forces its static, so a bad file-/// fails in CI rather than at runtime.-pub(crate) fn parse_embedded(site: &str, src: &str) -> Value {- match serde_json::from_str(src) {- Ok(value) => value,- Err(error) => panic!("embedded tool schema at {site} is not valid JSON: {error}"),- }-}--/// Return a constant tool schema parsed once from an embedded JSON string.-///-/// ```ignore-/// fn parameters_schema(&self) -> Value {-/// static_schema!(include_str!("parameters/my_tool.json"))-/// }-/// ```-macro_rules! static_schema {- ($src:expr) => {{- static SCHEMA: ::std::sync::LazyLock<::serde_json::Value> =- ::std::sync::LazyLock::new(|| {- $crate::tools::schema_cache::parse_embedded(concat!(file!(), ":", line!()), $src)- });- ::std::clone::Clone::clone(&*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.rsdeleted file mode 100644index 9ba381be94..0000000000--- a/crates/openhuman-core/src/tools/schema_cache_tests.rs+++ /dev/null@@ -1,24 +0,0 @@-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");-}--fn cached() -> serde_json::Value {- static_schema!(r#"{"a":1}"#)-}--#[test]-fn static_schema_clones_independently() {- let mut first = cached();- first["a"] = serde_json::json!(2);- assert_eq!(cached()["a"], 1);-}