Skip to content

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

refactor(inference): delegate provider error classification to tinyinference

Steven Enamakele1e435e71afa
diff --git a/crates/openhuman-core/src/inference/provider/error_classify.rs b/crates/openhuman-core/src/inference/provider/error_classify.rs
index 0ac058ddd1..b767b4e1a5 100644
--- a/crates/openhuman-core/src/inference/provider/error_classify.rs
+++ b/crates/openhuman-core/src/inference/provider/error_classify.rs
@@ -1,28 +1,19 @@
//! OpenHuman-specific policy layered on TinyInference's provider-neutral classifier.
use tinyinference_llm::failure::{
- classify_provider_failure, parse_retry_after_ms as parse_inference_retry_after,
- ProviderFailureClass,
+ classify_provider_failure_with, ProviderFailureClass,
};
fn classify(err: &anyhow::Error) -> ProviderFailureClass {
let message = err.to_string();
- // Product/account-state failures are terminal even when an upstream proxy
- // wrapped them in a nominally retryable status (for example a 500 carrying
- // MONTHLY_REQUEST_COUNT). These rules intentionally stay host-side.
- if tinyinference_llm::failure::is_context_window_exceeded_message(&message)
- || crate::core::observability::is_session_expired_message(&message)
- || tinyinference_llm::failure::body_indicates_quota_exhausted(&message)
- {
- return ProviderFailureClass::NonRetryable;
- }
-
let status = err
.downcast_ref::<reqwest::Error>()
.and_then(reqwest::Error::status)
.map(|status| status.as_u16());
- classify_provider_failure(status, None, &message)
+ 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 {
@@ -37,5 +28,6 @@ pub(crate) fn is_upstream_unhealthy(err: &anyhow::Error) -> bool {
}
pub(crate) fn parse_retry_after_ms(err: &anyhow::Error) -> Option<u64> {
- parse_inference_retry_after(&err.to_string())
+ let message = err.to_string();
+ tinyinference_core::retry_after::parse_retry_after_ms(Some(&message))
}
diff --git a/crates/openhuman-core/src/inference/provider/mod.rs b/crates/openhuman-core/src/inference/provider/mod.rs
index f5b3b9aa91..4e28d99432 100644
--- a/crates/openhuman-core/src/inference/provider/mod.rs
+++ b/crates/openhuman-core/src/inference/provider/mod.rs
@@ -5,7 +5,6 @@
//! inference concerns (local runtime, cloud providers, HTTP endpoint) share
//! a single domain root.
-pub mod error_classify;
pub mod factory;
pub(crate) mod fallback_diagnostics;
pub mod http_error;