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
fix(api): correct error type for budget and quota failures
Steven Enamakel9133cb86ca76
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/scout_run.rs b/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/scout_run.rsindex 1d779882cb..d7739e1880 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/scout_run.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/scout_run.rs@@ -166,14 +166,14 @@ pub(super) fn scout_failure_signal(err: &SubagentRunError) -> String {/// Two billing shapes reach here, both **user-state, not defects**:/// * the managed OpenHuman backend's budget-exhausted 400/// (`{"error":"Insufficient budget","errorCode":"USER_INSUFFICIENT_CREDITS"}`),-/// matched by [`crate::hosted::billing::classify::is_budget_exhausted_message`];+/// matched by [`crate::api::classify::is_budget_exhausted_message`];/// * a BYO provider's insufficient-credits 402, matched by/// [`crate::core::observability::is_insufficient_credits_message`].////// Both delegate to the crate's single-source classifiers so the phrase sets/// can't drift from the cron halt / `before_send` nets that share them.pub(super) fn is_expected_billing_failure(message: &str) -> bool {- crate::hosted::billing::classify::is_budget_exhausted_message(message)+ crate::api::classify::is_budget_exhausted_message(message)|| crate::core::observability::is_insufficient_credits_message(message)}diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/loop_guards.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/loop_guards.rsindex a1a7d8b6c0..501a50a0f5 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/loop_guards.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/loop_guards.rs@@ -113,7 +113,7 @@ fn has_inference_failure_envelope(result: &str) -> bool {/// the two tight provider classifiers. Budget takes precedence if both match./// Ported from legacy `tool_loop::terminal_inference_failure_kind` (#3104).pub(crate) fn terminal_inference_failure_kind(result: &str) -> Option<TerminalInferenceFailure> {- use crate::hosted::billing::classify::is_budget_exhausted_message;+ use crate::api::classify::is_budget_exhausted_message;use tinyinference_providers::is_provider_config_rejection_message;if !has_inference_failure_envelope(result) {return None;diff --git a/crates/openhuman-core/src/api/classify.rs b/crates/openhuman-core/src/api/classify.rsindex 098cf9d79b..5654cb5590 100644--- a/crates/openhuman-core/src/api/classify.rs+++ b/crates/openhuman-core/src/api/classify.rs@@ -1,4 +1,9 @@-//! OpenHuman billing-state classification used by UI and telemetry policy.+//! Backend / provider error-body classification shared across domains.+//!+//! Budget exhaustion is reported by the hosted backend and by managed inference+//! providers as a deterministic user state, not a defect; every domain that+//! sees such a body (inference HTTP errors, agent loop guards, the scheduler,+//! web chat, telemetry) classifies it through this one predicate./// Return whether a provider message represents deterministic exhausted-budget/// user state rather than a product defect.diff --git a/crates/openhuman-core/src/api/rest.rs b/crates/openhuman-core/src/api/rest.rsindex 5231150b09..27ae7eb01b 100644--- a/crates/openhuman-core/src/api/rest.rs+++ b/crates/openhuman-core/src/api/rest.rs@@ -821,7 +821,7 @@ impl BackendOAuthClient {let is_transient_infra =crate::core::observability::is_transient_http_status_code(status_code);let is_budget_exhausted = status_code == 400- && crate::hosted::billing::classify::is_budget_exhausted_message(&text);+ && crate::api::classify::is_budget_exhausted_message(&text);if is_budget_exhausted {tracing::info!(method = method.as_str(),diff --git a/crates/openhuman-core/src/core/observability.rs b/crates/openhuman-core/src/core/observability.rsindex 824a6b21fe..7a63eb5d67 100644--- a/crates/openhuman-core/src/core/observability.rs+++ b/crates/openhuman-core/src/core/observability.rs@@ -648,7 +648,7 @@ pub fn expected_error_kind(message: &str) -> Option<ExpectedErrorKind> {if is_local_ai_capability_unavailable_message(&lower) {return Some(ExpectedErrorKind::LocalAiCapabilityUnavailable);}- if crate::hosted::billing::classify::is_budget_exhausted_message(message) {+ if crate::api::classify::is_budget_exhausted_message(message) {return Some(ExpectedErrorKind::BudgetExhausted);}if is_prompt_injection_blocked_message(&lower) {@@ -3426,7 +3426,7 @@ fn event_contains_budget_exhausted_message(event: &sentry::protocol::Event<'_>)if event.message.as_deref()- .is_some_and(crate::hosted::billing::classify::is_budget_exhausted_message)+ .is_some_and(crate::api::classify::is_budget_exhausted_message){return true;}@@ -3435,7 +3435,7 @@ fn event_contains_budget_exhausted_message(event: &sentry::protocol::Event<'_>)exception.value.as_deref()- .is_some_and(crate::hosted::billing::classify::is_budget_exhausted_message)+ .is_some_and(crate::api::classify::is_budget_exhausted_message)})}diff --git a/crates/openhuman-core/src/cron/scheduler/failure_classification.rs b/crates/openhuman-core/src/cron/scheduler/failure_classification.rsindex d5f7b7f690..ef13daf6c8 100644--- a/crates/openhuman-core/src/cron/scheduler/failure_classification.rs+++ b/crates/openhuman-core/src/cron/scheduler/failure_classification.rs@@ -193,7 +193,7 @@ pub(super) fn is_budget_exhausted_failure(return false;}let signal = last_agent_error.unwrap_or(last_output);- crate::hosted::billing::classify::is_budget_exhausted_message(signal)+ crate::api::classify::is_budget_exhausted_message(signal)}/// TAURI-RUST-HCK — a cron **agent** job pinned to a provider with nodiff --git a/crates/openhuman-core/src/hosted/billing/mod.rs b/crates/openhuman-core/src/hosted/billing/mod.rsindex 9dcc71acb3..b058a8a6f7 100644--- a/crates/openhuman-core/src/hosted/billing/mod.rs+++ b/crates/openhuman-core/src/hosted/billing/mod.rs@@ -3,7 +3,6 @@//! Exposes plan lookup, purchase flows, and credit top-ups through the//! standard controller registry (`openhuman.billing_*`).-pub mod classify;mod ops;mod schemas;diff --git a/crates/openhuman-core/src/inference/provider/ops/http_error/quota_and_credits.rs b/crates/openhuman-core/src/inference/provider/ops/http_error/quota_and_credits.rsindex d317ec7592..23e64658b4 100644--- a/crates/openhuman-core/src/inference/provider/ops/http_error/quota_and_credits.rs+++ b/crates/openhuman-core/src/inference/provider/ops/http_error/quota_and_credits.rs@@ -5,7 +5,7 @@/// user-state error that should be demoted from Sentry to an info log.pub fn is_budget_exhausted_http_400(status: reqwest::StatusCode, body: &str) -> bool {status == reqwest::StatusCode::BAD_REQUEST- && crate::hosted::billing::classify::is_budget_exhausted_message(body)+ && crate::api::classify::is_budget_exhausted_message(body)}pub fn log_budget_exhausted_http_400(diff --git a/crates/openhuman-core/src/web_chat/web_errors/budget.rs b/crates/openhuman-core/src/web_chat/web_errors/budget.rsindex 91b22bd95f..cbaa6aa9eb 100644--- a/crates/openhuman-core/src/web_chat/web_errors/budget.rs+++ b/crates/openhuman-core/src/web_chat/web_errors/budget.rs@@ -34,7 +34,7 @@ pub(crate) fn is_inference_budget_exceeded_error(message: &str) -> bool {// (issue #3088). Without this, an Ollama user with zero credits and// routing still on Managed sees an opaque "provider error" and has no// way to self-diagnose that they must top up or switch routing.- crate::hosted::billing::classify::is_budget_exhausted_message(message)+ crate::api::classify::is_budget_exhausted_message(message)}pub(crate) fn inference_budget_exceeded_user_message() -> &'static str {