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-core/src/agent/progress_tracing/langfuse/span_export.rs,crates

Steven Enamakel95b80fb95342
diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse/span_export.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse/span_export.rs
index a0c8f4e279..26437fe780 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse/span_export.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse/span_export.rs
@@ -277,17 +277,17 @@ pub(crate) async fn push_spans(config: &Config, spans: &[TraceSpan]) -> Result<(
// `ingestion_url` resolves to the backend's own Langfuse proxy route on the
// backend host, authenticated with a TinyHumans session token — backend
- // traffic, so it carries the product identity. This is a bare
- // `reqwest::Client`, not `BackendClient`'s, so nothing is inherited
- // from that path's default headers; see [`crate::api::product`].
- let (product_header, product_value) = crate::api::product::product_identity_header();
- let response = reqwest::Client::new()
+ // traffic, so it rides the transport's client, which carries the host's
+ // attribution headers (product identity, versions).
+ let client = crate::backend::resolve_backend_transport()
+ .map_err(|err| format!("Langfuse push has no backend transport: {err}"))?
+ .http_client(crate::backend::TransportProfile::Api);
+ let response = client
.post(&url)
.header(
reqwest::header::AUTHORIZATION,
bearer_authorization_value(&token),
)
- .header(product_header, product_value)
.timeout(PUSH_TIMEOUT)
.json(&batch)
.send()
diff --git a/crates/openhuman-core/src/agent/progress_tracing/otlp.rs b/crates/openhuman-core/src/agent/progress_tracing/otlp.rs
index 49c90b613c..b1147d9272 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/otlp.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/otlp.rs
@@ -466,8 +466,11 @@ pub(super) async fn push_spans(config: &Config, spans: &[TraceSpan]) -> Result<(
return Ok(());
};
let token = credential.into_secret();
- let (product_header, product_value) = crate::api::product::product_identity_header();
- let client = reqwest::Client::new();
+ // Backend traffic: the transport's client carries the host's attribution
+ // headers (product identity, versions).
+ let client = crate::backend::resolve_backend_transport()
+ .map_err(|err| format!("Langfuse OTLP push has no backend transport: {err}"))?
+ .http_client(crate::backend::TransportProfile::Api);
for payload in otlp_requests(spans, environment) {
let response = client
.post(&url)
@@ -475,7 +478,6 @@ pub(super) async fn push_spans(config: &Config, spans: &[TraceSpan]) -> Result<(
reqwest::header::AUTHORIZATION,
bearer_authorization_value(&token),
)
- .header(product_header.clone(), product_value.clone())
.timeout(std::time::Duration::from_secs(10))
.json(&payload)
.send()
diff --git a/crates/openhuman-core/src/inference/embedding_host/cloud_adapter.rs b/crates/openhuman-core/src/inference/embedding_host/cloud_adapter.rs
index 933b90b560..4c7e9d9c1c 100644
--- a/crates/openhuman-core/src/inference/embedding_host/cloud_adapter.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/cloud_adapter.rs
@@ -8,7 +8,6 @@ use tinyinference_embeddings::{
DEFAULT_CLOUD_DIMENSIONS, DEFAULT_CLOUD_MODEL,
};
-use crate::api::config::effective_api_url;
use crate::security::credentials::{AuthService, APP_SESSION_PROVIDER};
pub const DEFAULT_CLOUD_EMBEDDING_MODEL: &str = DEFAULT_CLOUD_MODEL;
@@ -28,7 +27,18 @@ impl OpenHumanCloudEmbeddingModel {
dimensions: usize,
) -> Self {
let state_dir = openhuman_dir.unwrap_or_else(default_state_dir);
+ // The managed endpoint comes from the installed backend transport.
+ // Without one there is nothing to embed against, so the bearer
+ // resolver (asked before every request) refuses up front.
+ let base = crate::backend::inference_base_url(&api_url).ok();
+ let backend_available = base.is_some();
let bearer: BearerResolver = Arc::new(move || {
+ if !backend_available {
+ return Err(tinyinference_embeddings::Error::Validation(format!(
+ "{} managed embeddings need a backend transport",
+ crate::core::observability::BACKEND_UNAVAILABLE_PREFIX
+ )));
+ }
let auth = AuthService::new(&state_dir, secrets_encrypt);
auth.get_provider_bearer_token(APP_SESSION_PROVIDER, None)
.map_err(|error| tinyinference_embeddings::Error::Embedding(error.to_string()))?
@@ -41,7 +51,7 @@ impl OpenHumanCloudEmbeddingModel {
});
let base_url = format!(
"{}/openai/v1",
- effective_api_url(&api_url).trim_end_matches('/')
+ base.unwrap_or_default().trim_end_matches('/')
);
let guard: EmbeddingEgressGuard = Arc::new(|model, _input_count| {
let egress = crate::security::egress::EgressDescriptor::embedding("cloud", model);
diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
index 8af2195a4f..453dd82865 100644
--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
@@ -36,7 +36,6 @@ use tinyinference_llm::providers::openai::OpenAiModel;
use tinyinference_llm::Error as TiError;
use super::ProviderRuntimeOptions;
-use crate::api::config::effective_api_url;
use crate::security::credentials::{AuthService, APP_SESSION_PROVIDER};
pub const PROVIDER_LABEL: &str = "OpenHuman";
@@ -164,11 +163,11 @@ impl OpenHumanBackendModel {
)? {
// Refuse to send the key over a plaintext channel it could leak
// from. Scoped to this managed-key path only — `base_url()`
- // comes from `effective_api_url`, which a library host can point
+ // comes from the backend transport, which a library host can point
// at anything (a BYOK/local endpoint legitimately runs over
// plain HTTP on loopback), so this cannot tighten
// `normalize_api_base_url` itself without breaking those.
- let endpoint = self.base_url();
+ let endpoint = self.base_url()?;
if !is_safe_endpoint_for_managed_bearer(&endpoint) {
anyhow::bail!(
"refusing to send the TinyHumans API key as a bearer over a non-HTTPS, \
@@ -217,11 +216,16 @@ impl OpenHumanBackendModel {
}
}
- fn base_url(&self) -> String {
- format!(
- "{}/openai/v1",
- effective_api_url(&self.api_url).trim_end_matches('/')
- )
+ /// The managed OpenAI-compatible endpoint, from the installed backend
+ /// transport. Without one there is no managed backend to reach.
+ fn base_url(&self) -> anyhow::Result<String> {
+ let base = crate::backend::inference_base_url(&self.api_url).map_err(|_| {
+ anyhow::anyhow!(
+ "{} managed inference needs a backend transport",
+ crate::core::observability::BACKEND_UNAVAILABLE_PREFIX
+ )
+ })?;
+ Ok(format!("{}/openai/v1", base.trim_end_matches('/')))
}
/// Resolve the current JWT + base URL and build a fresh crate `OpenAiModel`
@@ -230,7 +234,7 @@ impl OpenHumanBackendModel {
let token = self
.resolve_bearer()
.map_err(|e| TiError::Model(e.to_string()))?;
- let base_url = self.base_url();
+ let base_url = self.base_url().map_err(|e| TiError::Model(e.to_string()))?;
// The hosted API is chat-completions only (no `/v1/responses`); auth is a
// plain bearer JWT. The tier/model rides `request.model`, which the backend
// resolves — the baked default only applies when a request omits it.
@@ -558,11 +562,9 @@ impl ChatModel<()> for OpenHumanBackendModel {
/// backend resolves the tier per account anyway, so two accounts sharing
/// a cache would need their own namespace, not a credential in the key.
fn cache_identity(&self) -> Option<String> {
- Some(format!(
- "openhuman:{}:{}",
- self.base_url(),
- self.default_model
- ))
+ self.base_url()
+ .ok()
+ .map(|base| format!("openhuman:{base}:{}", self.default_model))
}
async fn invoke(