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
fix(tinymemes): gate remix on the memes component and export cooldown
Steven Enamakel49b40f8bd6da
diff --git a/crates/openhuman-core/src/tinymemes/inference.rs b/crates/openhuman-core/src/tinymemes/inference.rsindex 72fdfd61e2..5d536e765a 100644--- a/crates/openhuman-core/src/tinymemes/inference.rs+++ b/crates/openhuman-core/src/tinymemes/inference.rs@@ -40,7 +40,9 @@ pub(crate) async fn complete(config: &Config, system: &str, user: &str) -> Resul.map_err(|e| format!("openhuman inference failed model={resolved}: {e}"))?;let text = response.text();if text.trim().is_empty() {- return Err(format!("openhuman inference returned no text model={resolved}"));+ return Err(format!(+ "openhuman inference returned no text model={resolved}"+ ));}Ok(text)}diff --git a/crates/openhuman-core/src/tinymemes/mod.rs b/crates/openhuman-core/src/tinymemes/mod.rsindex 692b0689a1..1435831089 100644--- a/crates/openhuman-core/src/tinymemes/mod.rs+++ b/crates/openhuman-core/src/tinymemes/mod.rs@@ -262,8 +262,7 @@ async fn remix_with(let result = if changed {let id = crate::threads::store::run_reply_message_id(turn.request_id);let remixed = remixed.clone();- if let Err(e) =- crate::core::runtime::spawn_blocking_scoped(move || remixed.mark(id)).await+ if let Err(e) = crate::core::runtime::spawn_blocking_scoped(move || remixed.mark(id)).await{log::warn!("[tinymemes] remixed-id write task failed: {e}");}@@ -306,9 +305,7 @@ fn turn_line(format!("[tinymemes] turn arm=treatment bucket={bucket} request_id={request_id} turn_ms={turn_ms} \remix_ms={remix_ms} outcome={result} score={} skipped={} wants_more_memes={}",- response- .and_then(|r| r.score)- .map_or(-1, i32::from),+ response.and_then(|r| r.score).map_or(-1, i32::from),response.and_then(|r| r.skipped).map_or("none", |s| match s {diff --git a/crates/openhuman-core/src/tinymemes/mod_tests.rs b/crates/openhuman-core/src/tinymemes/mod_tests.rsindex 6971805023..93d9f3cf48 100644--- a/crates/openhuman-core/src/tinymemes/mod_tests.rs+++ b/crates/openhuman-core/src/tinymemes/mod_tests.rs@@ -106,13 +106,22 @@ async fn run(#[test]fn the_budget_defaults_to_the_configured_twenty_seconds() {let config = Config::default();- assert_eq!(budget_with(None, config.memes.timeout_ms), Duration::from_secs(20));+ assert_eq!(+ budget_with(None, config.memes.timeout_ms),+ Duration::from_secs(20)+ );}#[test]fn the_budget_env_override_beats_config_and_bad_values_fall_back() {- assert_eq!(budget_with(Some("1500"), 20_000), Duration::from_millis(1500));- assert_eq!(budget_with(Some("soon"), 7_000), Duration::from_millis(7_000));+ assert_eq!(+ budget_with(Some("1500"), 20_000),+ Duration::from_millis(1500)+ );+ assert_eq!(+ budget_with(Some("soon"), 7_000),+ Duration::from_millis(7_000)+ );}#[test]@@ -283,3 +292,19 @@ fn flag_values_enable_remixing() {assert!(flag_enabled("ab:30"));assert!(!flag_enabled("off"));}++#[tokio::test]+async fn component_off_refuses_the_remix_before_any_module_load() {+ let mut config = Config::default();+ config.components.memes = false;+ let request = RemixRequest {+ conversation: Vec::new(),+ reply: "hi".to_owned(),+ region: None,+ enabled: true,+ timeout_ms: 100,+ deliver: false,+ };+ let err = service::remix(&config, request).await.unwrap_err();+ assert!(err.contains("component is off"), "{err}");+}diff --git a/crates/openhuman-core/src/tinymemes/service.rs b/crates/openhuman-core/src/tinymemes/service.rsindex 1d640fb612..c0acd36f28 100644--- a/crates/openhuman-core/src/tinymemes/service.rs+++ b/crates/openhuman-core/src/tinymemes/service.rs@@ -68,6 +68,16 @@ impl tinybus::Interface for HostService {}}+const COOLDOWN_ENV: &str = "OPENHUMAN_TINYMEMES_MEME_COOLDOWN";++/// The module reads its meme cooldown from the environment; hand it+/// `[memes] meme_cooldown` unless the operator already set the variable.+fn export_cooldown(config: &Config) {+ if std::env::var_os(COOLDOWN_ENV).is_none() {+ std::env::set_var(COOLDOWN_ENV, config.memes.meme_cooldown.to_string());+ }+}+/// Serve the module's host callbacks on the module bus.pub(crate) async fn install(connection: &Connection) -> tinybus::Result<()> {connection@@ -83,6 +93,10 @@ pub(crate) async fn install(connection: &Connection) -> tinybus::Result<()> {/// Remix one reply through the loaded module, serving its callbacks for/// `config`'s workspace meanwhile.pub(crate) async fn remix(config: &Config, request: RemixRequest) -> Result<RemixResponse, String> {+ if !config.components.memes {+ return Err("the memes component is off".to_owned());+ }+ export_cooldown(config);crate::modules::ensure_loaded(config, MODULE_ID).await?;let runtime = crate::modules::host::runtime().await