Skip to content

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

fix(inference): recognise legacy host-adapter error envelopes

Steven Enamakel8b8917230a94
diff --git a/crates/openhuman-tinyhumans/src/inference/backend_error_code.rs b/crates/openhuman-tinyhumans/src/inference/backend_error_code.rs
index a553a0a623..06524db929 100644
--- a/crates/openhuman-tinyhumans/src/inference/backend_error_code.rs
+++ b/crates/openhuman-tinyhumans/src/inference/backend_error_code.rs
@@ -106,6 +106,9 @@ pub fn is_managed_backend_envelope(err: &str) -> bool {
let lower = err.to_ascii_lowercase();
lower.starts_with(&format!("{label} api error"))
|| lower.starts_with(&format!("{label} streaming api error"))
+ // Existing diagnostics may still carry the former host-adapter label.
+ || lower.starts_with("openhuman api error")
+ || lower.starts_with("openhuman streaming api error")
}
/// Whether the managed backend explicitly flagged this `BAD_REQUEST` as a
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_model_tests.rs b/crates/openhuman-tinyhumans/src/inference/managed_model_tests.rs
index cf17861301..4924a3d307 100644
--- a/crates/openhuman-tinyhumans/src/inference/managed_model_tests.rs
+++ b/crates/openhuman-tinyhumans/src/inference/managed_model_tests.rs
@@ -49,3 +49,36 @@ fn managed_model_trims_a_configured_model_and_uses_the_product_default_when_blan
Some("openhuman:https://api.example.test/openai/v1:openrouter/deepseek/deepseek-v4-flash")
);
}
+
+#[test]
+fn managed_bearer_keeps_the_stored_key_transport_guard() {
+ let tmp = tempfile::TempDir::new().expect("temporary credentials");
+ openhuman_embed::__host::security::credentials::api_key::store_api_key_in(
+ tmp.path(),
+ false,
+ "test-managed-key",
+ )
+ .expect("store test API key");
+ let options = ManagedOptions {
+ openhuman_dir: Some(tmp.path().to_path_buf()),
+ secrets_encrypt: false,
+ ..ManagedOptions::default()
+ };
+
+ assert_eq!(
+ options
+ .resolve_bearer("https://api.tinyhumans.ai/openai/v1")
+ .expect("managed TLS endpoint accepts the API key"),
+ "test-managed-key"
+ );
+ assert_eq!(
+ options
+ .resolve_bearer("http://127.0.0.1:9999/openai/v1")
+ .expect("loopback is a valid local test endpoint"),
+ "test-managed-key"
+ );
+ let error = options
+ .resolve_bearer("https://api.example.test/openai/v1")
+ .expect_err("a foreign HTTPS origin must not receive the stored key");
+ assert!(error.to_string().contains("unmanaged or insecure"));
+}