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(middleware): extract heuristic text logic into shared function
Steven Enamakel4748ecf3208a
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/fetched_site.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/fetched_site.rsindex d54ddd1b3b..ff1f1aed91 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/fetched_site.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/fetched_site.rs@@ -67,3 +67,16 @@ pub(super) fn fetch_host_scope(tool: &str, field: &str, value: &str) -> Option<Slet url = url::Url::parse(value).ok()?;Some(format!(":host={}", url.host_str()?))}++/// The text the keyword heuristics may read for a failed `tool` result. For an+/// ordinary fetched-site status (404, 410, ...) the response body is untrusted+/// excerpt text, so only the status line is read; it must not turn a site+/// failure into a terminal inference or transient tool failure. Everything else+/// is read whole.+pub(super) fn heuristic_text<'a>(tool: &str, failure_text: &'a str) -> &'a str {+ if fetched_site_policy(tool, failure_text) == Some(None) {+ failure_text.lines().next().unwrap_or(failure_text)+ } else {+ failure_text+ }+}diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rsindex 7aa42913a2..353a834b4a 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs@@ -19,7 +19,7 @@ use tinyinference_llm::model::ModelRequest;use tinyinference_llm::tool::ToolCall as TaToolCall;use tinytools::ToolResult as TaToolResult;-use super::fetched_site::{fetch_host_scope, fetched_site_policy};+use super::fetched_site::{fetch_host_scope, fetched_site_policy, heuristic_text};use super::loop_guards::{is_repeat_call_exempt, RECOVERABLE_NO_PROGRESS_FAILURE_THRESHOLD,RECOVERABLE_REPEAT_FAILURE_THRESHOLD,@@ -311,7 +311,6 @@ fn classified_recovery_policy({return Some(("unavailable", 1));}- // A site's refusal is not our credential failure (see `fetched_site`).if let Some(policy) = fetched_site_policy(tool, error) {return policy;}@@ -476,16 +475,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>false if body_level_failure => content.clone(),false => String::new(),};- // For an ordinary fetched-site status (404, 410, etc.), the response- // body is untrusted excerpt text. It must not turn the site failure- // into a terminal inference or transient tool failure. Keep the full- // text below for the exact-repeat tracker and its user-facing summary.- let heuristic_failure_text = if fetched_site_policy(tool_name, &failure_text) == Some(None)- {- failure_text.lines().next().unwrap_or(&failure_text)- } else {- &failure_text- };+ let heuristic_failure_text = heuristic_text(tool_name, &failure_text);if !result.is_error && !body_level_failure {// Only a successful observation against this operation and scopediff --git a/crates/openhuman-core/src/sandbox/grants_tests.rs b/crates/openhuman-core/src/sandbox/grants_tests.rsindex 3207348187..e490e6c464 100644--- a/crates/openhuman-core/src/sandbox/grants_tests.rs+++ b/crates/openhuman-core/src/sandbox/grants_tests.rs@@ -90,12 +90,18 @@ fn toolchain_homes_are_granted_when_they_exist() {let g = resolve_local_jail_grants(Some(home.path()), &LocalJailConfig::default());let h = canon(home.path());let cargo = h.join(".cargo");- assert!(!has(&g.read_write, &cargo), "Cargo home must never be writable");+ assert!(+ !has(&g.read_write, &cargo),+ "Cargo home must never be writable"+ );assert!(has(&g.read_only, &cargo.join("bin")));assert!(has(&g.read_write, &cargo.join("registry")));assert!(has(&g.read_write, &cargo.join("git")));for file in ["config.toml", "config", "env"] {- assert!(has(&g.read_only, &cargo.join(file)), "{file} should be read-only");+ assert!(+ has(&g.read_only, &cargo.join(file)),+ "{file} should be read-only"+ );}for ro in [".rustup", ".nvm", ".npm"] {assert!(has(&g.read_only, &h.join(ro)), "{ro} should be read-only");