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(chat): avoid billing claim for empty model responses
Steven Enamakela2210aa07e86
diff --git a/crates/openhuman-core/src/cron/scheduler/failure_classification.rs b/crates/openhuman-core/src/cron/scheduler/failure_classification.rsindex 6d7bb5d9b0..277c23dedb 100644--- a/crates/openhuman-core/src/cron/scheduler/failure_classification.rs+++ b/crates/openhuman-core/src/cron/scheduler/failure_classification.rs@@ -50,16 +50,9 @@ pub(super) fn agent_error_to_user_message(err: &AgentError) -> &'static str {"Too many tool iterations. Raise the iteration cap in Connections \u{2192} API keys \u{2192} LLM or simplify the task."}AgentError::EmptyProviderResponse { .. } => {- // Issue #3335: the prior copy named a "local provider"- // remedy that doesn't exist on the Managed route. This- // shorter form (≤120 chars per the- // `agent_error_to_user_message_canned_strings_are_short`- // contract, for clean notification-drawer rendering) names- // the two highest-signal remedies — credits and model- // configuration. The richer three-remedy copy lives on the- // chat-surface side (`web_chat/web_errors.rs`'s- // empty_response arm) where there's no drawer-width limit.- "Empty model response. Out of credits (Settings \u{2192} Billing) or try another model in Connections \u{2192} API keys \u{2192} LLM."+ // Empty content alone cannot establish a billing problem. Keep+ // the notification short and point to a retry or model change.+ "Empty model response. Retry the job or try another model in Connections \u{2192} API keys \u{2192} LLM."}AgentError::CompactionFailed { .. } => {"Automatic history compaction failed. The next run will start with a fresh context."diff --git a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rsindex 097ed24972..69550f35a0 100644--- a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs@@ -136,16 +136,13 @@ fn agent_error_to_user_message_classifies_max_iterations() {}#[test]-fn agent_error_to_user_message_classifies_empty_provider_response_for_3335() {- // Issue #3335: the cron-path copy must stay in lock-step with the- // web-channel `empty_response` arm — names the credits / billing- // remedy explicitly and drops the misleading "local provider"- // misdirect that broke remediation for Managed users.+fn agent_error_to_user_message_does_not_infer_credits_from_empty_response() {+ // An empty completion does not establish that billing rejected the call.let err = AgentError::EmptyProviderResponse { iteration: 1 };let msg = agent_error_to_user_message(&err);assert!(- msg.contains("Settings \u{2192} Billing"),- "must point at billing for credit exhaustion: {msg}"+ !msg.to_ascii_lowercase().contains("credit") && !msg.contains("Billing"),+ "must not infer credit exhaustion from an empty completion: {msg}");assert!(!msg.contains("local provider"),@@ -237,12 +234,7 @@ fn agent_error_to_user_message_canned_strings_are_short() {required_level: "x".into(),channel_max_level: "x".into(),},- // Issue #3335: EmptyProviderResponse was historically absent from- // this variants list — its old copy happened to fit, but nothing- // enforced it. The fix shipped a new copy that explicitly names- // the credits / billing remedy, which makes the length tradeoff- // active rather than incidental. Lock it in so a future copy- // change can't quietly grow past the drawer-render budget.+ // Keep empty-response notifications within the drawer width.AgentError::EmptyProviderResponse { iteration: 0 },];for v in &variants {diff --git a/crates/openhuman-core/src/web_chat/web_errors/classify.rs b/crates/openhuman-core/src/web_chat/web_errors/classify.rsindex 8e6b67dbd3..e546053598 100644--- a/crates/openhuman-core/src/web_chat/web_errors/classify.rs+++ b/crates/openhuman-core/src/web_chat/web_errors/classify.rs@@ -229,29 +229,15 @@ pub(crate) fn classify_inference_error(err: &str) -> ClassifiedError {// No `with_provider_detail` — an empty response carries no JSON body// to quote.//- // Issue #3335: the prior copy ("Try a different model or check your- // local provider in Connections → API keys → LLM") sent Managed users in- // exactly the wrong direction — there is no local provider on the- // Managed route, and the common underlying cause is credit- // exhaustion (see #3386). The provider name is not available here- // because `EmptyProviderResponse`'s flattened Display carries no- // `" API error"` infix for `extract_provider_name` to anchor on,- // and routing the typed provider through every layer is out of- // scope for this fix. So the copy is rewritten to be accurate for- // ALL providers: it names the three real remedies (credits, model- // health, configuration) without claiming any single one of them- // applies, and lets the user pick which is relevant to their- // setup. The companion empty-2xx-stream diagnostic in- // `compatible.rs::stream_native_chat` records elapsed_ms,- // chunk_count, and has_usage so the next iteration of this arm- // can be provider-aware once we have evidence on which path is- // dominant in production.+ // An empty successful completion is not a billing verdict. In+ // particular, reasoning-only replies can spend output tokens but+ // produce no visible answer. Reserve credit guidance for explicit+ // backend/provider errors; this path has neither an error code nor+ // a response body establishing the user's balance.ClassifiedError {error_type: "empty_response",- message: "The model returned an empty response. This usually means your inference \- credits are exhausted (Settings → Billing), the upstream model is temporarily \- unhealthy, or your provider configuration is rejecting the request \- (Connections → API keys → LLM). Try one of those, or pick a different model."+ message: "The model returned an empty response. Please retry. If it keeps happening, \+ try a different model or check its setup in Connections → API keys → LLM.".to_string(),source: "agent_loop",retryable: true,diff --git a/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rsindex b088290615..b8f3da460f 100644--- a/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs+++ b/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs@@ -1,29 +1,19 @@use super::*;#[test]-fn classify_inference_error_empty_response_copy_names_billing_remedy_and_drops_local_provider_misdirect(-) {- // Issue #3335: the prior copy ("Try a different model or check your- // local provider in Connections → API keys → LLM") sent Managed-route users- // toward a remedy that does not exist for them. The common underlying- // cause is credit exhaustion (issue #3386), so the revised copy must- // name the credits / billing path explicitly, must NOT claim a "local- // provider" exists, and must still offer the model-switch path for- // users on self-hosted providers.+fn classify_inference_error_empty_response_does_not_claim_credit_exhaustion() {+ // An empty successful completion provides no evidence about the user's+ // balance. A real credit error has its own backend errorCode classification.let raw = "run_chat_task failed client_id=abc thread_id=t-1 request_id=r-1 \error=The model returned an empty response. Please try again.";let classified = classify_inference_error(raw);assert_eq!(classified.error_type, "empty_response");- // New: names the credits / billing remedy (was absent in the old copy,- // so Managed users had no way to self-diagnose credit exhaustion).assert!(- classified.message.contains("Settings → Billing"),- "must point at the billing surface for credit exhaustion: {}",+ !classified.message.to_ascii_lowercase().contains("credit")+ && !classified.message.contains("Billing"),+ "must not infer credit exhaustion from an empty completion: {}",classified.message);- // New: drops the misleading "local provider" framing — the previous- // copy made a false claim for Managed users where no local provider- // exists.assert!(!classified.message.contains("local provider"),"must not claim a local provider exists: {}",