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(anthropic): restrict native Messages API to first-party endpoint
Steven Enamakelb03303a58009
diff --git a/src/openhuman/inference/provider/crate_anthropic.rs b/src/openhuman/inference/provider/crate_anthropic.rsindex 778a8d1a4c..dea60c6b7f 100644--- a/src/openhuman/inference/provider/crate_anthropic.rs+++ b/src/openhuman/inference/provider/crate_anthropic.rs@@ -22,6 +22,17 @@ use std::sync::Arc;use tinyinference::model::{ChatModel, ModelRequest, ModelResponse, ModelStream};use tinyinference::providers::anthropic::AnthropicModel;+/// Whether an endpoint is known to speak the Anthropic Messages API.+///+/// Authentication style is not sufficient to select the wire protocol:+/// existing configurations may use an Anthropic key with an OpenAI-compatible+/// proxy. Keep those endpoints on Chat Completions unless the endpoint is the+/// first-party Messages API.+pub(crate) fn endpoint_is_anthropic_messages(endpoint: &str) -> bool {+ crate::openhuman::config::schema::cloud_providers::endpoint_host(endpoint)+ .is_some_and(|host| host == "api.anthropic.com")+}+/// The resolved config for one Anthropic Messages API provider.pub(crate) struct CrateAnthropicConfig<'a> {/// Base URL (`https://api.anthropic.com/v1` for the hosted API; a@@ -98,9 +109,16 @@ pub(crate) fn build_crate_anthropic_model(config.model,config.temperature_override);+ let model_matches_unsupported_pattern = config+ .temperature_unsupported_models+ .iter()+ .any(|pattern| crate::openhuman::inference::temperature::glob_match(pattern, config.model));+ let adapter_temperature_override = (!model_matches_unsupported_pattern)+ .then_some(config.temperature_override)+ .flatten();let model = AnthropicModel::with_base_url(config.api_key, config.endpoint).with_model(config.model)- .with_temperature_override(config.temperature_override);+ .with_temperature_override(adapter_temperature_override);let model: Arc<dyn ChatModel<()>> = Arc::new(model);if config.temperature_unsupported_models.is_empty() {modeldiff --git a/src/openhuman/inference/provider/crate_anthropic_tests.rs b/src/openhuman/inference/provider/crate_anthropic_tests.rsindex 98c83bdb12..22c41bf075 100644--- a/src/openhuman/inference/provider/crate_anthropic_tests.rs+++ b/src/openhuman/inference/provider/crate_anthropic_tests.rs@@ -1,5 +1,16 @@use super::*;+#[test]+fn only_first_party_anthropic_endpoint_selects_messages_api() {+ assert!(endpoint_is_anthropic_messages(+ "https://api.anthropic.com/v1"+ ));+ assert!(!endpoint_is_anthropic_messages(+ "https://anthropic-proxy.example/v1"+ ));+ assert!(!endpoint_is_anthropic_messages("https://api.openai.com/v1"));+}+#[test]fn builds_a_native_anthropic_model_with_the_configured_profile() {let model = build_crate_anthropic_model(CrateAnthropicConfig {diff --git a/src/openhuman/inference/provider/factory_part_04.rs b/src/openhuman/inference/provider/factory_part_04.rsindex 1f95a594d2..e6d5506770 100644--- a/src/openhuman/inference/provider/factory_part_04.rs+++ b/src/openhuman/inference/provider/factory_part_04.rs@@ -399,7 +399,9 @@ fn try_create_cloud_slug_chat_model_from_string_with_native_tools(// places `cache_control` breakpoints. Text mode (prompt-guided// tools) is only implemented on the Chat Completions adapter, so// that rare case keeps the compat path.- if native_tool_calling {+ if native_tool_calling+ && super::crate_anthropic::endpoint_is_anthropic_messages(&endpoint)+ {crate::openhuman::security::egress::emit_external_transfer(crate::openhuman::security::egress::EgressDescriptor::inference(&slug,