Skip to content

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

chore: files changed crates/openhuman-tinyhumans/src/hosted/client.rs,crates/openhuman-tinyhumans/sr

Steven Enamakelfe002ed7a7c3
diff --git a/crates/openhuman-tinyhumans/src/hosted/client.rs b/crates/openhuman-tinyhumans/src/hosted/client.rs
index b8d92caf44..3789936a0e 100644
--- a/crates/openhuman-tinyhumans/src/hosted/client.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/client.rs
@@ -30,7 +30,9 @@
//! phrases, budget exhaustion) keep matching them.
use crate::backend::url::effective_backend_api_url;
-use openhuman_core::backend::transport::{resolve_backend_transport, TransportProfile};
+use openhuman_core::backend::transport::{
+ resolve_backend_transport, BackendTransport, BackendTransportError, TransportProfile,
+};
use openhuman_core::config::Config;
use openhuman_core::core::observability::{
contains_transient_transport_phrase, is_transient_http_status_code, API_KEY_REJECTED_PREFIX,
@@ -40,6 +42,7 @@ use openhuman_core::security::credentials::session_support::{
resolve_backend_credential, BackendCredential,
};
use serde_json::Value;
+use std::sync::Arc;
use tinyhumans_sdk::{Error as SdkError, TinyHumansClient};
const LOG_PREFIX: &str = "[hosted][client]";
@@ -67,10 +70,7 @@ impl HostedClient {
let credential = resolve_backend_credential(config).inspect_err(|err| {
log::debug!("{LOG_PREFIX} no usable backend credential; skipping request: {err}");
})?;
- resolve_backend_transport().map_err(|_| {
- log::debug!("{LOG_PREFIX} no backend transport installed; skipping request");
- format!("{BACKEND_UNAVAILABLE_PREFIX} no backend transport installed")
- })?;
+ require_transport(resolve_backend_transport())?;
let base_url = backend_origin(&effective_backend_api_url(&config.api_url))?;
Ok(Self::with_credential(&base_url, credential))
}
@@ -121,6 +121,16 @@ impl HostedClient {
}
}
+/// Reject hosted calls when the runtime has no backend transport.
+fn require_transport(
+ result: Result<Arc<dyn BackendTransport>, BackendTransportError>,
+) -> Result<(), String> {
+ result.map(|_| ()).map_err(|_| {
+ log::debug!("{LOG_PREFIX} no backend transport installed; skipping request");
+ format!("{BACKEND_UNAVAILABLE_PREFIX} no backend transport installed")
+ })
+}
+
/// The backend origin with any path, query and fragment stripped — the same
/// normalisation `BackendClient::new` applies, so a completions-style
/// `api_url` (`https://host/v1/chat/completions`) still reaches `/teams/...`.
diff --git a/crates/openhuman-tinyhumans/src/hosted/client_tests.rs b/crates/openhuman-tinyhumans/src/hosted/client_tests.rs
index d53ebb2776..82d99ecdbc 100644
--- a/crates/openhuman-tinyhumans/src/hosted/client_tests.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/client_tests.rs
@@ -150,13 +150,8 @@ fn missing_credential_fails_before_any_request() {
}
#[test]
-fn stored_session_cannot_bypass_missing_backend_transport() {
- let tmp = TempDir::new().unwrap();
- let config = test_config(&tmp, "http://127.0.0.1:9");
- store_session(&config, "jwt.a.b");
- let err = HostedClient::from_config(&config)
- .err()
- .expect("transport required");
+fn missing_backend_transport_has_unavailable_sentinel() {
+ let err = require_transport(Err(BackendTransportError::Unavailable)).unwrap_err();
assert!(err.starts_with("BACKEND_UNAVAILABLE:"), "{err}");
}