Skip to content

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

refactor(web_chat): delegate business-limit detection to tinyinference_llm

Steven Enamakel88a8f02db819
diff --git a/crates/openhuman-core/src/web_chat/web_errors/retry.rs b/crates/openhuman-core/src/web_chat/web_errors/retry.rs
index 2a48de864f..1f40685925 100644
--- a/crates/openhuman-core/src/web_chat/web_errors/retry.rs
+++ b/crates/openhuman-core/src/web_chat/web_errors/retry.rs
@@ -71,46 +71,17 @@ pub(crate) fn retry_after_hint(secs: Option<u64>) -> String {
}
}
-/// String-flat mirror of
-/// [`crate::inference::provider::error_classify::is_non_retryable_rate_limit`].
+/// Whether a flattened, already-lowercased 429 message is a business limit
+/// (plan, balance, quota, package) that a retry cannot clear.
///
-/// The reliable provider already classifies 429s into retryable vs
-/// non-retryable based on business-quota markers ("plan does not
-/// include", "insufficient balance", Z.AI codes 1311/1113, …) — but
-/// that typed `anyhow::Error` is collapsed to a `String` at the
-/// native-bus boundary before reaching this layer. We re-detect the
-/// same markers in the flattened string so the FE knows whether to
-/// offer a "Retry" button.
+/// The reliable provider classifies 429s into retryable vs non-retryable from
+/// the typed error, but that `anyhow::Error` is collapsed to a `String` at the
+/// native-bus boundary before reaching this layer. The verdict is the one
+/// `classify_provider_failure` reaches; the marker list and the Z.AI business
+/// codes (1113 / 1311) live in `tinyinference_llm::failure`, not here.
///
/// Caller passes the already-lowercased error string to avoid double
/// allocation.
pub(crate) fn is_non_retryable_rate_limit_text(lower: &str) -> bool {
- const BUSINESS_HINTS: &[&str] = &[
- "plan does not include",
- "doesn't include",
- "not include",
- "insufficient balance",
- "insufficient_balance",
- "insufficient quota",
- "insufficient_quota",
- "quota exhausted",
- "out of credits",
- "no available package",
- "package not active",
- "purchase package",
- "model not available for your plan",
- ];
- if BUSINESS_HINTS.iter().any(|hint| lower.contains(hint)) {
- return true;
- }
- // Known provider business codes observed for 429 where retry is
- // futile (mirrors reliable.rs). Scan integer-like tokens.
- for token in lower.split(|c: char| !c.is_ascii_digit()) {
- if let Ok(code) = token.parse::<u16>() {
- if matches!(code, 1113 | 1311) {
- return true;
- }
- }
- }
- false
+ tinyinference_llm::failure::contains_business_limit(lower)
}
diff --git a/vendor/tinyagents b/vendor/tinyagents
index b58933cf43..a7e3f6f4ab 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit b58933cf4396aaea95ee5385021808b9d2865dda
+Subproject commit a7e3f6f4ab5c43768d2d6c383ae209820e955169