Skip to content

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

Merge remote-tracking branch 'origin/main' into epic-8092-ci-clean

Steven Enamakel0f30e6b91298
diff --cc crates/openhuman-core/src/config/schema/ephemeral_route.rs
index f9e35d9cd2,c26848ed82..21962090a0
--- a/crates/openhuman-core/src/config/schema/ephemeral_route.rs
+++ b/crates/openhuman-core/src/config/schema/ephemeral_route.rs
@@@ -35,13 -35,6 +35,13 @@@ use serde::{Deserialize, Serialize}
use super::cloud_providers::{AuthStyle, CloudProviderCreds};
- /// Select only the URL origin for route diagnostics, then use TinyInference's
- /// canonical sanitizer for credentials and malformed URL handling.
++/// Select only the endpoint origin for diagnostics, then apply TinyInference's
++/// canonical URL sanitizer so paths, credentials, and query values stay out of logs.
+fn redacted_endpoint_origin_for_log(endpoint: &str) -> String {
+ let origin = url::Url::parse(endpoint.trim()).map(|url| url.origin().ascii_serialization());
+ tinyinference_core::sanitize::redact_url(origin.as_deref().unwrap_or(endpoint))
+}
+
/// The `cloud_providers` slug [`apply`] registers the route under.
///
/// Hyphenated and prefixed so it cannot collide with a provider slug a user
@@@ -136,6 -153,32 +160,32 @@@ pub fn apply(config: &mut crate::config
return;
};
+ let provider_string = format!("{EPHEMERAL_ROUTE_SLUG}:{model}");
+ if let Some(effort) = route.reasoning_effort.as_deref() {
+ config
+ .runtime
+ .reasoning_effort_by_model
+ .insert(model.clone(), effort.to_string());
+ }
+ let route_is_unchanged = config.ephemeral_route.as_ref() == Some(&route);
+ let roles_match = [
+ config.chat_provider.as_deref(),
+ config.reasoning_provider.as_deref(),
+ config.agentic_provider.as_deref(),
+ config.coding_provider.as_deref(),
+ ]
+ .into_iter()
+ .all(|provider| provider == Some(provider_string.as_str()));
+
+ if route_is_unchanged && roles_match {
+ tracing::debug!(
+ "[config][ephemeral-route] route already applied to {} model={}",
- crate::inference::provider::factory::redact_endpoint(&route.endpoint),
++ redacted_endpoint_origin_for_log(&route.endpoint),
+ model
+ );
+ return;
+ }
+
// Replace rather than append: a second call on the same `Config` copy is not
// expected, but two entries sharing a slug would make which one resolves an
// ordering accident.
@@@ -160,11 -202,19 +209,19 @@@
config.agentic_provider = Some(provider_string.clone());
config.coding_provider = Some(provider_string);
- log::info!(
- "[config][ephemeral-route] this call routed to {} model={}",
- redacted_endpoint_origin_for_log(&route.endpoint),
- model
- );
+ if route_is_unchanged {
+ tracing::debug!(
+ "[config][ephemeral-route] this call routed to {} model={}",
- crate::inference::provider::factory::redact_endpoint(&route.endpoint),
++ redacted_endpoint_origin_for_log(&route.endpoint),
+ model
+ );
+ } else {
+ tracing::info!(
+ "[config][ephemeral-route] this call routed to {} model={}",
- crate::inference::provider::factory::redact_endpoint(&route.endpoint),
++ redacted_endpoint_origin_for_log(&route.endpoint),
+ model
+ );
+ }
config.ephemeral_route = Some(route);
}
diff --cc crates/openhuman-core/src/config/schema/ephemeral_route_tests.rs
index 9902935f1d,9866693bb3..2ebeb3b88e
--- a/crates/openhuman-core/src/config/schema/ephemeral_route_tests.rs
+++ b/crates/openhuman-core/src/config/schema/ephemeral_route_tests.rs
@@@ -185,9 -351,10 +351,10 @@@ fn the_route_cannot_be_serialized_into_
#[test]
fn debug_never_discloses_route_bearer_or_header_values() {
let route = EphemeralRoute {
- endpoint: "https://fixture.example/v1".into(),
+ endpoint: "https://route-user:[email protected]/route-path-secret/v1?key=route-query-secret#route-fragment-secret".into(),
api_key: "u2-unique-route-secret".into(),
headers: vec![("x-private".into(), "u2-unique-header-secret".into())],
+ ..EphemeralRoute::default()
};
let debug = format!("{route:?}");
assert!(!debug.contains("u2-unique-route-secret"));
diff --cc crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
index 81bd7c2ec9,93cb953260..e29d4a46e0
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
@@@ -16,19 -7,7 +16,17 @@@ use crate::inference::provider::factory
#[cfg(not(test))]
use crate::inference::provider::factory::access_gates::verify_session_active;
use crate::inference::provider::fallback_diagnostics;
+use crate::inference::provider::openai_codex::resolve_openai_codex_routing_for_inspection;
+use crate::security::egress::EgressLedger;
+use std::sync::Arc;
+use tinyinference_llm::model::ChatModel;
use tinyinference_llm::providers::anthropic::endpoint_is_anthropic_messages;
+use tinyinference_llm::providers::openai::codex::{
+ openai_codex_client_version, openai_codex_user_agent, OPENAI_CODEX_ACCOUNT_HEADER,
+ OPENAI_CODEX_ORIGINATOR, OPENAI_CODEX_ORIGINATOR_HEADER,
+};
- use tinyinference_llm::providers::registry::{
- resolve_slug_model, ProviderBuildOptions, ProviderRegistry,
- };
++use tinyinference_llm::providers::registry::resolve_slug_model;
+use tinyinference_providers::route::split_model_and_temperature;
type CloudSlugInspectionChatModelResult = Option<
anyhow::Result<(
@@@ -639,45 -564,36 +645,36 @@@ fn try_create_cloud_slug_chat_model_fro
.cloud_provider_ca_certs
.get(&slug)
.filter(|pem| !pem.is_empty())
- .map(String::as_str);
- let service_key = if anthropic_native {
- "provider.anthropic"
- } else {
- "provider.compatible"
+ {
+ Some(pem) => {
- let label = if anthropic_native {
++ let service_key = if anthropic_native {
+ "provider.anthropic"
+ } else {
+ "provider.compatible"
+ };
- match crate::util::tls::client_with_ca_bundle(pem, label) {
++ match crate::util::tls::client_with_ca_bundle(pem, service_key) {
+ Ok(http) => Some(http),
+ Err(error) => return Some(Err(anyhow::anyhow!(error))),
+ }
+ }
+ None => None,
};
- let http_builder = ca_bundle.map(|_| {
- std::sync::Arc::new(move || {
- crate::config::apply_runtime_proxy_to_builder(
- crate::util::tls::tls_client_builder(),
- service_key,
- )
- }) as tinyinference_llm::providers::registry::ProviderHttpClientBuilder<'_>
+ let auth_style = cloud_spec::registry_auth_style(entry.auth_style)
+ .expect("managed JWT entries returned above");
+ let chat = cloud_spec::build_cloud_model(cloud_spec::CloudBuild {
+ spec: cloud_spec::cloud_provider_spec(entry, &effective_model),
+ auth_style,
+ key: key.as_str(),
+ temperature_override,
+ temperature_unsupported_models: config.temperature_unsupported_models.as_slice(),
+ native_tool_calling,
+ default_provider_options,
+ extra_headers: extra_headers.as_slice(),
+ extra_query_params: extra_query_params.as_slice(),
+ user_agent: user_agent.as_deref(),
+ codex: codex_route,
+ http,
});
- let spec = cloud_spec::cloud_provider_spec(entry, &effective_model);
- log::debug!(
- "[providers][cloud-spec] build slug={} kind={} auth={:?}",
- spec.provider,
- spec.kind.as_str(),
- entry.auth_style
- );
- let chat = ProviderRegistry::new(cloud_spec::CloudCredentialResolver(&key))
- .build_with(
- &spec,
- ProviderBuildOptions {
- auth_style: Some(entry.auth_style.into()),
- temperature_override,
- temperature_unsupported_models: config.temperature_unsupported_models.as_slice(),
- native_tool_calling: Some(native_tool_calling),
- extra_headers: extra_headers.as_slice(),
- extra_query_params: extra_query_params.as_slice(),
- user_agent: user_agent.as_deref(),
- codex: codex_route,
- http_builder,
- ca_bundle,
- ..ProviderBuildOptions::default()
- },
- )
- .map_err(|error| anyhow::anyhow!("[chat-factory] {error}"));
if let Some(identity) = inspection_identity {
let credential = if entry.auth_style == AuthStyle::None {
String::new()
diff --cc crates/openhuman-core/src/inference/provider/factory/cloud_spec.rs
index 1390815031,f263f564ee..15af5e2e6d
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_spec.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_spec.rs
@@@ -1,14 -1,25 +1,26 @@@
- //! Host-resolved cloud provider inputs for TinyInference's provider registry.
+ //! `CloudProviderCreds` → `ProviderSpec` → `ProviderRegistry` mapping.
+ //!
+ //! The host owns saved configuration, routing and access gates; this module
+ //! hands the resolved route to `tinyinference-llm`'s [`ProviderRegistry`],
+ //! which owns adapter construction (Chat Completions, Anthropic Messages,
+ //! Codex Responses, OpenRouter routing options) and listing discovery. Only
+ //! host policy is expressed here: which auth style a slug uses, which extra
+ //! headers the ephemeral route and Codex OAuth add, and the TLS client for a
+ //! provider with a custom CA bundle.
use super::*;
- use tinyinference_llm::providers::registry::CredentialResolver;
+ use tinyinference_llm::providers::openai::codex::OpenAiCodexRouting;
++use tinyinference_llm::providers::openai::AuthStyle as CompatAuthStyle;
+ use tinyinference_llm::providers::registry::{ProviderBuildOptions, ProviderRegistry};
use tinyinference_llm::{ProviderKind, ProviderSpec};
use crate::config::schema::cloud_providers::CloudProviderCreds;
/// Maps a configured cloud entry and its effective model onto the registry's
- /// spec without resolving credentials or changing the configured endpoint.
+ /// spec. Credentials are resolved by the host beforehand, so no env var is
+ /// named and a key is not required at the spec level (a blank key is a host
+ /// decision, made in `resolve_cloud_slug`).
-pub(super) fn cloud_provider_spec(entry: &CloudProviderCreds, model: &str) -> ProviderSpec {
+pub(crate) fn cloud_provider_spec(entry: &CloudProviderCreds, model: &str) -> ProviderSpec {
ProviderSpec {
kind: match entry.auth_style {
AuthStyle::Anthropic => ProviderKind::Anthropic,
@@@ -22,29 -33,94 +34,117 @@@
}
}
- /// The bearer selected by OpenHuman's auth-profile and OAuth policy.
- ///
- /// Resolve the host credential before creating a registry so errors and OAuth
- /// token rotation retain the existing host semantics; the registry callback
- /// then returns that exact selected credential for its provider spec.
++/// Credential resolver retained for host call sites that need the registry
++/// directly. The host resolves policy and auth before handing the key here.
+pub(crate) struct CloudCredentialResolver<'a>(pub(crate) &'a str);
+
- impl CredentialResolver for CloudCredentialResolver<'_> {
++impl tinyinference_llm::providers::registry::CredentialResolver for CloudCredentialResolver<'_> {
+ fn resolve(&self, _spec: &ProviderSpec) -> tinyinference_llm::Result<String> {
+ Ok(self.0.to_owned())
+ }
+}
+
- impl From<AuthStyle> for tinyinference_llm::providers::openai::AuthStyle {
++impl From<AuthStyle> for CompatAuthStyle {
+ fn from(style: AuthStyle) -> Self {
+ match style {
+ AuthStyle::Bearer => Self::Bearer,
+ AuthStyle::Anthropic => Self::Anthropic,
+ AuthStyle::None | AuthStyle::OpenhumanJwt => Self::None,
+ }
+ }
+}
+
+ /// The registry auth style for a host [`AuthStyle`]; `None` for the managed
+ /// JWT style, which never reaches the registry.
+ pub(super) fn registry_auth_style(style: AuthStyle) -> Option<CompatAuthStyle> {
+ match style {
+ AuthStyle::Bearer => Some(CompatAuthStyle::Bearer),
+ AuthStyle::Anthropic => Some(CompatAuthStyle::Anthropic),
+ AuthStyle::None => Some(CompatAuthStyle::None),
+ AuthStyle::OpenhumanJwt => None,
+ }
+ }
+
+ /// Host-resolved inputs for [`build_cloud_model`].
+ pub(super) struct CloudBuild<'a> {
+ pub(super) spec: ProviderSpec,
+ pub(super) auth_style: CompatAuthStyle,
+ pub(super) key: &'a str,
+ pub(super) temperature_override: Option<f64>,
+ pub(super) temperature_unsupported_models: &'a [String],
+ pub(super) native_tool_calling: bool,
+ pub(super) default_provider_options: Option<serde_json::Value>,
+ pub(super) extra_headers: &'a [(String, String)],
+ pub(super) extra_query_params: &'a [(String, String)],
+ pub(super) user_agent: Option<&'a str>,
+ pub(super) codex: Option<&'a OpenAiCodexRouting>,
+ pub(super) http: Option<reqwest::Client>,
+ }
+
+ impl<'a> CloudBuild<'a> {
+ fn options(&self) -> ProviderBuildOptions<'a> {
+ ProviderBuildOptions {
+ auth_style: Some(self.auth_style.clone()),
+ temperature_override: self.temperature_override,
+ temperature_unsupported_models: self.temperature_unsupported_models,
+ native_tool_calling: Some(self.native_tool_calling),
+ default_provider_options: self.default_provider_options.clone(),
+ extra_headers: self.extra_headers,
+ extra_query_params: self.extra_query_params,
+ user_agent: self.user_agent,
+ codex: self.codex,
+ http: self.http.clone(),
+ ..ProviderBuildOptions::default()
+ }
+ }
+
+ fn registry(
+ &self,
+ ) -> ProviderRegistry<impl tinyinference_llm::providers::registry::CredentialResolver + '_>
+ {
+ let key = self.key.to_string();
+ ProviderRegistry::new(move |_: &ProviderSpec| Ok(key.clone()))
+ }
+ }
+
+ /// Builds the chat model for a resolved cloud route through the registry.
+ pub(super) fn build_cloud_model(build: CloudBuild<'_>) -> anyhow::Result<Arc<dyn ChatModel<()>>> {
+ log::debug!(
+ "[providers][cloud-spec] build slug={} kind={} auth={:?}",
+ build.spec.provider,
+ build.spec.kind.as_str(),
+ build.auth_style
+ );
+ build
+ .registry()
+ .build_with(&build.spec, build.options())
+ .map_err(|error| anyhow::anyhow!("[chat-factory] {error}"))
+ }
+
+ /// The registry's listing request for a resolved cloud route (headers, pinned
+ /// OpenRouter providers), or `None` when the route has no discoverable
+ /// listing.
+ pub(super) fn cloud_discovery_request(
+ build: &CloudBuild<'_>,
+ ) -> Option<tinyinference_llm::model::discover::DiscoveryRequest> {
++ if build.codex.is_some_and(|codex| codex.using_oauth) {
++ return None;
++ }
+ match build
+ .registry()
+ .discovery_request(&build.spec, &build.options())
+ {
+ Ok(request) => request,
+ Err(error) => {
+ log::debug!(
+ "[model_limits] registry discovery unavailable slug={}: {error}",
+ build.spec.provider
+ );
+ None
+ }
+ }
+ }
+
#[cfg(test)]
#[path = "cloud_spec_tests.rs"]
mod tests;