Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(host_runtime): handle missing reaction in ops dispatch

Steven Enamakel36945f10bf2b
diff --git a/crates/openhuman-core/src/cron/scheduler/failure_classification.rs b/crates/openhuman-core/src/cron/scheduler/failure_classification.rs
index dcd40563a4..9edde682b3 100644
--- a/crates/openhuman-core/src/cron/scheduler/failure_classification.rs
+++ b/crates/openhuman-core/src/cron/scheduler/failure_classification.rs
@@ -255,7 +255,7 @@ pub(super) fn is_local_provider_unreachable_failure(
pub(super) fn is_local_provider_no_model_loaded_message(signal: &str) -> bool {
let lower = signal.to_ascii_lowercase();
(lower.contains("local inference server") && lower.contains("no model loaded"))
- || lower.contains("no models loaded")
+ || tinyinference_llm::failure::body_indicates_no_model_loaded(signal)
}
/// Static, leak-safe actionable alert copy for a permanent cron halt state.
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops.rs
index 3005d426e9..a3e4dd73b5 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops.rs
@@ -26,7 +26,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.rs
index cd353bd54f..a4e79c213a 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/reactions.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/reactions.rs
@@ -87,7 +87,7 @@ pub async fn local_ai_should_react(
}
} else {
// Extract the first emoji-like character(s) from the response
- let emoji = extract_first_emoji(trimmed);
+ let emoji = tinyinference_llm::classification::extract_first_emoji(trimmed);
match emoji {
Some(e) => ReactionDecision {
should_react: true,
@@ -116,75 +116,3 @@ pub async fn local_ai_should_react(
);
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
- )
-}
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
index a558024a42..2318931d1f 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
@@ -1,47 +1,5 @@
use super::*;
-#[test]
-fn extract_emoji_from_simple_string() {
- assert_eq!(extract_first_emoji("👍"), Some("👍".to_string()));
- assert_eq!(extract_first_emoji("🔥"), Some("🔥".to_string()));
- assert_eq!(extract_first_emoji("❤️"), Some("❤️".to_string()));
-}
-
-#[test]
-fn extract_emoji_with_surrounding_text() {
- assert_eq!(extract_first_emoji("Sure! 😂"), Some("😂".to_string()));
- assert_eq!(
- extract_first_emoji("I think 👀 fits here"),
- Some("👀".to_string())
- );
-}
-
-#[test]
-fn extract_none_when_no_emoji() {
- assert_eq!(extract_first_emoji("NONE"), None);
- assert_eq!(extract_first_emoji("no reaction"), None);
- assert_eq!(extract_first_emoji(""), None);
-}
-
-#[test]
-fn extract_flag_emoji_keeps_pair_together() {
- assert_eq!(extract_first_emoji("🇺🇸"), Some("🇺🇸".to_string()));
- assert_eq!(
- extract_first_emoji("🇬🇧 Great Britain"),
- Some("🇬🇧".to_string())
- );
-}
-
-#[test]
-fn is_emoji_start_recognizes_common_emojis() {
- assert!(is_emoji_start('👍'));
- assert!(is_emoji_start('🔥'));
- assert!(is_emoji_start('😂'));
- assert!(is_emoji_start('⭐'));
- assert!(!is_emoji_start('A'));
- assert!(!is_emoji_start('1'));
-}
-
// ── Op-level validation / error paths (no hardware) ───────────
fn test_config(tmp: &tempfile::TempDir) -> Config {