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
refactor(observability): simplify error kind determination logic
Steven Enamakelb7b52048c281
diff --git a/crates/openhuman-core/src/core/observability.rs b/crates/openhuman-core/src/core/observability.rsindex 4eafaa359f..fc964803d1 100644--- a/crates/openhuman-core/src/core/observability.rs+++ b/crates/openhuman-core/src/core/observability.rs@@ -369,16 +369,7 @@ pub enum ExpectedErrorKind {pub fn expected_error_kind(message: &str) -> Option<ExpectedErrorKind> {let lower = message.to_ascii_lowercase();- // F2/F4: a managed-backend `errorCode` (#870) means the backend owns this- // error — it already paged its own 5xx, or the code is expected user-state.- // Trust it FIRST, before the substring matchers, so a managed 500- // `INTERNAL_ERROR` (which no substring matcher below would otherwise demote)- // stops double-reporting. The one exception — a backend-flagged malformed- // `BAD_REQUEST` — is excluded by `managed_error_skips_sentry` and falls- // through to the matchers / capture so the FE still pages (F8). The- // decision is gated on the managed-backend envelope so a BYO payload- // carrying an `errorCode`-shaped field is not wrongly suppressed- // (CodeRabbit).+ // Explicit host ownership/reportability metadata precedes text heuristics.let backend_error = crate::inference::registry::classify_backend_error(None, message);if backend_error.as_ref()@@ -386,16 +377,7 @@ pub fn expected_error_kind(message: &str) -> Option<ExpectedErrorKind> {{return Some(ExpectedErrorKind::BackendErrorCodeOwned);}- // A managed-backend client-guard-leak code (`PAYLOAD_TOO_LARGE` /- // `CONTEXT_LENGTH_EXCEEDED`) must PAGE — the client enforces these limits- // before sending, so a backend rejection is our guard leaking. Force- // capture (return `None`) here, BEFORE the substring matchers below: a real- // managed `CONTEXT_LENGTH_EXCEEDED` body carries "context length- // exceeded"-style text that `is_context_window_exceeded_message` (further- // down) would otherwise re-demote into the suppressed- // `ContextWindowExceeded` bucket (CodeRabbit). Gated on the managed envelope- // so a BYO provider's own context-overflow — genuine user-state, not our- // guard — still flows to that matcher and stays demoted.+ // Explicitly reportable guard failures must bypass broader text demotions.if backend_error.as_ref().is_some_and(|classification| {classification.provider_owned&& classification.reportable@@ -2313,11 +2295,8 @@ fn report_expected_message(kind: ExpectedErrorKind, message: &str, domain: &str,);}ExpectedErrorKind::BackendErrorCodeOwned => {- // Managed-backend `errorCode` (#870) re-report — the backend owns- // this error (already paged its own 5xx, or expected user-state).- // The FE surfaces actionable copy via `classify_inference_error`;- // Sentry must not double-report (F2/F4). Demote at `warn!` so the- // breadcrumb retains the code for triage without spawning an event.+ // The classifier's canonical token aids triage without re-parsing+ // provider-specific strings in this generic module.let code = crate::inference::registry::classify_backend_error(None, message).as_ref().and_then(|classification| classification.token.as_deref())diff --git a/crates/openhuman-core/src/core/observability_tests.rs b/crates/openhuman-core/src/core/observability_tests.rsindex dd90ab6486..e5c667166b 100644--- a/crates/openhuman-core/src/core/observability_tests.rs+++ b/crates/openhuman-core/src/core/observability_tests.rs@@ -60,9 +60,7 @@ fn managed_body(status: &str, code: &str) -> String {fn register_backend_classifier_fixture(message: &str, classification: BackendErrorClassification) {static FIXTURES: OnceLock<Arc<Mutex<HashMap<String, BackendErrorClassification>>>> =OnceLock::new();- let fixtures = Arc::clone(FIXTURES.get_or_init(|| {- Arc::new(Mutex::new(HashMap::new()))- }));+ let fixtures = Arc::clone(FIXTURES.get_or_init(|| Arc::new(Mutex::new(HashMap::new()))));let classifier_fixtures = Arc::clone(&fixtures);register_backend_error_classifier(Arc::new(move |_provider, error| {classifier_fixturesdiff --git a/crates/openhuman-tinyhumans/src/inference/backend_error_code_tests.rs b/crates/openhuman-tinyhumans/src/inference/backend_error_code_tests.rsindex 3a08f4ca4f..2166e7f362 100644--- a/crates/openhuman-tinyhumans/src/inference/backend_error_code_tests.rs+++ b/crates/openhuman-tinyhumans/src/inference/backend_error_code_tests.rs@@ -164,18 +164,15 @@ fn hosted_classifier_drives_core_observability_without_core_token_ownership() {let malformed =r#"OpenHuman API error (400): {"error":{"errorCode":"BAD_REQUEST","malformed":true}}"#;- assert_ne!(- expected_error_kind(malformed),- Some(ExpectedErrorKind::BackendErrorCodeOwned)- );+ assert_eq!(expected_error_kind(malformed), None);for code in ["PAYLOAD_TOO_LARGE", "CONTEXT_LENGTH_EXCEEDED"] {let guard_leak = format!("OpenHuman API error (413): {{\"error\":{{\"errorCode\":\"{code}\",\"message\":\"x\"}}}}");- assert_ne!(+ assert_eq!(expected_error_kind(&guard_leak),- Some(ExpectedErrorKind::BackendErrorCodeOwned),+ None,"{code} must remain reportable as a client guard leak");}