Skip to content

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

test(inference): add hosted classifier observability tests

Steven Enamakelf5d437c086e6
diff --git a/crates/openhuman-tinyhumans/src/inference/backend_error_code_tests.rs b/crates/openhuman-tinyhumans/src/inference/backend_error_code_tests.rs
index ad8c65b340..081a1135a0 100644
--- a/crates/openhuman-tinyhumans/src/inference/backend_error_code_tests.rs
+++ b/crates/openhuman-tinyhumans/src/inference/backend_error_code_tests.rs
@@ -134,6 +134,52 @@ fn managed_envelope_gate_rejects_byo_payload_carrying_error_code() {
assert!(managed_error_skips_sentry(managed_stream));
}
+#[test]
+fn hosted_classifier_drives_core_observability_without_core_token_ownership() {
+ use openhuman_embed::__host::inference_registry::register_backend_error_classifier;
+ use openhuman_embed::__host::observability::{expected_error_kind, ExpectedErrorKind};
+ use std::sync::Arc;
+
+ register_backend_error_classifier(Arc::new(super::classify));
+
+ let owned =
+ r#"OpenHuman API error (429): {"error":{"errorCode":"RATE_LIMITED","message":"x"}}"#;
+ assert_eq!(
+ expected_error_kind(owned),
+ Some(ExpectedErrorKind::BackendErrorCodeOwned)
+ );
+
+ let unknown =
+ r#"OpenHuman API error (500): {"error":{"errorCode":"FUTURE_CODE","message":"x"}}"#;
+ assert_eq!(
+ expected_error_kind(unknown),
+ Some(ExpectedErrorKind::BackendErrorCodeOwned)
+ );
+
+ let byo = r#"custom_openai API error (429): {"error":{"errorCode":"RATE_LIMITED"}}"#;
+ assert_ne!(
+ expected_error_kind(byo),
+ Some(ExpectedErrorKind::BackendErrorCodeOwned)
+ );
+
+ let malformed = r#"OpenHuman API error (400): {"error":{"errorCode":"BAD_REQUEST","malformed":true}}"#;
+ assert_ne!(
+ expected_error_kind(malformed),
+ Some(ExpectedErrorKind::BackendErrorCodeOwned)
+ );
+
+ for code in ["PAYLOAD_TOO_LARGE", "CONTEXT_LENGTH_EXCEEDED"] {
+ let guard_leak = format!(
+ "OpenHuman API error (413): {{\"error\":{{\"errorCode\":\"{code}\",\"message\":\"x\"}}}}"
+ );
+ assert_ne!(
+ expected_error_kind(&guard_leak),
+ Some(ExpectedErrorKind::BackendErrorCodeOwned),
+ "{code} must remain reportable as a client guard leak"
+ );
+ }
+}
+
#[test]
fn classification_keeps_provider_ownership_separate_from_raw_token_and_reportability() {
let unknown = classify(