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
chore: files changed crates/openhuman-core/src/agent/message_convert.rs,crates/openhuman-core/src/ag
Steven Enamakel1cad8c7e3be7
diff --git a/crates/openhuman-core/src/agent/message_convert.rs b/crates/openhuman-core/src/agent/message_convert.rsindex 7ce2379fb7..d3e64f4a2b 100644--- a/crates/openhuman-core/src/agent/message_convert.rs+++ b/crates/openhuman-core/src/agent/message_convert.rs@@ -19,8 +19,7 @@ use tinyinference_llm::message::{};use tinyinference_llm::tool::ToolCall as TaToolCall;use tinytools_agent::dialect::{- DialectMessage, DialectResponse, DialectRole, ToolDialect, ToolResultEntry,- TranscriptEntry,+ DialectMessage, DialectResponse, DialectRole, ToolDialect, ToolResultEntry, TranscriptEntry,};use crate::agent::messages::{ChatMessage, ConversationMessage, ToolResultMessage};diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rsindex 0588f37e93..43e8b18884 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs@@ -335,6 +335,15 @@ pub(super) fn recovery_policy({("transient", 2)}+ // A local command killed by the shell's own timeout is still uncertain+ // (it may have partly run), but it is inspectable: the model can check+ // the filesystem or re-run a smaller, bounded step. Halting the whole+ // turn on the first one threw away every earlier result for what is+ // usually a slow read (a `whois`/`dig` loop). It gets one recovery+ // attempt, steered by a reconcile-first nudge, and halts on a second.+ // Remote actions (`gmail_send`, payments, …) stay at zero: a retry+ // there can repeat an effect the agent cannot observe.+ Class::Timeout if tool == "shell" => ("uncertain_side_effect", 1),Class::Timeout => ("uncertain_side_effect", 0),Class::Unknown if is_recoverable_tool_failure(error) => ("transient", 2),Class::Unknown@@ -476,12 +485,20 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>self.tracker.reset();return Ok(());}- if matches!(class, "missing_window" | "missing_app" | "validation") {- let instruction = if class == "validation" {- "The last call failed validation. Correct its schema or arguments once before trying again."- } else {- "The desktop target was not found. Rediscover the current app and window once before trying again."+ if matches!(+ class,+ "missing_window" | "missing_app" | "validation" | "uncertain_side_effect"+ ) {+ let instruction = match class {+ "validation" => "The last call failed validation. Correct its schema or arguments once before trying again.",+ "uncertain_side_effect" => "The last command timed out and was killed; it may have partly run. Check its effect before repeating anything, then retry at most once as a smaller, bounded step (fewer items per call, a per-item timeout such as `timeout 5`, or background it and poll).",+ _ => "The desktop target was not found. Rediscover the current app and window once before trying again.",};+ tracing::debug!(+ tool = tool_name,+ class,+ "[tinyagents::mw] classified failure within budget — nudging recovery"+ );self.queue_nudge(instruction);}// The classified budget owns this known blocker. In particular,diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_tests.rsindex acaaa213db..4242679362 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_classified_failure_tests.rs@@ -142,6 +142,76 @@ fn uncertain_timeout_requires_reconciliation() {super::super::repeated_failure::recovery_policy("web_fetch", "timed out", false),Some(("transient", 2)));+ // A killed local command is inspectable, so it gets one recovery attempt.+ assert_eq!(+ super::super::repeated_failure::recovery_policy(+ "shell",+ "Command timed out after 60s and was killed",+ false+ ),+ Some(("uncertain_side_effect", 1))+ );+}++/// Regression: one `whois` loop hitting the 60s shell timeout halted the whole+/// turn, discarding every earlier result. The first timeout must steer the+/// model to reconcile and narrow the command; only a second one halts.+#[tokio::test]+async fn shell_timeout_nudges_once_then_halts_on_second() {+ let handle = SteeringHandle::allow_all();+ let slot = std::sync::Arc::new(std::sync::Mutex::new(None));+ let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());+ let run = |id: &'static str, command: &'static str| {+ let mw = &mw;+ async move {+ let mut call = TaToolCall::new(id, "shell", serde_json::json!({ "command": command }));+ mw.before_tool(&mut ctx(), &(), &mut call).await.unwrap();+ let mut result = failing_result("shell", "Command timed out after 60s and was killed");+ mw.after_tool(&mut ctx(), &(), &invocation(id, "shell"), &mut result)+ .await+ .unwrap();+ }+ };++ run("sh-1", "for d in a.io b.io c.io; do whois $d; done").await;+ assert_eq!(drain_pause_count(&handle), 0, "first timeout must not halt");+ assert!(slot.lock().unwrap().is_none());+ let nudges = mw.take_pending_nudges();+ assert_eq!(nudges.len(), 1, "{nudges:?}");+ assert!(nudges[0].contains("timed out"), "{nudges:?}");+ assert!(nudges[0].contains("smaller, bounded"), "{nudges:?}");++ run("sh-2", "whois a.io").await;+ assert_eq!(drain_pause_count(&handle), 1, "second timeout halts");+ let summary = slot.lock().unwrap().clone().unwrap();+ assert!(summary.contains("uncertain_side_effect"), "{summary}");+ assert!(+ summary.contains("reconcile its external state"),+ "{summary}"+ );+}++/// A shell success in between clears the ledger, so a later, unrelated timeout+/// gets its own recovery attempt instead of halting.+#[tokio::test]+async fn shell_success_resets_the_timeout_budget() {+ let handle = SteeringHandle::allow_all();+ let slot = std::sync::Arc::new(std::sync::Mutex::new(None));+ let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());+ for (id, ok) in [("t-1", false), ("t-ok", true), ("t-2", false)] {+ let mut call = TaToolCall::new(id, "shell", serde_json::json!({ "command": id }));+ mw.before_tool(&mut ctx(), &(), &mut call).await.unwrap();+ let mut result = if ok {+ tool_result("shell", "done")+ } else {+ failing_result("shell", "Command timed out after 60s and was killed")+ };+ mw.after_tool(&mut ctx(), &(), &invocation(id, "shell"), &mut result)+ .await+ .unwrap();+ }+ assert_eq!(drain_pause_count(&handle), 0);+ assert!(slot.lock().unwrap().is_none());}#[test]