Skip to content

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

fix(triage): classify provider failures inline in arm evaluator

Steven Enamakel8d37e47fd1c7
diff --git a/crates/openhuman-core/src/inference/provider/error_classify.rs b/crates/openhuman-core/src/inference/provider/error_classify.rs
deleted file mode 100644
index b767b4e1a5..0000000000
--- a/crates/openhuman-core/src/inference/provider/error_classify.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-//! OpenHuman-specific policy layered on TinyInference's provider-neutral classifier.
-
-use tinyinference_llm::failure::{
- classify_provider_failure_with, ProviderFailureClass,
-};
-
-fn classify(err: &anyhow::Error) -> ProviderFailureClass {
- let message = err.to_string();
-
- let status = err
- .downcast_ref::<reqwest::Error>()
- .and_then(reqwest::Error::status)
- .map(|status| status.as_u16());
- classify_provider_failure_with(status, None, &message, |value| {
- crate::core::observability::is_session_expired_message(value)
- })
-}
-
-pub(crate) fn is_rate_limited(err: &anyhow::Error) -> bool {
- matches!(
- classify(err),
- ProviderFailureClass::RateLimited | ProviderFailureClass::NonRetryableRateLimit
- )
-}
-
-pub(crate) fn is_upstream_unhealthy(err: &anyhow::Error) -> bool {
- classify(err) == ProviderFailureClass::UpstreamUnhealthy
-}
-
-pub(crate) fn parse_retry_after_ms(err: &anyhow::Error) -> Option<u64> {
- let message = err.to_string();
- tinyinference_core::retry_after::parse_retry_after_ms(Some(&message))
-}
diff --git a/crates/openhuman-core/src/triage/evaluator/arm.rs b/crates/openhuman-core/src/triage/evaluator/arm.rs
index b492de51ca..db9d0c1982 100644
--- a/crates/openhuman-core/src/triage/evaluator/arm.rs
+++ b/crates/openhuman-core/src/triage/evaluator/arm.rs
@@ -11,7 +11,6 @@ use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, AGENT_RUN_TURN_METH
use crate::agent_registry::host_definition::AgentDefinitionRegistry;
use crate::config::MultimodalConfig;
use crate::core::bus::BUS;
-use crate::inference::provider::error_classify::parse_retry_after_ms;
use tinyagents_harness::retry::{decide, FailoverDecision, FailoverReason, FailoverState};
use tinyagents_session::transcript::TranscriptMessage;
use tinybus::NativeRequestError;
@@ -245,18 +244,46 @@ pub(crate) fn classify_error(message: String) -> ArmError {
if is_prompt_guard_rejection(&message) {
return ArmError::SafetyFlagged(err);
}
- let reason = FailoverReason::classify_unstructured(&message);
- match decide(
+ let failure = tinyinference_llm::failure::classify_provider_failure_with(
+ None,
+ None,
+ &message,
+ crate::core::observability::is_session_expired_message,
+ );
+ let reason = match failure {
+ tinyinference_llm::failure::ProviderFailureClass::RateLimited
+ | tinyinference_llm::failure::ProviderFailureClass::NonRetryableRateLimit => {
+ FailoverReason::RateLimit
+ }
+ tinyinference_llm::failure::ProviderFailureClass::UpstreamUnhealthy => {
+ FailoverReason::UpstreamUnavailable
+ }
+ tinyinference_llm::failure::ProviderFailureClass::Retryable => {
+ FailoverReason::Unknown
+ }
+ tinyinference_llm::failure::ProviderFailureClass::NonRetryable => FailoverReason::Unknown,
+ };
+ let decision = decide(
reason,
FailoverState {
- retryable: reason != FailoverReason::Unknown,
+ retryable: failure.is_retryable(),
attempts_remaining: true,
larger_window_available: false,
},
- ) {
+ );
+ match decision {
FailoverDecision::RetrySame => ArmError::Retryable {
retry_after_ms: (reason == FailoverReason::RateLimit)
- .then(|| parse_retry_after_ms(&err))
+ .then(|| {
+ message.lines().find_map(|line| {
+ line.trim()
+ .strip_prefix("Retry-After:")
+ .or_else(|| line.trim().strip_prefix("retry-after:"))
+ .and_then(|value| {
+ tinyinference_core::retry_after::parse_retry_after_ms(Some(value))
+ })
+ })
+ })
.flatten(),
source: err,
},