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(tinymemes): meme research + review, richer turn log, vendor bump
killbill46c8f04a8111
diff --git a/crates/openhuman-core/src/tinymemes/host.rs b/crates/openhuman-core/src/tinymemes/host.rsindex d8abaab1d6..b939122402 100644--- a/crates/openhuman-core/src/tinymemes/host.rs+++ b/crates/openhuman-core/src/tinymemes/host.rs@@ -20,6 +20,10 @@ use crate::threads::store::ConversationMessage;const DIR: &str = "tinymemes";const INDEX_FILE: &str = "slang-index.json";+const MEME_INDEX_FILE: &str = "meme-index.json";+/// Newly learned GIFs are pending until a person approves them; `0` auto-approves+/// GIFs that pass every check instead.+pub(crate) const MEME_REVIEW_ENV: &str = "OPENHUMAN_TINYMEMES_MEME_REVIEW";const REMIXED_FILE: &str = "remixed.json";/// Remixed-message ids remembered per workspace (oldest dropped first).const REMIXED_CAP: usize = 4000;@@ -108,10 +112,22 @@ pub(crate) fn host_for(config: &Config) -> Option<Arc<Host>> {}};+ let search = openhuman_search(config);+ let meme_policy = tinymemes::MemeIndexPolicy {+ auto_approve: std::env::var(MEME_REVIEW_ENV).is_ok_and(|v| v.trim() == "0"),+ ..tinymemes::MemeIndexPolicy::default()+ };+ let meme_index = match std::fs::read_to_string(dir.join(MEME_INDEX_FILE)) {+ Ok(json) => tinymemes::MemeIndex::from_json(&json, meme_policy).unwrap_or_else(|e| {+ log::warn!("[tinymemes] meme index unreadable, starting fresh: {e}");+ tinymemes::MemeIndex::new(meme_policy)+ }),+ Err(_) => tinymemes::MemeIndex::new(meme_policy),+ };let (researcher, research_label): (Option<Arc<dyn SlangResearcher>>, &str) =match env.web_researcher(&http) {Some(r) => (Some(Arc::new(r)), "env:openrouter-web"),- None => match openhuman_search(config) {+ None => match search.clone() {Some(search) => (Some(Arc::new(SearchResearcher::new(search, chat.clone()))),"openhuman-search",@@ -121,8 +137,9 @@ pub(crate) fn host_for(config: &Config) -> Option<Arc<Host>> {};let mut builder = MemeEngine::builder(jev, chat)- .source(Arc::new(tinymemes::source::Imgflip::new(http)))+ .source(Arc::new(tinymemes::source::Imgflip::new(http.clone()))).slang_index(Arc::new(index))+ .meme_index(Arc::new(meme_index)).policy(rating_policy())// Research runs in the background after delivery, never on the// reply's critical path.@@ -130,11 +147,24 @@ pub(crate) fn host_for(config: &Config) -> Option<Arc<Host>> {if let Some(researcher) = researcher {builder = builder.researcher(researcher);}+ let meme_research_label = match search {+ Some(search) => {+ builder = builder+ .meme_researcher(Arc::new(tinymemes::GiphyPageResearcher::new(search, http)));+ if meme_policy.auto_approve {+ "giphy-pages"+ } else {+ "giphy-pages (review)"+ }+ }+ None => "off (no search provider)",+ };let engine = builder.build();log::info!("[tinymemes] engine ready chat={chat_label} jev={jev_label} research={research_label} \- slang_terms={}",- engine.slang_index().len("IN")+ meme_research={meme_research_label} slang_terms={} learned_memes={}",+ engine.slang_index().len("IN"),+ engine.meme_index().len("IN"));let host = Arc::new(Host {engine,@@ -190,6 +220,13 @@ impl Host {}}+ pub(crate) fn save_memes(&self) {+ let json = self.engine.meme_index().to_json();+ if let Err(e) = std::fs::write(self.dir.join(MEME_INDEX_FILE), json) {+ log::warn!("[tinymemes] cannot save meme index: {e}");+ }+ }+pub(crate) fn save_index(&self) {let json = self.engine.slang_index().to_json();if let Err(e) = std::fs::write(self.dir.join(INDEX_FILE), json) {diff --git a/crates/openhuman-core/src/tinymemes/mod.rs b/crates/openhuman-core/src/tinymemes/mod.rsindex 8fac375d04..1f75d32e36 100644--- a/crates/openhuman-core/src/tinymemes/mod.rs+++ b/crates/openhuman-core/src/tinymemes/mod.rs@@ -125,10 +125,45 @@ pub(crate) async fn remix_final_reply(}}+ // Meme research, off the critical path: a meme was allowed but nothing in+ // the catalog fit. New GIFs are vetted before Jev can pick them.+ if outcome.wants_more_memes() {+ if let Some(reading) = &outcome.reading {+ let host = host.clone();+ let intent = reading.reply_intent;+ let request_id = request_id.to_owned();+ // Only a short, generic meme concept derived from this is searched.+ let moment = user_message.to_owned();+ tokio::spawn(async move {+ match host.engine.learn_memes(intent, &moment).await {+ Ok(Some(r)) => log::info!(+ "[tinymemes] meme research request_id={request_id} query={:?} found={} \+ approved={} pending={} rejected_rating={} rejected_topic={} duplicates={} \+ failed_jev={}",+ r.query,+ r.found,+ r.approved,+ r.pending,+ r.rejected_rating,+ r.rejected_topic,+ r.duplicates,+ r.failed_verification+ ),+ Ok(None) => {+ log::debug!("[tinymemes] meme research skipped (repeat, budget, or busy)")+ }+ Err(e) => log::warn!("[tinymemes] meme research failed: {e}"),+ }+ host.save_memes();+ });+ }+ }+let remixed = outcome.remix.is_some() && outcome.reply.trim() != reply.trim();let result = if remixed {host.mark_remixed(crate::threads::store::run_reply_message_id(request_id));host.save_index();+ host.save_memes();"remixed"} else if outcome.skipped.is_some() && outcome.rating.is_none() {"error"@@ -153,8 +188,8 @@ fn log_outcome(let reading = outcome.and_then(|o| o.reading.as_ref());log::info!("[tinymemes] turn arm=treatment bucket={bucket} request_id={request_id} turn_ms={turn_ms} \- remix_ms={remix_ms} outcome={result} score={} tier={} memes={} rewrite_kept={} \- slang_enough={} wants_search={}",+ remix_ms={remix_ms} outcome={result} score={} tier={} mode={} memes={} rewrite_kept={} \+ dupes={} slang_enough={} wants_search={} meme_pick={} meme_p={}",rating.map_or(-1, |r| i32::from(r.score)),rating.map_or("none", |r| match r.tier {tinymemes::Tier::Off => "off",@@ -162,11 +197,27 @@ fn log_outcome(tinymemes::Tier::Spicy => "spicy",tinymemes::Tier::Unhinged => "unhinged",}),+ remix.map_or("none", |r| match r.mode {+ tinymemes::RemixMode::Rewrite => "rewrite",+ tinymemes::RemixMode::MemeOnly => "meme_only",+ }),remix.map_or(0, |r| r.memes.len()),remix.is_none_or(|r| r.rewrite_kept),+ remix.map_or(0, |r| r.duplicates_removed),reading.and_then(|r| r.slang_enough).map_or_else(|| "none".to_owned(), |p| format!("{p:.2}")),reading.is_some_and(|r| r.wants_more_slang(0.5)),+ reading.map_or_else(+ || "none".to_owned(),+ |r| match &r.meme {+ tinymemes::reading::MemePick::Pick(t) => t.replace(' ', "_"),+ tinymemes::reading::MemePick::NoneFit => "none_fit".to_owned(),+ tinymemes::reading::MemePick::Unasked => "unasked".to_owned(),+ }+ ),+ reading+ .and_then(|r| r.meme_p)+ .map_or_else(|| "none".to_owned(), |p| format!("{p:.2}")),);}diff --git a/scripts/ci/check-openhuman-rust-layout.mjs b/scripts/ci/check-openhuman-rust-layout.mjsindex 030e09426d..cf3c9a9005 100644--- a/scripts/ci/check-openhuman-rust-layout.mjs+++ b/scripts/ci/check-openhuman-rust-layout.mjs@@ -47,7 +47,7 @@ const LEGACY_LIMIT_ENTRIES = [["crates/openhuman-core/src/agent/subagent_host/lifecycle.rs", 1309],["crates/openhuman-core/src/agent/subagent_host/ops/runner.rs", 1150],["crates/openhuman-core/src/tools/ops.rs", 1209],- ["crates/openhuman-core/src/web_chat/progress_bridge.rs", 1299],+ ["crates/openhuman-core/src/web_chat/progress_bridge.rs", 1304],// These established external test modules grew with upstream coverage. Pin// their current sizes while follow-up work separates their test concerns.// `core/` was pruned from the line limit by name until these pins; itsdiff --git a/vendor/tinymemes b/vendor/tinymemesindex 4f502a7a42..6390b7b5e7 160000--- a/vendor/tinymemes+++ b/vendor/tinymemes@@ -1 +1 @@-Subproject commit 4f502a7a42af2592f164fe2a343d5becd0681a5a+Subproject commit 6390b7b5e7cbe451510948f36bf400b2c4ab44e4