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(tinyagents): delegate run failure classification to the harness
Steven Enamakel763b39066dbd
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs b/crates/openhuman-core/src/agent/tinyagents/turn_models.rsindex 8a6e9ab5e2..753caf416d 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_models.rs@@ -10,21 +10,6 @@ use tinyagents_harness::host::{ModelResolveRequest, ModelResolver};use tinyinference_llm::model::{ErrorSlotModel, ProfileOverrideModel};use tinyinference_llm::model::{ResolvedModelRoute, RouteRecordingModel};-pub(crate) fn tinyagents_depth_error(- err: &tinyagents_harness::TinyAgentsError,-) -> Option<crate::agent::subagent_host::SubagentRunError> {- match err {- tinyagents_harness::TinyAgentsError::SubAgentDepth(max_depth)- | tinyagents_harness::TinyAgentsError::RecursionLimit(max_depth) => Some(- crate::agent::subagent_host::SubagentRunError::SpawnDepthExceeded {- attempted_depth: max_depth.saturating_add(1),- max_depth: *max_depth,- },- ),- _ => None,- }-}-/// The per-turn crate [`ChatModel`](tinyinference_llm::model::ChatModel) set,/// built once from an openhuman [`Provider`] by [`build_turn_models`] — the/// single place a turn's `native model adapters are constructed (issue #4249, Phase 5).diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_error.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_error.rsindex cb4dddc18f..0293038c61 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_error.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_error.rs@@ -2,7 +2,7 @@//! caller expects, for [`run_turn_via_tinyagents_shared`](super::run_turn_via_tinyagents_shared).use crate::agent::tinyagents::journal::TurnJournal;-use crate::agent::tinyagents::turn_models::tinyagents_depth_error;+use tinyagents_harness::turn_run_error::{classify_run_failure, RunFailureKind};use tinyinference_llm::model::ModelErrorSlot;/// Map the harness's run failure `e` onto the typed error the turn caller@@ -31,13 +31,10 @@ pub(super) async fn map_turn_run_error(if let Some(journal) = turn_journal {journal.finish_failed(&e.to_string()).await;}- // The model-call cap (when not pausing gracefully — the channel/CLI- // path) maps to the typed `AgentError::MaxIterationsExceeded` so- // callers downcast it (Sentry skip) and render the canonical- // "Agent exceeded maximum tool iterations" message, matching the- // legacy `ErrorCheckpoint`.- if let tinyagents_harness::TinyAgentsError::LimitExceeded(msg) = &e {- if msg.contains("model call") {+ // The harness owns the ordering-sensitive classification; the host only+ // maps each kind onto its typed error.+ match classify_run_failure(&e) {+ RunFailureKind::ModelCallCap => {tracing::debug!(model,"[tinyagents] run hit the model-call cap; mapping to MaxIterationsExceeded (not consulting error_slot) — #4457 defect B"@@ -46,24 +43,24 @@ pub(super) async fn map_turn_run_error(max: max_iterations,});}- }- if let Some(depth_err) = tinyagents_depth_error(&e) {- return anyhow::Error::new(depth_err);- }- // A timeout or cancellation is the run's own failure, not a provider's: a- // provider error left in the slot by an earlier attempt must not be- // re-surfaced as its cause (#6724).- if matches!(- e,- tinyagents_harness::TinyAgentsError::Timeout(_)- | tinyagents_harness::TinyAgentsError::CallTimeout(_)- | tinyagents_harness::TinyAgentsError::Cancelled- ) {- error_slot- .lock()- .unwrap_or_else(std::sync::PoisonError::into_inner)- .take();- return anyhow::anyhow!("tinyagents harness run failed: {e}");+ RunFailureKind::DepthLimit { max_depth } => {+ return anyhow::Error::new(+ crate::agent::subagent_host::SubagentRunError::SpawnDepthExceeded {+ attempted_depth: max_depth.saturating_add(1),+ max_depth,+ },+ );+ }+ // A timeout or cancellation is the run's own failure, not a+ // provider's: a stale provider error must not be its cause (#6724).+ RunFailureKind::TimeoutOrCancelled => {+ error_slot+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner)+ .take();+ return anyhow::anyhow!("tinyagents harness run failed: {e}");+ }+ RunFailureKind::Other => {}}// Otherwise prefer the original typed provider error (preserves// `AgentError` downcasts the caller relies on) over the harness'sdiff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_error_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_error_tests.rsindex e24aeb4553..3bc9d5da09 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_error_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_error_tests.rs@@ -21,3 +21,28 @@ async fn a_timeout_is_not_reported_as_a_provider_error_left_in_the_slot() {);}}++#[tokio::test]+async fn the_model_call_cap_and_depth_limit_win_over_a_stale_provider_error() {+ let stale = || -> ModelErrorSlot {+ std::sync::Arc::new(std::sync::Mutex::new(Some(tinyinference_llm::Error::Model(+ "OpenHuman returned HTTP 503: upstream unavailable".to_string(),+ ))))+ };+ let cap = tinyagents_harness::TinyAgentsError::LimitExceeded("model call cap".to_string());+ let mapped = map_turn_run_error(cap, "m", 7, &stale(), None).await;+ assert!(matches!(+ mapped.downcast_ref::<crate::agent::error::AgentError>(),+ Some(crate::agent::error::AgentError::MaxIterationsExceeded { max: 7 })+ ));++ let depth = tinyagents_harness::TinyAgentsError::SubAgentDepth(3);+ let mapped = map_turn_run_error(depth, "m", 7, &stale(), None).await;+ assert!(matches!(+ mapped.downcast_ref::<crate::agent::subagent_host::SubagentRunError>(),+ Some(crate::agent::subagent_host::SubagentRunError::SpawnDepthExceeded {+ attempted_depth: 4,+ max_depth: 3+ })+ ));+}