The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(inference): add cloud provider slug resolution and discovery
Steven Enamakelb577cabc44b0
diff --git a/crates/openhuman-core/src/inference/provider/factory.rs b/crates/openhuman-core/src/inference/provider/factory.rsindex 4e6ab1bf6e..1bef26b8eb 100644--- a/crates/openhuman-core/src/inference/provider/factory.rs+++ b/crates/openhuman-core/src/inference/provider/factory.rs@@ -33,6 +33,7 @@//! - [`managed_backend`] — the managed OpenHuman backend model.//! - [`local_runtime`] — Ollama / LM Studio / MLX / OMLX / local-openai.//! - [`cloud_slug`] — `<slug>:<model>` BYOK cloud providers.+//! - [`cloud_spec`] — `CloudProviderCreds` → `ProviderSpec` → `ProviderRegistry`.//! - [`subprocess_providers`] — Claude Agent SDK and Claude Code CLI.//! - [`chat_model`] — the one-shot `create_chat_model*` entry points.//! - [`turn_model`] — the per-turn `create_turn_chat_model*` entry points.@@ -40,6 +41,7 @@pub(crate) mod access_gates;mod chat_model;mod cloud_slug;+mod cloud_spec;mod credentials;mod discovery;mod local_runtime;diff --git a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rsindex c7386898b8..5bf5343ffc 100644--- a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs@@ -8,7 +8,6 @@ use crate::inference::provider::factory::access_gates::verify_backend_session_acuse crate::inference::provider::factory::access_gates::verify_session_active;use crate::inference::provider::fallback_diagnostics;use tinyinference_llm::providers::anthropic::endpoint_is_anthropic_messages;-use tinyinference_llm::providers::openai::endpoint_is_openrouter;/// Look up a `cloud_providers` entry by slug and build the provider./// The shared resolution for a `<slug>:<model>` cloud provider — the cloud@@ -411,27 +410,7 @@ pub(super) fn try_create_cloud_slug_chat_model_from_string_with_native_tools(Some(chat.map(|chat| (chat, effective_model)))}-/// The `provider.sort` OpenRouter routing preference sent on every request to-/// a direct (BYOK) OpenRouter endpoint.-pub(crate) const OPENROUTER_PROVIDER_SORT: &str = "price";--/// Baked request options for a direct OpenRouter endpoint, `None` for every-/// other OpenAI-compatible host.-///-/// OpenRouter's default routing is a health-aware load balance weighted toward-/// the cheaper endpoints of a model's pool, which spreads consecutive turns-/// across endpoints. DeepSeek- and Z.AI-family prefix caches live per endpoint,-/// so every hop re-pays the whole prefill. `provider.sort` orders the pool and-/// disables the balancing (not the fallback: `allow_fallbacks` stays on and-/// `order` is never set, so a request still moves down the sorted list when an-/// endpoint errors), and `price` is the stable choice — cheapest first, dearer-/// only on failure. Stickiness itself comes from the harness's derived-/// `prompt_cache_key` (`tap-<prefix fingerprint>`), which OpenRouter honours as-/// its sticky-routing key; measured on `z-ai/glm-5.3-flash` the same endpoint-/// served 5/5 calls with it. The hosted backend applies the same sort-/// server-side (tinyhumansai/backend#1370), so managed and direct routing agree.-/// https://openrouter.ai/docs/features/provider-routing-pub(crate) fn openrouter_default_provider_options(endpoint: &str) -> Option<serde_json::Value> {- endpoint_is_openrouter(endpoint)- .then(|| serde_json::json!({ "provider": { "sort": OPENROUTER_PROVIDER_SORT } }))-}+/// Baked request options for a direct OpenRouter endpoint (`provider.sort =+/// price`), `None` for every other host. The policy and its rationale live with+/// the registry in `tinyinference-llm`.+pub(crate) use tinyinference_llm::providers::registry::openrouter_default_provider_options;diff --git a/crates/openhuman-core/src/inference/provider/factory/discovery.rs b/crates/openhuman-core/src/inference/provider/factory/discovery.rsindex 7025113cad..aef17a31b0 100644--- a/crates/openhuman-core/src/inference/provider/factory/discovery.rs+++ b/crates/openhuman-core/src/inference/provider/factory/discovery.rs@@ -4,7 +4,7 @@//! endpoint the turn actually talks to.use super::*;-use tinyinference_llm::model::discover::{pinned_openrouter_providers, DiscoveryRequest};+use tinyinference_llm::model::discover::DiscoveryRequest;/// The discovery request for `provider` (a role's resolved provider string)/// serving `model`, or `None` when the route has no listing to ask:@@ -66,22 +66,21 @@ pub(crate) fn model_limits_request(log::debug!("[model_limits] codex oauth routing has no window listing slug={slug}");return None;}- let endpoint = resolution.codex.endpoint.clone();- let mut request = DiscoveryRequest::new(&endpoint, &resolution.effective_model);- let key = resolution.key.trim();- if !key.is_empty() {- request = match resolution.entry.auth_style {- AuthStyle::Anthropic => request- .with_header("x-api-key", key)- .with_header("anthropic-version", "2023-06-01"),- AuthStyle::Bearer => request.with_header("Authorization", format!("Bearer {key}")),- AuthStyle::None | AuthStyle::OpenhumanJwt => request,- };- }- if let Some(options) = super::cloud_slug::openrouter_default_provider_options(&endpoint) {- request = request.with_pinned_providers(pinned_openrouter_providers(&options));- }- Some(request)+ let auth_style = super::cloud_spec::registry_auth_style(resolution.entry.auth_style)?;+ let (extra_headers, temperature_unsupported) = (Vec::new(), Vec::new());+ super::cloud_spec::cloud_discovery_request(&super::cloud_spec::CloudBuild {+ spec: super::cloud_spec::cloud_provider_spec(resolution.entry, &resolution.effective_model),+ auth_style,+ key: resolution.key.as_str(),+ temperature_override: None,+ temperature_unsupported_models: &temperature_unsupported,+ native_tool_calling: true,+ extra_headers: &extra_headers,+ extra_query_params: &[],+ user_agent: None,+ codex: Some(&resolution.codex),+ http: None,+ })}/// The managed backend's catalogue listing, authenticated with the backend