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(host_runtime): remove unused emoji reaction module
Steven Enamakel9b556217284a
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops.rsindex 3005d426e9..fd3ddd9593 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops.rs@@ -10,13 +10,11 @@ mod tests;mod agent_chat;mod chat;-mod reactions;mod runtime_ops;mod turn_guards;pub use agent_chat::{agent_chat, agent_chat_for, agent_chat_simple, AgentChatTarget};pub use chat::{local_ai_chat, LocalAiChatMessage};-pub use reactions::{local_ai_should_react, ReactionDecision};pub use runtime_ops::{local_ai_assets_status, local_ai_download_asset, local_ai_downloads_progress, local_ai_embed,local_ai_prompt, local_ai_status, local_ai_summarize, local_ai_transcribe,@@ -26,8 +24,6 @@ pub use runtime_ops::{#[cfg(test)]use crate::config::Config;#[cfg(test)]-use reactions::{extract_first_emoji, is_emoji_start};-#[cfg(test)]use turn_guards::{effective_agent_chat_origin, grant_turn_cwd, normalize_model_override, resolve_turn_cwd,};diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/reactions.rs b/crates/openhuman-core/src/inference/host_runtime/ops/reactions.rsdeleted file mode 100644index cd353bd54f..0000000000--- a/crates/openhuman-core/src/inference/host_runtime/ops/reactions.rs+++ /dev/null@@ -1,190 +0,0 @@-//! The emoji reaction decision: asking the local model whether to react and-//! extracting the emoji it picked.--use crate::config::Config;-use crate::core::Outcome;-use crate::inference::host_runtime as local_ai;--/// Result of the reaction-decision prompt.-#[derive(Debug, serde::Serialize)]-pub struct ReactionDecision {- /// Whether the model thinks a reaction is appropriate.- pub should_react: bool,- /// The emoji to use (only meaningful when `should_react` is true).- pub emoji: Option<String>,-}--/// Evaluates whether the assistant should add an emoji reaction to a user message.-///-/// This uses the local model to make a quick decision based on the message-/// content and the channel context.-pub async fn local_ai_should_react(- config: &Config,- message: &str,- channel_type: &str,-) -> Result<Outcome<ReactionDecision>, String> {- tracing::debug!(- channel_type,- msg_len = message.len(),- "[local_ai:should_react] evaluating reaction"- );-- if message.trim().is_empty() {- return Ok(Outcome::single_log(- ReactionDecision {- should_react: false,- emoji: None,- },- "empty message — no reaction",- ));- }-- let service = local_ai::global(config);- let status = service.status();- if !matches!(status.state.as_str(), "ready") {- tracing::debug!("[local_ai:should_react] local model not ready, skipping");- return Ok(Outcome::single_log(- ReactionDecision {- should_react: false,- emoji: None,- },- "local model not ready",- ));- }-- let prompt = format!(- "You decide whether an AI assistant should react to a user message with a single emoji. \- Consider the channel context: casual channels (discord, telegram) get more frequent \- reactions with playful emojis, while professional channels (web, slack, email) are more \- reserved — only react to clearly emotional or noteworthy messages.\n\n\- Channel: {channel_type}\nUser message: {message}\n\n\- Reply with EXACTLY one word: either NONE (no reaction) or a single emoji character."- );-- let runtime = crate::inference::local_runtime_config(config);- let Some(_permit) = crate::cron::scheduler_gate::wait_for_capacity().await else {- return Ok(Outcome::single_log(- ReactionDecision {- should_react: false,- emoji: None,- },- "local inference paused while signed out",- ));- };- let output = service.prompt(&runtime, &prompt, Some(8), true).await;-- let decision = match output {- Ok(raw) => {- let trimmed = raw.trim();- tracing::debug!(- output_len = trimmed.len(),- "[local_ai:should_react] model response"- );- if trimmed.eq_ignore_ascii_case("NONE") || trimmed.is_empty() {- ReactionDecision {- should_react: false,- emoji: None,- }- } else {- // Extract the first emoji-like character(s) from the response- let emoji = extract_first_emoji(trimmed);- match emoji {- Some(e) => ReactionDecision {- should_react: true,- emoji: Some(e),- },- None => ReactionDecision {- should_react: false,- emoji: None,- },- }- }- }- Err(e) => {- tracing::debug!(error = %e, "[local_ai:should_react] inference failed, skipping");- ReactionDecision {- should_react: false,- emoji: None,- }- }- };-- tracing::debug!(- should_react = decision.should_react,- emoji = ?decision.emoji,- "[local_ai:should_react] decision"- );- Ok(Outcome::single_log(decision, "reaction decision completed"))-}--/// Extract the first emoji from a string. Handles common emoji codepoints-/// including flag sequences (pairs of regional indicator symbols).-pub(super) fn extract_first_emoji(text: &str) -> Option<String> {- let mut chars = text.chars();- while let Some(ch) = chars.next() {- // Regional indicator pair → flag emoji (e.g. 🇺🇸 = U+1F1FA U+1F1F8)- if is_regional_indicator(ch) {- let mut emoji = String::new();- emoji.push(ch);- // Consume consecutive regional indicators (flags are pairs)- for next in chars.by_ref() {- if is_regional_indicator(next) {- emoji.push(next);- } else {- break;- }- }- return Some(emoji);- }-- if is_emoji_start(ch) {- let mut emoji = String::new();- emoji.push(ch);- // Consume joiners and variation selectors that extend the emoji- for next in chars.by_ref() {- if next == '\u{FE0F}' // variation selector- || next == '\u{200D}' // zero-width joiner- || ('\u{1F3FB}'..='\u{1F3FF}').contains(&next) // skin tones- || is_emoji_start(next) && emoji.contains('\u{200D}')- {- emoji.push(next);- } else {- break;- }- }- return Some(emoji);- }- }- None-}--pub(super) fn is_regional_indicator(ch: char) -> bool {- ('\u{1F1E6}'..='\u{1F1FF}').contains(&ch)-}--pub(super) fn is_emoji_start(ch: char) -> bool {- matches!(ch,- '\u{203C}' | '\u{2049}' // exclamation marks- | '\u{2139}' // information- | '\u{2194}'..='\u{2199}' // arrows- | '\u{21A9}'..='\u{21AA}' // arrows- | '\u{231A}'..='\u{231B}' // watch, hourglass- | '\u{23E9}'..='\u{23F3}' // media controls- | '\u{23F8}'..='\u{23FA}' // media controls- | '\u{24C2}' // circled M- | '\u{25AA}'..='\u{25AB}' // squares- | '\u{25B6}' | '\u{25C0}' // play buttons- | '\u{25FB}'..='\u{25FE}' // squares- | '\u{2328}' | '\u{23CF}' // keyboard, eject- | '\u{2600}'..='\u{27BF}' // misc symbols, dingbats- | '\u{2934}'..='\u{2935}' // arrows- | '\u{2B05}'..='\u{2B07}' // arrows- | '\u{2B1B}'..='\u{2B1C}' // squares- | '\u{2B50}' | '\u{2B55}' // star, circle- | '\u{FE00}'..='\u{FE0F}' // variation selectors- | '\u{1F300}'..='\u{1F9FF}' // misc symbols, emoticons, transport, supplemental- | '\u{1FA00}'..='\u{1FA6F}' // chess symbols, extended-A- | '\u{1FA70}'..='\u{1FAFF}' // symbols extended-A- | '\u{200D}' // ZWJ- )-}