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(tinyagents): add per-turn model selection policy
Steven Enamakel75d37a3f425e
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs b/crates/openhuman-core/src/agent/tinyagents/turn_models.rsindex f9c6ea4d1b..8c9e7ecdd5 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_models.rs@@ -531,7 +531,11 @@ impl TurnModelSource {let provider_string = cn.primary_override.clone().unwrap_or_else(|| {crate::inference::provider::provider_for_role(&cn.role, &cn.config)});- let is_local = tinyinference_local::profile::is_local_provider_string(&provider_string);+ let is_local = crate::agent::tinyagents::turn_policy::provider_is_self_hosted(+ &provider_string,+ crate::agent::tinyagents::turn_policy::local_openai_endpoint(&cn.config)+ .as_deref(),+ );let provider_id = if provider_string == "openhuman"|| provider_string.is_empty()|| provider_string == "cloud"diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rsindex 3d0b264234..59dd0fe4f0 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs@@ -70,11 +70,54 @@ pub(super) const LOCAL_AGENT_TURN_TIMEOUT_SECS: u64 = 14_400;/// first.pub(crate) const LOCAL_WEB_TURN_BACKSTOP_GRACE_SECS: u64 = 300;-/// Whether `config` routes the chat workload to a local / self-hosted provider-/// (`ollama:`, `lmstudio:`, `mlx:`, ...).+/// Whether `provider` (a provider string such as `ollama:llama3`) with the+/// resolved `endpoint` is a local / self-hosted runtime, which gets the longer+/// ceilings (#6042).+///+/// Do not use `tinyinference_local::profile::is_local_provider_string` for this+/// on its own: it maps the bare name `openai` onto the generic local+/// OpenAI-compatible kind, so hosted OpenAI would be classed as local and lose+/// its tight hang detection. Locality comes from the runtime kind and the+/// endpoint instead:+/// - Ollama / LM Studio / MLX / oMLX are self-hosted by definition.+/// - The generic OpenAI-compatible kinds (`local-openai`, `llamacpp`, `vllm`,+/// bare `openai`...) can point anywhere, so they are local only when the+/// endpoint host is loopback or on a private network.+/// - `openai:<model>` and every other cloud provider are never local.+pub(crate) fn provider_is_self_hosted(provider: &str, endpoint: Option<&str>) -> bool {+ use tinyinference_local::profile::{kind_from_provider_string, LocalProviderKind};+ let p = provider.trim().to_ascii_lowercase();+ let Some(kind) = kind_from_provider_string(&p) else {+ return false;+ };+ match kind {+ LocalProviderKind::LocalOpenai => endpoint+ .and_then(|url| url::Url::parse(url).ok())+ .is_some_and(|parsed| crate::util::url::host_is_local(&parsed)),+ _ => true,+ }+}++/// Whether `config` routes the chat workload to a local / self-hosted provider.pub(crate) fn chat_provider_is_local(config: &crate::config::Config) -> bool {let provider = crate::inference::provider::provider_for_role("chat", config);- tinyinference_local::profile::is_local_provider_string(&provider)+ provider_is_self_hosted(&provider, local_openai_endpoint(config).as_deref())+}++/// The endpoint the generic local OpenAI-compatible runtime resolves to:+/// `LOCAL_OPENAI_URL`, else `local_ai.base_url`, else the profile default.+pub(crate) fn local_openai_endpoint(config: &crate::config::Config) -> Option<String> {+ std::env::var("LOCAL_OPENAI_URL")+ .ok()+ .filter(|v| !v.trim().is_empty())+ .or_else(|| config.local_ai.base_url.clone())+ .or_else(|| {+ Some(+ tinyinference_local::profile::LOCAL_OPENAI_PROFILE+ .default_base_url+ .to_string(),+ )+ })}/// Resolve the per-turn wall-clock ceiling in milliseconds for the harness